A proportional loop is a control method that uses the idea of ‘error’. You take your setpoint (your target position), and subtract it by the motor’s current position. As you move away from your target, your error will grow larger. And as you get closer, your error gets smaller. If you set the motor’s speed to the value of your error, you would see your motor speed up and slow down depending on its positon.
The problem is that this error doesn’t work very well with the voltages/speeds the motor takes. So we multiply the error by a constant called kP (proportional). The value kP contains depends on how you want the motor to behave. If kP is too large, your motor will overshoot its target. When correcting for the overshoot, it will overshoot again. This repeated overshooting creates an oscillating pattern. If kP is too small, the motor might move slowly or it might not ever reach its target (as it won’t have enough power to push the motor). So we want kP to be tuned to a nice goldilox zone.
An easy way to tune kP is to set kP to 1. If it doesnt overshoot, increase kP. If it overshoots, you lower the value of kP. Rinse and repeat till you find a good value.
Better than just a P loop is a PID loop. It is a proportional loop, but it also has integral and derivative values. The integral helps move the motor to its position as it gets closer to the target. And the derivative helps lower the effects when you change the target. PID is what the motor.rotateTo() function uses to reach its target. The hold brake mode also uses PID to keep its position.