Tuning

Oh no! The bot doesn’t move! That’s because you need to tune.

Setting up the code:

  1. Set the path as a long (~half the field) straight line.

  2. Go to Constants.java and change Constants.AutoConstants.MAX_VEL and Constants.AutoConstants.MAX_ACCEL to something reasonable (it really depends on how fast the chassis is. But try to keep it at a safe speed)

  3. Set Constants.ChassisConstants.kV to a small number like 0.5

Now you’re basically ready to go! But in order to tune effectively, we need to see how the bot reacts to different inputs. Thus, we can use Glass to view velocity graphs.

Setting up Glass:

  1. Open up WPIlib Glass

  2. Configure these settings and click apply

../_images/glass_setup.PNG

Note

Make sure to change “Team/IP” to your correct team number

  1. Go to “Plot” in the toolbar and select “New Plot Window”

  2. Click “Add Plot”

  3. Do steps 3 & 4 twice to add 2 plots

  4. From the “NetworkTables” tab, drag and drop “actual left vel” and “desired left vel” to one of the plots and “actual right vel” and “desired right vel” to the other plot

  5. Now, all the velocities will be graphed when you run the path.

Running the Code and Tuning:

Now your ready to run the code!

Keep running the code until the max actual velocity is around the same place as the max desired velocity.

../_images/untuned.PNG

And then…

../_images/kv.PNG

Next we will tune the kA. Keep tuning the KA until the accerlation and deceleration parts of the profile matches between the actual and desired velocities. It should end up like this:

../_images/ka.PNG

Next we will tune the kP. Keep tuning the kP until the actual graph matches the desired graph even better.

../_images/kp.PNG

Note

It is okay if the robot does not drive straight. We will correct this later on.

Correcting for Positional Error:

What RAMSETE (a nonlinear state-space feedback controller) does is that it looks at the robot’s current position and corrects its velocities based on the calculated error.

To add RAMSETE, go to TrajectoryFollower.java, and uncomment line 61 and comment line 62.