1516X High Stakes 2.0
Codebase for 1516X High Stakes season
Loading...
Searching...
No Matches
main.cpp File Reference

This file contains the main code for the robot's operation. More...

#include "main.h"
#include "pros/apix.h"

Go to the source code of this file.

Classes

struct  RobotSubsystems
 Structure that holds instances of all robot subsystems. More...
 
struct  RobotScreen
 

Functions

void initialize ()
 
void disabled ()
 
void competition_initialize ()
 
void autonomous ()
 
void opcontrol ()
 

Variables

struct RobotSubsystems subsystem
 
struct RobotScreen screen
 

Detailed Description

This file contains the main code for the robot's operation.

Definition in file main.cpp.

Function Documentation

◆ autonomous()

void autonomous ( )

6 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 83 of file main.cpp.

83 {
85}
void AutoDrive(Intake &intake, Latch &latch)
Drives the robot autonomously.
Definition auton.cpp:108
struct RobotSubsystems subsystem
Robot::Intake intake
Definition main.cpp:28
Robot::Autonomous autonomous
Definition main.cpp:26
Robot::Latch latch
Definition main.cpp:29

References Robot::Autonomous::AutoDrive(), RobotSubsystems::autonomous, RobotSubsystems::intake, RobotSubsystems::latch, and subsystem.

Referenced by 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.<asd></asd>

Definition at line 70 of file main.cpp.

70{}

◆ 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 59 of file main.cpp.

59{}

◆ 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 44 of file main.cpp.

44 {
45 if (pros::c::registry_get_plugged_type(15) == pros::c::E_DEVICE_IMU) {
46 chassis.calibrate();
47 }
48 chassis.setPose(0, 0, 0);
49
50 screen.selector.selector();
51}
struct RobotScreen screen
lemlib::Chassis chassis(drivetrain, lateral_controller, angular_controller, sensors, &throttle_curve, &steer_curve)
Robot::selector_screen selector
Definition main.cpp:33

References Robot::Globals::chassis(), screen, and RobotScreen::selector.

◆ 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 100 of file main.cpp.

100 {
101 while (true) {
102 if (controller.get_digital_new_press(pros::E_CONTROLLER_DIGITAL_DOWN)) {
103 autonomous();
104 }
105 if (controller.get_digital_new_press(pros::E_CONTROLLER_DIGITAL_LEFT)) {
106 std::string name = subsystem.drivetrain.toggleDrive();
107 // Output the current drive mode to the controller screen
108 controller.print(0, 0, name.c_str());
109 }
110
113
114 // Intake controller, uses the X button holded down to push the elevation
115 // up.
117 // Intake controller, moves the left and right intakes and stops them if
118 // nothing is pressed.
119
120 pros::delay(10); // Small delay to reduce CPU usage
121 }
122}
static std::string toggleDrive()
Cycles through each drivetrain control mode.
void run()
Runs the drivetrain.
void run()
Runs the main function of the intake system.
Definition intake.cpp:15
void run()
Runs latching mechanism.
Definition latch.cpp:8
void autonomous()
Definition main.cpp:83
pros::Controller controller(pros::E_CONTROLLER_MASTER)
Robot::Drivetrain drivetrain
Definition main.cpp:27

References autonomous(), Robot::Globals::controller(), RobotSubsystems::drivetrain, RobotSubsystems::intake, RobotSubsystems::latch, Robot::Drivetrain::run(), Robot::Intake::run(), Robot::Latch::run(), subsystem, and Robot::Drivetrain::toggleDrive().

Variable Documentation

◆ screen

struct RobotScreen screen

Referenced by initialize().

◆ subsystem

struct RobotSubsystems subsystem

Referenced by autonomous(), and opcontrol().