Control theory
LiveGrapher lab

In this lab, we'll be using the LiveGrapher real-time graphing application to display various waveforms and tune the parameters of a simulated mechanical system.

Installation

Clone the LiveGrapher Git repository with git clone git://github.com/frc3512/LiveGrapher. Follow the instructions in its README to build it.

Motion profile data

Note: At the moment, the test server only builds on Linux. Until this is resolved, Windows users should skip this section.

LiveGrapher uses a client-server model for data transmission. The program we just built is the LiveGrapher client application, so a server is needed to test your setup. Our test server will simulate the output of S-curve and trapezoidal motion profiles. Run the following commands in the parent directory of your LiveGrapher repository folder.

git clone git://github.com/frc3512/LiveGrapher
cd LiveGrapher/test
make

After the build is complete, start the server.

Edit LiveGrapher's IPSettings.txt to use a robotIP of 127.0.0.1. This instructs LiveGrapher to look for a running server on the local machine, known as localhost. The defaults for the other options are fine. Read the README for documentation on the other options.

Start the client and click the "Connect" button. A dialog box should pop up with two check boxes. These correspond to two different graph datasets the server is providing. Select at least one, then click "Ok". You should see a graph start to scroll by. The axes will automatically scale to fit the data the graph contains. To view the other dataset, click the "Connect" button and choose different checkboxes from the dialog.

DC brushed motor simulation

Our robotics team mainly uses LiveGrapher to display the state of mechanical subsystems of our robots in real-time so we can tune their response. This part will walk you through tuning the feedback controller for a simulated DC brushed motor.

Replace LiveGrapher/test/src/Main.cpp with this file, rebuild the project, and rerun the server. After reconnecting LiveGrapher, two datasets will be available: "Reference" and "Velocity". Graph both of them.

In robotics, we use feedback controllers to make motors track a desired reference signal. Your goal is to make the motor's rotational velocity track the reference shown on the graph. Do this by modifying the PID constants in DCMotor.cpp, rebuilding and rerunning the server, then watching the response in LiveGrapher. See controls-engineering-in-frc.pdf for advice on manually tuning a PID controller.

Submission

Use the folder name live-grapher for this project. Once you feel your motor is tracking the reference step inputs well, hit the "Clear Data" button, let a couple reference changes with the motor response show up on the graph, then save the graph data to a .csv file with the "Save" button. Include this in your assignment submission repository alongside an src folder containing all the files you used except the Main.cpp that was removed. Do not forget your DCMotor.cpp file which contains your modified PID gains.