So I’m working on a simple method to prevent overshoot on my robot. Do you guys have any suggestion?
void drivestraight(int d)
{
SensorValue[leftencoder]=0; //initializes motor encoder
while(SensorValue[leftencoder]<=d) //while the encoder value is less than the desired distance
{
motor[leftDriveMotor]=round((127*(d - SensorValue[leftEncoder])/d)); //left motor is equal to the proportion of x/127 = error/desired
motor[rightDriveMotor]=round((127*(d - SensorValue[leftEncoder])/d));//left motor is equal to the proportion of x/127 =error/desired
}
}
task main()
{
drivestraight(400); //starts the drivestraight function with a specified distance of 400
}