Using PID for traction control (help!)

Hi all,
I’m back to working on traction control code, and it doesn’t seem to work :frowning: The first thing that I’m trying to get working is to get the wheels to go at the same velocity as the robot.

Here’s the setup: we have an omni (trailer) wheels on each side of the robot, plus encoders on the omnis and on each transmission. This lets us see the velocity the wheels are going, and the velocity the robot (via the omnis) is going.

Here is my algorithm for maintaining the velocity indicated by the omni wheels, in pseduocode:

pidSetpoint = getOmniVelocity()  // get velocity according to encoder on omni wheel
pidCurrentPoint = getTransmissionVelocity() // get velocity according to encoder on transmission
change = calculatePID()
newMotorSpeed = currentMotorSpeed + change

I do use different PID’s for the left and right (that would be a stupid bug!) However, this code seems to make the robot go at the correct speed for a while, and then it starts to get faster and start spinning in circles! Does anyone have any ideas as to why this might occur?

Secondly, my plan is to decide if we’re slipping (getOmniVelocity() and getTransmissionVelocity() differ enough) and then kick in the PID correction code until the slipping is over. Does anyone have any real-world success using this (albeit simplistic) method? I’m worried that it will become jerky.

I would have to see more more of your code to tell for sure, but by your description it sounds like your loop just needs some tuning. The spinning in circles is classic PID overshoot.

We use a box with 3 pots (one for P, I, and D) so we can tune without reloading the code.

Turns out that left and right were swapped:mad: The person on our software them (I’m looking at you, Ben) who wrote wrappers over the motors got them mixed up. As a result, we have spent about 2 weeks working on inexplicably buggy drive code.:mad: :mad: :mad:

It works now, though.:smiley: