PID loop in PROS

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.
1
2
3
The problem is nothing happens when we run our code.
Can you guys help me, please?

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.

1 Like

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.

2 Likes

While this isn’t a super basic resource, there’s a lot of information especially on the practical implementation of a PID controller.

4 Likes

We’ve tried but it didn’t work anyway :frowning:

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.

4 Likes

Okay thank you. We’ll try this in our next meeting. Hope it works :crossed_fingers:

Thank you!! It worked just fine :smile:

1 Like

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

2 Likes

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.

1 Like