Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
Annotate the autonomous routines
Browse files Browse the repository at this point in the history
  • Loading branch information
RubyflameWarrior committed Mar 1, 2024
1 parent c38dc1f commit 276aa16
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 38 deletions.
1 change: 1 addition & 0 deletions include/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ void opcontrol(void);

#ifdef __cplusplus
#include "lemlib/api.hpp"
#include "gif-pros/gifclass.hpp"
#include "global.hpp"
#include "autonomous.hpp"
#include "subsystemHeaders/wings.hpp"
Expand Down
57 changes: 48 additions & 9 deletions src/autonomous.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,16 @@ void AutonWings(unsigned short int msec, bool activateWings){
void autonomous() {
// Informs the program that the robot is in the autonomous phase
GamePhase = 3;
// Sets the auton to the "Left Quals" auton
// autonSelect = 1;

switch (autonSelect) {
case 0:
// Odometry Test Auton
chassis.setPose(0, 0, 0); // X, Y, Heading (degrees)
chassis.moveToPoint(0, 30, 50000);
// chassis.turnTo(45, 45, 5000);
break;
case 1:
// Left Qualification Match Auton
controller.print(0, 0, "Left Quals Auton");
chassis.setPose(-48, -60, 135); // X, Y, Heading (degrees)
ToggleVerticalPneumaticWings();
Expand All @@ -91,52 +91,77 @@ void autonomous() {
controller.print(1, 0, "Auton Completed");
break;
case 2:
// Single triball using PID (made at Gateway)
// Right Qualification Match Auton (single triball using PID)
controller.print(0, 0, "Right Quals Auton");
// Sets the robot's current position as the starting position for LemLib
chassis.setPose(0, 0, 0); // X, Y, Heading (degrees)
// ToggleVerticalPneumaticWings();
pros::delay(1000);
// Delays the next command by 1 second
pros::delay(1000);
// chassis.turnTo(0,-30,2000);
// ToggleVerticalPneumaticWings();
// Drives the robot backwards closer to the goal
chassis.moveToPoint(0, -18, 3000, false, 75);
// ToggleVerticalPneumaticWings();
// chassis.moveToPoint(0,-20,3000,false,75);
// Rams the robot (with the backside facing front) into the goal, scoring the triball
chassis.moveToPoint(0, -36, 3000, false, 75);
// Delays the next command by 1 second
pros::delay(1000);
// Drives the robot away from the goal
chassis.moveToPoint(0, -15, 3000, true, 75);
// Delays the next command by 1 second
pros::delay(1000);
// Rams the robot (with the backside facing front) into the goal again to ensure the triball is scored
chassis.moveToPoint(0, -48, 3000, false, 127);
// Delays the next command by 1 second
pros::delay(1000);
// Drives the robot away from the goal so that it is not touching the triball at the end of the auton phase
chassis.moveToPoint(0, -15, 3000, true, 75);
controller.print(1, 0, "Auton Completed");
break;
case 3:
// Left Side Half AWP
controller.print(0, 0, "Left Elims Auton");
// Sets the robot's current position relative to the middle point of the field
chassis.setPose(-48 - (7.0 / 2), -60, 135); // X, Y, Heading (degrees)
// Lowers the vertical wings, activating them
ToggleVerticalPneumaticWings();
pros::delay(250);
// Turns to the left to begin descoring the match load triball
chassis.turnTo(0, -60, 2000);
pros::delay(250);
// Drives forward to finish descoring the match load triball
chassis.moveToPoint(-45, -60, 2000);
// Lifts the vertical wings, deactivating them
ToggleVerticalPneumaticWings();
pros::delay(250);
// Turns to the elevation bar
chassis.turnTo(0, -60 - 2, 2000);
pros::delay(250);
// Drives towards the elevation bar, stopping in time for the ziptie attached to the intake to touch the elevaiton bar
chassis.moveToPoint(0 - 20, -60 - 2, 2000);
pros::delay(250);
// Outtakes the pre-loaded alliance triball onto the other side of the field
AutonIntake(1000, true);
controller.print(1, 0, "Auton Completed");
break;
case 4:
// in progress in-depth auton
controller.print(0, 0, "Right Elims Auton");
// Sets the robot's current position relative to the middle point of the field
chassis.setPose(-48 - (7.0 / 2), -60, 135); // X, Y, Heading (degrees)
// Lowers the vertical wings, activating them
ToggleVerticalPneumaticWings();
// Drives forward to descore the match load triball
chassis.turnTo(0, -18, 2000);
// Lifts the vertical wings, deactivating them
ToggleVerticalPneumaticWings();
// Drives the robot towards the triball under the elevation bar
chassis.moveToPoint(-30, -18, 2000);
// Activates the intake
AutonIntake(1000,false);
// Drives the robot forward to intake the triball
chassis.moveToPoint(-30,-40,2000,false);
/*
pros::delay(500);
Expand All @@ -157,34 +182,48 @@ void autonomous() {
case 7:
// Currently curves the robot to push a triball into the goal
controller.print(0, 0, "Programming Skills - New Version");

// Sets the robot's current position relative to the middle point of the field
chassis.setPose(-72 + 26.5, -60, 133); // X, Y, Heading (degrees)
// Pushes the initially placed triballs into the close side goal
chassis.moveToPose(-60 + 5, -24 + 24, 180, 2500, {.forwards = false, .chasePower = 8});
// Delays the next command until the drivetrain is done moving
chassis.waitUntilDone();
// Re-sets the position coordinates of the robot to account for wheel slippage
chassis.setPose(-72 + 26.5, -29.25, 180); // X, Y, Heading (degrees)
// The robot drives backwards into loading position
chassis.moveToPose(-48, -48 + 3, 70, 2500, {.forwards = false, .chasePower = 8 + 6});
// Delays the next command until the drivetrain is done moving
chassis.waitUntilDone();
// Activates the vertical wings so that they are touching the match load bar
ToggleVerticalPneumaticWings();
// 0.5 second delay to allow the wings to fall
pros::delay(500);

// Activates the kicker
//KickerMotor.move(127);
// Allows the kicker to shoot for 25 seconds
//pros::delay(25000);
// Brakes the kicker
//KickerMotor.brake();
// 0.5 second delay to allow the kicker to stop moving
pros::delay(500);
// Deactivates the vertical wings
ToggleVerticalPneumaticWings();
// 0.5 second delay to allow the wings to rise
pros::delay(500);
// Turns the robot towards the bottom of the field
chassis.turnTo( -36, -60, 2500);
// Drives the robot towards the bottom of the field
chassis.moveToPoint(-36, -60, 2500);
// Turns the robot towards the elevation bar
chassis.turnTo(0,-60,2500);
// Drives towards the elevation bar
chassis.moveToPoint(24, -60, 2500);
//chassis.moveToPose(36,-36,0,2500);
// Delays the next command until the drivetrain is done moving
//chassis.waitUntilDone();
//ToggleVerticalPneumaticWings();
//chassis.moveToPose(60, -12, 90, 2500);

// chassis.moveToPose(-48 - 5, -48 + 8, 70, 2500, {.forwards = false, .chasePower = 8});
// TODO: Ishika, test line 192 (directly above) to see if it gets the bot closer to the match load position than line 191

controller.print(1, 0, "Skills Complete");
break;
case 8:
Expand Down
20 changes: 1 addition & 19 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,28 +36,10 @@ void initialize() {
KickerMotor.brake();
// Clears the controller screen
controller.clear();
// Resets the inertial sensor readings
// Inertial.reset();
// Calibrates the LemLib chassis (takes 3 seconds)
chassis.calibrate();
// pros::delay(3000);

/*
pros::Task screenTask([&]() {
lemlib::Pose pose(0, 0, 0);
while (true) {
// print robot location to the brain screen
pros::lcd::print(0, "X: %f", chassis.getPose().x); // x
pros::lcd::print(1, "Y: %f", chassis.getPose().y); // y
pros::lcd::print(2, "Theta: %f", chassis.getPose().theta); // heading
// log position telemetry
lemlib::telemetrySink()->info("Chassis pose: {}", chassis.getPose());
// delay to save resources
pros::delay(50);
}
});
*/

// Prints LemLib chassis position values to the computer terminal for debugging purposes
pros::Task terminalTask([&]() {
while (true) {
// print robot location to the brain screen
Expand Down
19 changes: 9 additions & 10 deletions src/opcontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,25 @@ void opcontrol()
LMotors.move(GetCurveOutput(-rightAxis));
}

// When LEFT is pressed, toggles the activation of the wings
// When R2 is pressed, the activation of the horizontal wings is toggled
if(controller.get_digital_new_press(pros::E_CONTROLLER_DIGITAL_R2))
ToggleHorizontalPneumaticWings();

// When R1 is pressed, the activation of the vertical wings is toggled
if(controller.get_digital_new_press(pros::E_CONTROLLER_DIGITAL_R1))
ToggleVerticalPneumaticWings();

// Allows L1 and L2 to move the intake forward and backwards respectively
// If L1 is behind held, the intake spins forward at maximum velocity
if(controller.get_digital(pros::E_CONTROLLER_DIGITAL_L1))
IntakeMotor.move(127);
// Otherwise, L2 is behind held, the intake spins bakcward at maximum velocity
else if(controller.get_digital(pros::E_CONTROLLER_DIGITAL_L2))
IntakeMotor.move(-127);
// If neither L1 nor L2 is behind held, the intake brakes
else
IntakeMotor.brake();

// When the if statement is manually set to true, the kicker code is used. When it is manually set to false, the elevation code is used.
if (true) {
// If the kicker is in manual control mode...
if(manualKicker) {
Expand All @@ -116,21 +120,16 @@ void opcontrol()
KickerMotor.brake();
}
} else {
// If UP is being held, the elevation mechanism spins forward, lifting the robot upwards
if(controller.get_digital(pros::E_CONTROLLER_DIGITAL_UP)) KickerMotor.move(127);
// Otherwise, if DOWN is being held, the elevation mechanism spins downward, allowing the robot to fall
else if(controller.get_digital(pros::E_CONTROLLER_DIGITAL_DOWN)) KickerMotor.move(-127);
// If neither UP nor DOWN are being held, the elevation mechanism brakes and holds its current position
else KickerMotor.brake();
}

count++;

if (count % 40 == 0) {
std::cout << "Hue: " << Optical.get_hue() << std::endl;
std::cout << "Saturation: " << Optical.get_saturation() << std::endl;
std::cout << "Brightness: " << Optical.get_brightness() << std::endl;
std::cout << "manualKicker: ";
std::cout << "-----------------------" << std::endl;
}

// Creates a 20 millisecond delay between each loop of the driver control code to prevent the starving of PROS kernel resources
pros::delay(20);
}
Expand Down

0 comments on commit 276aa16

Please sign in to comment.