turning radius is inaccurate of the robot is inaccuarate

55 Views Asked by At
#pragma config(StandardModel, "RVW SQUAREBOT")

task main(){
int begindistance = SensorValue[sonarSensor];
while (SensorValue[gyro] < 900){

motor[leftMotor] = 20;
motor[rightMotor] = -20;
}
motor[leftMotor] = 0;
motor[rightMotor] = 0;

SensorValue[leftEncoder] = 0;
SensorValue[rightEncoder] = 0;

while (SensorValue[sonarSensor] > 25){
motor[leftMotor] = 50;
motor[rightMotor] =50;
}

SensorValue[gyro] = 0;

int z = 180 - atan(begindistance/SensorValue[leftEncoder]);
while (SensorValue[gyro] > -z){
motor[leftMotor]  = -31;
motor[rightMotor]  = 31;
}
motor[leftMotor] = 0;
motor[rightMotor] = 0;
}

by the way the begin distance is 178, i dont know why the robot is over turning, by just a little bit, but i dont know why. im also using the squarebot. i am using the robocci program. and i using the peg for the begin distance.

1

There are 1 best solutions below

0
On BEST ANSWER

The gyro sensor does not always start at 0. You need to store the initial value into a variable, and find the difference between the value read and the initial value.

The gyrosensor is also read-only, so this statement

SensorValue[gyro] = 0;

won't work.