1516X Push Back 1.0
1516X's robot code for the 2025-2026 VEX Robotics Competition
Loading...
Searching...
No Matches
main.cpp
Go to the documentation of this file.
1#include "main.h"
2#include "globals.h"
3#include "pros/misc.h"
4#include "autonRoutines.h"
5#include "lemlib/api.hpp"
6#include "lemlib/util.hpp"
7
8
9
10void auton2()
11{
12 chassis.turnToHeading(90, 1000);
13}
14
15void auton3()
16{
17 chassis.moveToPoint(0, -12, 1000);
18}
19
20
21rd::Selector selector({
22 {"Red Right", red_right},
23 {"Test auton 2", auton2},
24 {"Test auton 3", auton3},
25});
26
27rd::Console console;
28
29// Global Objects
30void initialize() {
31 chassis.calibrate();
32 agitator.set_voltage_limit(6500);
33 pros::Task screen_task([&]() {
34 while (true) {
35 lemlib::Pose pose = chassis.getPose();
36 console.printf("X: %f\n", pose.x);
37 console.printf("Y: %f\n", pose.y);
38 console.printf("Theta: %f\n", pose.theta);
39 pros::delay(20);
40 }
41 });
42}
43
44void disabled() {
45 selector.focus();
46}
47
49
50}
51
52void autonomous() {
53 selector.run_auton();
54}
55
56void opcontrol() {
57 while(true)
58 {
59 double y = controller.get_analog(pros::E_CONTROLLER_ANALOG_LEFT_Y);
60 double x = controller.get_analog(pros::E_CONTROLLER_ANALOG_RIGHT_X);
61 chassis.curvature(y, x, false);
62
63 /*
64 double right = controller.get_analog(pros::E_CONTROLLER_ANALOG_RIGHT_Y);
65 double left = controller.get_analog(pros::E_CONTROLLER_ANALOG_LEFT_Y);
66 chassis.tank(left, right, false);
67 */
68
69 //R1 - outake long goal
70 if(controller.get_digital(pros::E_CONTROLLER_DIGITAL_R1))
71 {
72 midMotor.move_voltage(-12000);
73 agitator.move_voltage(-6500);
74 intakeMotor.move_voltage(12000);
75
76 }
77 else if(controller.get_digital(pros::E_CONTROLLER_DIGITAL_R2))
78 {
79 //R2 - Bottom goal
80 midMotor.move_voltage(12000);
81 agitator.move_voltage(-6500);
82 intakeMotor.move_voltage(-12000);
83
84 }
85 else if(controller.get_digital(pros::E_CONTROLLER_DIGITAL_L1))
86 {
87 //Intake
88 if(midRollerHeight.is_extended())
89 {
90 midRollerHeight.retract();
91 }
92 agitator.brake();
93 intakeMotor.move_voltage(12000);
94 topRoller.retract();
95 midMotor.move_voltage(-12000);
96
97 }
98 else if(controller.get_digital(pros::E_CONTROLLER_DIGITAL_L2))
99 {
100 agitator.move_voltage(-6500);
101 intakeMotor.move_voltage(12000);
102 midMotor.move_voltage(12000);
103 }
104 else if (controller.get_digital_new_press(pros::E_CONTROLLER_DIGITAL_LEFT))
105 {
106 aligner.toggle();
107 }
108 else if (controller.get_digital_new_press(pros::E_CONTROLLER_DIGITAL_RIGHT))
109 {
110 matchload_mech.toggle();
111 }
112 else if (controller.get_digital_new_press(pros::E_CONTROLLER_DIGITAL_X))
113 {
114 topRoller.toggle();
115 }
116 else {
117 intakeMotor.brake();
118 agitator.brake();
119 midMotor.brake();
120 if(!midRollerHeight.is_extended())
121 {
122 midRollerHeight.extend();
123 }
124 }
125 pros::delay(20);
126 }
127}
128
129//Deactivated: Long goal
130//Extended: Score top goal
131//Deactivate top roller for storage
132//Activate storage to extend
133
134//R1 - outake long goal
135//R2 - Bottom goal
136//L1 - Intake into hopper
137//l2 - outtake onto mid goal
void red_right()
pros::Motor midMotor(20)
pros::Motor intakeMotor(6)
pros::adi::Pneumatics topRoller('B', false)
pros::adi::Pneumatics matchload_mech('D', false)
pros::Motor agitator(16, pros::v5::MotorGears::green)
pros::adi::Pneumatics aligner('C', true)
pros::adi::Pneumatics midRollerHeight('A', true)
lemlib::Chassis chassis
pros::Controller controller
void initialize()
Definition main.cpp:30
void autonomous()
Definition main.cpp:52
rd::Selector selector({ {"Red Right", red_right}, {"Test auton 2", auton2}, {"Test auton 3", auton3}, })
void disabled()
Definition main.cpp:44
void auton3()
Definition main.cpp:15
void competition_initialize()
Definition main.cpp:48
void opcontrol()
Definition main.cpp:56
rd::Console console
Definition main.cpp:27
void auton2()
Definition main.cpp:10