A big problem I have for auton is having my robot pivoting/turning in place. I usually overshoot/undershoot my desired angle or have some horizontal/vertical displacement, and this is with PID. Can someone post an example of some pretty good turning code or just some tips and tricks i can use in my code.
What sensors do you currently use for feedback?
Gyro mostly but also encoders. Gyro to obviously get the angle (it might be i calibrated the thing wrong) and encoders because in theory, both sides of the base should move the same distance
Well for one thing with a gyro, the robot gains momentum that doesn’t immediately dissipate, so for a 90 degree turn, you may have to set it to stop at say 60-70 degrees, or make the motors run in the opposite direction at 90 degrees so that the robot doesnt overshoot and it counteracts the momentum.
+1
Running the motors in the opposite direction for 100ms or so always makes my autonomous actions more accurate.
Another thing you could implement is QCC2’s gyro drift code. Gyroscopes tend to read bad values after collisions/vibrations and this is a good way to solve that. I don’t have the exact link on me right now, but it shouldn’t be too hard to search it up.
Also if your turns are still having issues even with PID, then maybe your constants aren’t tuned as well as they could be (probably).
Hey! I have attached a link to our programming for ITZ, which had a PID for the turns that was pretty consistent. Let me know what you think.
https://github.com/AndrewGonzalez8/2297A-In-the-Zone-Season-2017-2018-/blob/master/Worlds%20Robot.c
@Team_2297A Do you do any calibration or scaling for the gyro other than the pre_auton part? Usually, for me, the gyros I’ve used aren’t perfectly 3600 ticks per revolution meaning I have to apply some scaling (I mean the closest I’ve ever gotten to a perfect gyro was 3800 ticks per revolution). When you turn, do you experience any major displacement or does the robot turn in place pretty well? One thing I really like is the use of for loops to run parts for a specific amount of seconds. For your integral, you continuously use it until the error reaches zero. Usually, I have it where I only use the integral within a certain range. Has the integral been a problem at times?
We have not had any problems with the scaling, given that in oren autonomous I set the SensorScale(gyro) value to the correct one for my personal gyroscope. Also, being very honest with you, I usually don’t use Ki because it makes the robot unstable.