text
stringlengths
0
715
while (calibrateTimer < 200) {
if (!Inertial.isCalibrating()) {
printControllerSetup();
Controller1.Screen.print("Recalibrated");
break;
}
calibrateTimer++;
wait (20, msec);
}
}
void setLeftDrive(int velocity1) {
Left1.setVelocity(velocity1, percent);
Left2.setVelocity(velocity1, percent);
Left3.setVelocity(velocity1, percent);
}
void setRightDrive(int velocity1) {
Right1.setVelocity(velocity1, percent);
Right2.setVelocity(velocity1, percent);
Right3.setVelocity(velocity1, percent);
}
void buttonRightPressed() {
//Automatically balance the robot
ElevationPiston.set(true);
auton = true;
Left1.spin(forward);
Left2.spin(forward);
Left3.spin(forward);
Right1.spin(forward);
Right2.spin(forward);
Right3.spin(forward);
setLeftDrive(90);
setRightDrive(90);
wait(200, msec);
setLeftDrive(40);
setRightDrive(50);
wait(400, msec);
setLeftDrive(40);
setRightDrive(-80);
wait(200, msec);
Left1.stop();
Left2.stop();
Left3.stop();
Right1.stop();
Right2.stop();
Right3.stop();
auton = false;
}
void checkOverheating() {
//check for overheating in any of the motors
if (Left1.temperature(percent) > 60 || Left2.temperature(percent) > 60 || Left3.temperature(percent) > 60 || Right1.temperature(percent) > 60 || Right2.temperature(percent) > 60 || Right3.temperature(percent) > 60 || Kicker.temperature(percent) > 60) {
if (overHeatingTimer == 0) {
Controller1.rumble(rumbleLong);
printControllerSetup();
Controller1.Screen.print("Real Overheating Warning");
overHeatingTimer++;
} else {
overHeatingTimer++;
if (overHeatingTimer > 750) overHeatingTimer = 0;
}
}
}
int kickerLoop() {
//shoot the kicker when there is a triball and keep it loaded at all times
bool reachedBottom = false;
while (true) {
//check if it is optical sensor mode
wait(20, msec);
if (kickerOn) {
KickerLED.on();
if (KickerDrawback.objectDistance(mm) < 90) {
if (KickerDistanceSensor.objectDistance(mm) < 40) {
//triball detected
Kicker.spin(reverse, 11, volt);
} else {
//no triball detected
Kicker.stop();
}
reachedBottom = true;
} else {
Kicker.spin(reverse, 11, volt);
reachedBottom = false;
}
} else {
Kicker.stop();
KickerLED.off();
}
}
return 0;
}
int intakeLoop() {
//spin at 3 volts when the efficency is 0
while (true) {
//check if the intake is on
wait(20, msec);
if (intakeOn) {
if (Intake.efficiency(percent) < 10) {
//if the intake is on and efficency is low, there is likely a triball in there; reduce the voltage to lower strain on the motor
Intake.spin(reverse, 2, volt);
} else {
//otherwise, spin normally