Need help figuring out how to use PID to go over an obstacle turn to a certain point. (ex. The position that the robot calibrates at)
This is the code I have so far.
myRobot.SetSafetyEnabled(false);
myRobot.Drive(-.5,0.0);
Wait(1.5);
myRobot.Drive(0.0, 0.0);
turnController->SetSetpoint(0.0f);
Wait(2.0); // Have to wait till the bot turns
This is a simple P loop. It takes the angle error, multiplies it by a constant you specify, and applies that as the output for your drive. As you get closer, your output gets smaller because the error gets smaller, and it coasts to a stop. Note that due to the fact that a drive train needs a certain percentage to actually drive (e.g. 10%), it will never actually make it the whole way to where you want it to go with just a P loop, although you could make it where it gets pretty close, depending on how you tune your constant.
If you want to get more complex than that, you could use a PI loop, but that’s another story.
PID presumes continuous measurements. If you are crossing the low bar with no jerky movements, then PID works ok for driving straight (our robot drives like a slightly drunken sailor).
Over the other Defenses, the jerkiness throws off PID. You will eventually head in the right direction (gyro), but you may be off track to the left/right.
Yeah but the issue is its unpredictability. For example, the ramparts tend to send robots in any direction, and there’s no good way to predict that. Also, a couple inches can be a big deal, particularly when trying to shoot without a vision system. Earlier in the season, we calculated that the margin of error when shooting the high goal in auto (if you go straight through the low bar and spin) to be ~1.5 degrees and 2-3 inches IIRC.
We did not use a PID just the Proportional part of it… and it is good enough to cross the ramparts in auto, then spin 180 and cross them again during lab work. We never had any issues staying straight on any of the defenses.
There are some items that we will be cleaning up in the off season but it did work.
As a matter of fact auto was better then telle-op.