#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;
}
顺便说一下,开始距离是 178,我不知道为什么机器人会过度转弯,只是一点点,但我不知道为什么。我也在使用squarebot。我正在使用 robocci 程序。我使用挂钩作为开始距离。