Ramsete Command Advice | Fixing path following and repeated motor oscillation

I have been trying to implement the Ramsete Command for trajectory following, but I have been running into problems of which I have no idea how to fix. So far, I have been able to create and run trajectories with the Ramsete Command to make the robot move straight or backwards x amount of meters, but any other type of trajectory has so far been a failure.

This is because very time we tell our bot (which consists of 6 motors controlled by spark MAXES using differential drive) to end at say position (1,1) with an end rotation of 0, the motors repeatedly oscillate while going on its diagonal path from (0,0). The motors even oscillate when I try to run trajectories which only manipulate the heading of the bot. I have referred to other posts noting of similar problems which point to PID and how the voltages are fed into the motors, but after ensuring the drive.feed() methods are in the right spots and after manually tampering with my 2 PID controller’s Kp and Kd values to try to dampen the effect, I have seen no improvement thus far.

I do believe this may be an over correction problem with the PID, but changing the constants didn’t do me any good. I have reviewed my code and ran additional motion profiling tests for the PID vals, but I still can’t figure out how to fix it.

My code is accessible here, and is based off of the Ramsete Comand example provided by wpilib. If someone has any Idea how to go about this, I’m all ears. Thanks!

Are you sure you selected the “Velocity” loop type in the characterization tool? Your Kd should be zero and your Kp should be way lower than that.

To put your values in context, your PID controller will output 46.8 volts to the motor when the velocity error is 1 meter per second.

Oh, I apologize, I uploaded an earlier version of it, these were my most recent values, kP=0.3, kI=0.0001, kD=1;

I would first zero all feedback gains i.e. Kp, Ki, and Kd and then run the trajectory. If the tracking looks reasonable (might not be exactly accurate), then the oscillation has to do something with your feedback gains.

If not, then you might have a units error somewhere in your code which is causing the Ks, Kv, and Ka values to be incorrect.

Also, another thing I noticed was that your Kv and Ka values seem a little bit high. Some napkin math to calculate your robot’s max velocity (12 volts / Kv) suggests that your robot’s top speed is 1.76 m/s or 5.7 feet per second. Is this correct?

You can also consult the troubleshooting documentation for code examples and more in-depth methods of troubleshooting poor performance when tracking trajectories.

1 Like

Ok, I will check this out and come back later. The max speed doesn’t sound correct to me, so I will check that out first. Thanks for the tip.

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.