text
stringlengths
0
715
visionTrackBlue = true;
printControllerSetup();
Controller1.Screen.print("Vision Track: BLUE");
} else {
Intake.spin(reverse, 11, volt);
}
}
void buttonL1Released() {
Intake.stop();
}
void buttonL2Released() {
Intake.stop();
}
void buttonR1Pressed() {
//retract extension mechanism
Wings.set(false);
}
void buttonR2Pressed() {
//expand extension mechanism, if button B is pressed
if (Controller1.ButtonB.pressing()) {
Wings.set(true);
}
}
void buttonUpPressed() {
//increase the RPM of the flywheel when the up button is pressed
if (Controller1.ButtonB.pressing()) {
//fine control if another button is held down
flywheelTargetRPM += 10;
} else {
flywheelTargetRPM += 100;
}
printController(flywheelTargetRPM);
}
void buttonDownPressed() {
//decrease the RPM of the flywheel when the down button is pressed
if (Controller1.ButtonB.pressing()) {
//fine control if another button is held down
flywheelTargetRPM -= 10;
} else {
flywheelTargetRPM -= 100;
}
printController(flywheelTargetRPM);
}
void buttonLeftPressed() {
//align to goal first lol
auton = true;
if (visionAlign) {
alignToGoal();
} else {
//display the number
int x = 0;
int center = 158;// the goal should be at x=100 when lined up perfectly with the robot
//look at the leftmost instance of the goal
int maxArea = 0;
int maxX = -1;
for (int k = 0; k < 5; k++) {
if (visionTrackRed) {
VisionSensor.takeSnapshot( VisionSensor__RED_GOAL );
//if this is the new highest area, then update the variable
int area = VisionSensor.largestObject.width * VisionSensor.largestObject.height;
if (area > maxArea && area > 400) {
maxArea = area;
maxX = VisionSensor.largestObject.originX + (VisionSensor.largestObject.width / 2);
}
}
if (visionTrackBlue) {
VisionSensor.takeSnapshot( VisionSensor__BLUE_GOAL );
int area = VisionSensor.largestObject.width * VisionSensor.largestObject.height;
if (area > maxArea && area > 400) {
maxArea = area;
maxX = VisionSensor.largestObject.originX + (VisionSensor.largestObject.width / 2);
}
}
wait(20, msec);
}
if (maxX == -1) {
//dont do anything if no goal is detected
x = center;
} else {
x = maxX;
}
printController((x / 316.0 * 60) - 30);
}
auton = false;
//automatically fire all three disc
Indexer.spin(forward, 11, volt);
wait(200, msec);
Indexer.spin(reverse, 11, volt);
wait(120, msec);
Indexer.spin(reverse, 3, volt);
tripleShooting = true;
wait(50, msec);
Indexer.spin(forward, 11, volt);
wait(200, msec);
Indexer.spin(reverse, 11, volt);
wait(120, msec);
Indexer.spin(reverse, 3, volt);
wait(50, msec);
Indexer.spin(forward, 11, volt);
wait(200, msec);