1516b Over Under 2.0
Codebase for 1516b over under 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 <ostream>
#include "api.h"
#include "pros/apix.h"
#include "pros/serial.h"

Go to the source code of this file.

Classes

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

Namespaces

namespace  Robot
 Contains all objects generated by the 1516B team - Contains all of the subsystems, methods, and global objects.
 

Functions

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

Variables

struct Robot::RobotSubsystems Robot::subsystem
 

Detailed Description

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

Definition in file main.cpp.

Function Documentation

◆ autonomous()

void autonomous ( void )

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

121 {
122
124
125
126
127}
void AutoDrive(Puncher &puncher, bool autono)
Drives the robot autonomously.
Definition auton.cpp:60
struct Robot::RobotSubsystems subsystem
Robot::Puncher puncher
Definition main.cpp:35
Robot::Autonomous autonomous
Definition main.cpp:32

References Robot::Autonomous::AutoDrive(), Robot::RobotSubsystems::autonomous, and Robot::RobotSubsystems::puncher.

◆ competition_initialize()

void competition_initialize ( void )

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

95 {
96 // Allows the user to select the autonomous routine, drive control type as well as whether the distance puncher is enabled.
97 // The user can select the auton routine by pressing the right buttons on the controller.
98 // The user can select the drive control type by pressing the down button on the controller.
99 // The user can select the distance puncher by pressing the left button on the controller.
100 // The state of each subsystem is displayed on the controller screen.
101
102
103}

◆ disabled()

void disabled ( void )

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

84{}

◆ initialize()

void initialize ( void )

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

59 {
60
61 pros::lcd::initialize();
62 pros::Task toggler(toggles);
63
64 if (pros::c::registry_get_plugged_type(13) == pros::c::E_DEVICE_IMU) {
65 chassis.calibrate();
66 chassis.setPose(0, 0, 90); // X: 0, Y: 0, Heading: 0
67 // Setting an example start location for the robot so it is all relatativistic
68 pros::Task screenTask(Robot::Utility::displayLocation);
69 }
70 else {
71 pros::Task screenTask(Robot::Utility::displayMotorVel);
72 }
73
74}
void toggles()
Definition main.cpp:48
lemlib::Chassis chassis
void displayLocation()
Displays current position of the robot.
Definition utility.cpp:42
void displayMotorVel()
Displays current velocity of the robot.
Definition utility.cpp:28

References Robot::Globals::chassis, Robot::Utility::displayLocation(), Robot::Utility::displayMotorVel(), and toggles().

◆ opcontrol()

void opcontrol ( void )

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

144 {
145
146
147 while (true) {
149
150
151
153
154
155
156
157 // Catapult controller, uses the X button holded down to push the elevation up.
159
160 // Intake controller, moves the left and right intakes and stops them if nothing is pressed.
161
162
164
165
166
167
168
169
170
171
172 pros::delay(2); // Small delay to reduce CPU usage
173 }
174
175
176}
void run()
Runs the drivetrain.
void run()
Runs the main function of the intake system.
Definition intake.cpp:7
void run(int autonVal)
Runs the puncher based on the given autonomous value.
Definition puncher.cpp:15
void run()
Runs the wings.
Definition wings.cpp:7
Robot::Drivetrain drivetrain
Definition main.cpp:33
Robot::Wings wings
Definition main.cpp:34
Robot::Intake intake
Definition main.cpp:36

References Robot::RobotSubsystems::drivetrain, Robot::RobotSubsystems::intake, Robot::RobotSubsystems::puncher, Robot::Drivetrain::run(), Robot::Intake::run(), Robot::Wings::run(), Robot::Puncher::run(), and Robot::RobotSubsystems::wings.

◆ toggles()

void toggles ( )

A callback function for LLEMU's center button.

When this callback is fired, it will toggle line 2 of the LCD text between "I was pressed!" and nothing.

Definition at line 48 of file main.cpp.

48 {
50}
void toggleSubsystemOptions(Autonomous &auton, Drivetrain &drive, Puncher &punch)
Toggles subsystems, drive mode auton routine, and puncher.
Definition utility.cpp:10

References Robot::RobotSubsystems::autonomous, Robot::RobotSubsystems::drivetrain, Robot::RobotSubsystems::puncher, and Robot::Utility::toggleSubsystemOptions().

Referenced by initialize().