1516X Push Back 1.0
1516X's robot code for the 2025-2026 VEX Robotics Competition
Loading...
Searching...
No Matches
main.cpp File Reference
#include "main.h"
#include "lemlib/api.hpp"
#include "lemlib/chassis/chassis.hpp"
#include "lemlib/chassis/trackingWheel.hpp"
#include "liblvgl/llemu.hpp"
#include "pros/misc.h"

Go to the source code of this file.

Functions

pros::Controller controller (CONTROLLER_MASTER)
 
pros::MotorGroup rightMotors ({-11, 2, 1})
 
pros::MotorGroup leftMotors ({-16, 14,-13})
 
pros::IMU imu (3)
 
pros::Rotation horizontal_tracking_sensor (12)
 
pros::Rotation vertical_tracking_sensor (15)
 
lemlib::ControllerSettings lateral_controller (10, 0, 3, 3, 1, 100, 3, 500, 20)
 
lemlib::ControllerSettings angular_controller (2, 0, 10, 3, 1, 100, 3, 500, 0)
 
lemlib::Chassis chassis (drivetrain, lateral_controller, angular_controller, sensors)
 
void initialize ()
 
void disabled ()
 
void competition_initialize ()
 
void autonomous ()
 
void opcontrol ()
 

Variables

lemlib::Drivetrain drivetrain & leftMotors
 
lemlib::TrackingWheel horizontal_tracking_wheel & horizontal_tracking_sensor
 
lemlib::TrackingWheel vertical_tracking_wheelvertical_tracking_sensor
 
lemlib::OdomSensors sensors & vertical_tracking_wheel
 

Function Documentation

◆ angular_controller()

lemlib::ControllerSettings angular_controller ( 2 ,
0 ,
10 ,
3 ,
1 ,
100 ,
3 ,
500 ,
0  )

Referenced by chassis().

◆ autonomous()

void autonomous ( )

Runs the user autonomous code. This function will be started in its own task with the default priority and stack size whenever the robot is enabled via the Field Management System or the VEX Competition Switch in the autonomous mode. Alternatively, this function may be called in initialize or opcontrol for non-competition testing purposes.

If the robot is disabled or communications is lost, the autonomous task will be stopped. Re-enabling the robot will restart the task, not re-start it from where it left off.

Definition at line 104 of file main.cpp.

104{}

◆ chassis()

lemlib::Chassis chassis ( drivetrain ,
lateral_controller ,
angular_controller ,
sensors  )

References angular_controller(), and lateral_controller().

Referenced by initialize(), and opcontrol().

◆ competition_initialize()

void competition_initialize ( )

Runs after initialize(), and before autonomous when connected to the Field Management System or the VEX Competition Switch. This is intended for competition-specific initialization routines, such as an autonomous selector on the LCD.

This task will exit when the robot is enabled and autonomous or opcontrol starts.

Definition at line 91 of file main.cpp.

91{}

◆ controller()

pros::Controller controller ( CONTROLLER_MASTER )

Referenced by opcontrol().

◆ disabled()

void disabled ( )

Runs while the robot is in the disabled state of Field Management System or the VEX Competition Switch, following either autonomous or opcontrol. When the robot is enabled, this task will exit.

Definition at line 80 of file main.cpp.

80{}

◆ horizontal_tracking_sensor()

pros::Rotation horizontal_tracking_sensor ( 12 )

◆ imu()

pros::IMU imu ( 3 )

◆ initialize()

void initialize ( )

Runs initialization code. This occurs as soon as the program is started.

All other competition modes are blocked by initialize; it is recommended to keep execution time for this mode under a few seconds.

Definition at line 58 of file main.cpp.

58 {
59 pros::lcd::initialize(); // initialize brain screen
60 chassis.calibrate(); // calibrate sensors
61 // print position to brain screen
62 pros::Task screen_task([&]() {
63 while (true) {
64 // print robot location to the brain screen
65 pros::lcd::print(0, "X: %f", chassis.getPose().x); // x
66 pros::lcd::print(1, "Y: %f", chassis.getPose().y); // y
67 pros::lcd::print(2, "Theta: %f", chassis.getPose().theta); // heading
68 // delay to save resources
69 pros::delay(20);
70 }
71 });
72}
lemlib::Chassis chassis(drivetrain, lateral_controller, angular_controller, sensors)

References chassis().

◆ lateral_controller()

lemlib::ControllerSettings lateral_controller ( 10 ,
0 ,
3 ,
3 ,
1 ,
100 ,
3 ,
500 ,
20  )

Referenced by chassis().

◆ leftMotors()

pros::MotorGroup leftMotors ( {-16, 14,-13} )

◆ opcontrol()

void opcontrol ( )

Runs the operator control code. This function will be started in its own task with the default priority and stack size whenever the robot is enabled via the Field Management System or the VEX Competition Switch in the operator control mode.

If no competition control is connected, this function will run immediately following initialize().

If the robot is disabled or communications is lost, the operator control task will be stopped. Re-enabling the robot will restart the task, not resume it from where it left off.

Definition at line 122 of file main.cpp.

122 {
123 while (true)
124 {
125 int rightControl = controller.get_analog(pros::E_CONTROLLER_ANALOG_RIGHT_Y);
126 int leftControl = controller.get_analog(pros::E_CONTROLLER_ANALOG_LEFT_Y);
127
128 chassis.tank(leftControl, rightControl, false);
129
130 pros::delay(20);
131 }
132}
pros::Controller controller(CONTROLLER_MASTER)

References chassis(), and controller().

◆ rightMotors()

pros::MotorGroup rightMotors ( {-11, 2, 1} )

◆ vertical_tracking_sensor()

pros::Rotation vertical_tracking_sensor ( 15 )

Variable Documentation

◆ horizontal_tracking_sensor

lemlib::TrackingWheel horizontal_tracking_wheel& horizontal_tracking_sensor

Definition at line 21 of file main.cpp.

◆ leftMotors

lemlib::Drivetrain drivetrain& leftMotors

Definition at line 14 of file main.cpp.

◆ vertical_tracking_sensor

lemlib::TrackingWheel vertical_tracking_wheel& vertical_tracking_sensor

Definition at line 22 of file main.cpp.

◆ vertical_tracking_wheel

lemlib::OdomSensors sensors& vertical_tracking_wheel

Definition at line 23 of file main.cpp.