Robot arc turning when it's not supposed to

Hi, we have a PD and the robot is arc turning when it isn’t supposed to. I’m not the primary programmer but my understanding is that runTask() runs the PD with the first parameter being distance, the second being the angle, and the third being speed. However, when we run something like runTask(0,30), it will arc turn. All other commands work as they should. Does anyone know why and how to fix this? Thanks!

Hello. It would be a bit difficult to solve your problem without looking at your actual code. From your description, would it be that your first parameter being incorrectly set to left wheel velocity and second one be set to right wheel? That will let the robot to do an arc turn to the left. Thank you.

2 Likes

Add a PID that uses the difference of the encoder values between the two sides of the drive as the error value, and add the output value of this new PID to your drive velocity input

Here’s a link to our code.

It seems that you put the drive and the turn pid into a single function. What this will produce is that when the robot is supposed to turn, the left and right wheels will spin in different direction, causing the variables leftMotorRotation and rightMotorRotation to change in different directions (i.e. one will increase and one will decrease). If these two variables change in the exact same rate, then there should be no problem since it is taking the average of the two. If not, this will cause the lateralMotorPower to either go up or down. What I did is to separate the turn and drive into different pid functions, so that one will only rely on the imu/gyro and one will rely on the motor encoders. Also, one tip is that separating the left and right side into giving them different motor powers, to let it go straighter. Hope this helps!

2 Likes