1516b Over Under 2.0
Codebase for 1516b over under season
Loading...
Searching...
No Matches
main.h File Reference
#include "api.h"
#include "robot/auton.h"
#include "globals.h"
#include "robot/drivetrain.h"
#include "robot/puncher.h"
#include "robot/intake.h"
#include "robot/utility.h"

Go to the source code of this file.

Macros

#define PROS_USE_SIMPLE_NAMES
 
#define PROS_USE_LITERALS
 

Functions

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

Detailed Description

Contains common definitions and header files used throughout your PROS project.

This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.

Definition in file main.h.

Macro Definition Documentation

◆ PROS_USE_LITERALS

#define PROS_USE_LITERALS

If defined, C++ literals will be available for use. All literals are in the pros::literals namespace.

For instance, you can do 4_mtr = 50 to set motor 4's target velocity to 50

Definition at line 35 of file main.h.

◆ PROS_USE_SIMPLE_NAMES

#define PROS_USE_SIMPLE_NAMES

If defined, some commonly used enums will have preprocessor macros which give a shorter, more convenient naming pattern. If this isn't desired, simply comment the following line out.

For instance, E_CONTROLLER_MASTER has a shorter name: CONTROLLER_MASTER. E_CONTROLLER_MASTER is pedantically correct within the PROS styleguide, but not convenient for most student programmers.

Definition at line 27 of file main.h.

Function Documentation

◆ autonomous()

void autonomous ( void )

You should add more #includes here If you find doing pros::Motor() to be tedious and you'd prefer just to do Motor, you can use the namespace with the following commented out line.

IMPORTANT: Only the okapi or pros namespace may be used, not both concurrently! The okapi namespace will export all symbols inside the pros namespace. Prototypes for the competition control tasks are redefined here to ensure that they can be called from user code (i.e. calling autonomous from a button press in opcontrol() for testing purposes).

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.