Hey guys. So we were trying to implement a PID loop for our programming skills match. We’ve tried to reproduce @Connor 's PID loop on PROS. Here’s our code.
The problem is nothing happens when we run our code.
Can you guys help me, please?
Hey guys. So we were trying to implement a PID loop for our programming skills match. We’ve tried to reproduce @Connor 's PID loop on PROS. Here’s our code.
set enablepid to true at the start of auton. your teleop might be running first and disabling it.
Also, the thread will exit when the auton function ends.
It may help to have a solid understanding of PID when you run into issues in the future. Here is a great place to learn PID from basic to advanced.
While this isn’t a super basic resource, there’s a lot of information especially on the practical implementation of a PID controller.
We’ve tried but it didn’t work anyway
We were thinking that maybe there was a problem with the function move_voltage because it sets the voltage from -12000 mV to 12000 mV. And in our case where the lateral motion is error * kp=200 * 0.2=40 and the turn motion is 0, the motors will move at 40 mV which is very small compared to 12000 mV. So this voltage gets ignored. That’s just my theory. Do you think that it could be the reason why the motors don’t seem move?
yes, that is exactly why. The motors do not produce enough torque at that voltage to overcome the friction of existing.
Okay thank you. We’ll try this in our next meeting. Hope it works
Thank you!! It worked just fine
is this PID loop using a 2 motor base? I’ve been trying to learn PID for myself but my team uses a 4 motor base.
it’s the exact same code, just set the sides instead of individual motors
Yes we are using a 2 motor base. If you’re using a 4 motor base, you should sum the position of all 4 motors and divide it by 4 to get the average position.
For turning, I think that you should calculate the average position for the two motors in each side and then subtract the average of the right motors from the average of the left motors. And the rest should be the same.
I am not really sure about the turning part though but it seems to me pretty logical and I think that it should theoretically work.
I have a PID programmed that is supposed to just drive forward, but it drives all over the field for some reason.
Isn’t 100 rotations making you across the whole field?
all it is supposed to do is drive straight
set prevError=0; turn_prevError=0;