電力式:電力 = 常數×差距 = 常數×(目標 - 測量) = K * (target - measurement)
We can use the Proportional control (P) to let the robot smooth stop. The concept is that we can let the power be controlled proportionally by distance(error). The distance is defined as the target position minus now position(measurement). The magnitude of power is proportion of the magnitude of distance and The direction of the robot is the direction of distance. If the distance is zero, the robot is static. If the distance is positive, the robot moves forward. If the distance is negative, the robot moves backward. We use degrees sensor to measure the distance.
The power formula is: Power = constant × distance = K * (target - measurement)
Example:
task main()
{
int power,K,target,measurement;
K = 1;
target = 1000;
measurement = MotorRotationCount(OUT_A);
while(1)
{
measurement = MotorRotationCount(OUT_A);
power = K * (target - measurement);
OnFwd(OUT_AC,power);
}
}