1516X High Stakes 2.0
Codebase for 1516X High Stakes season
Loading...
Searching...
No Matches
drivetrain.cpp
Go to the documentation of this file.
1#include "robot/drivetrain.h"
2
3#include "globals.h"
4
5using namespace Robot;
6using namespace Robot::Globals;
7
9
14
16{
17 int left = controller.get_analog(pros::E_CONTROLLER_ANALOG_LEFT_Y);
18 int right = controller.get_analog(pros::E_CONTROLLER_ANALOG_RIGHT_X);
19
20 chassis.curvature(left, right);
21
22 pros::delay(15);
23}
24
26{
27 // Arcade Measurements
28 int left = controller.get_analog(pros::E_CONTROLLER_ANALOG_LEFT_Y);
29 int right = controller.get_analog(pros::E_CONTROLLER_ANALOG_RIGHT_X);
30
31 chassis.arcade(left, right, false, 0.6);
32
33 pros::delay(15);
34}
35
37{
38 int left = controller.get_analog(pros::E_CONTROLLER_ANALOG_LEFT_Y);
39 int right = controller.get_analog(pros::E_CONTROLLER_ANALOG_RIGHT_Y);
40
41 chassis.tank(left, right);
42
43 pros::delay(15);
44}
45
46
47// Run the drivetrain depending on the control mode
49{
50 switch (Drivetrain::driveMode) {
51 case CURVATURE_DRIVE:
53 break;
54 case ARCADE_DRIVE:
56 break;
57 case TANK_DRIVE:
59 break;
60 }
61}
62
63// Cycle through each drivetrain control mode, overflows back to 0
65{
66 int driveMode = (Drivetrain::driveMode + 1) % (TANK_DRIVE + 1);
67 return SwitchDrive(driveMode);
68}
69
70// Switch the drivetrain control mode between arcade and tank drive with the down button(between 1 and 2)
71std::string Drivetrain::SwitchDrive(int driveMode)
72{
73 switch (driveMode) {
74 case 0:
76 std::cout << "Curvature Drive" << std::endl;
77 return "Curvature Drive";
78 case 1:
80 std::cout << "Arcade Drive" << std::endl;
81 return "Arcade Drive";
82 case 2:
84 std::cout << "Tank Drive" << std::endl;
85 return "Tank Drive";
86 default:
87 std::cout << "Not a valid drivetrain control mode!" << std::endl;
88 return "Not a valid driveMode!";
89 }
90}
static std::string toggleDrive()
Cycles through each drivetrain control mode.
void run()
Runs the drivetrain.
static std::string SwitchDrive(int driveMode)
Switches the DriveTrain mode between arcade and tank drive.
DRIVE_MODE
Drive control schemes.
Definition drivetrain.h:43
void ArcadeDrive()
Drives the robot using arcade drive.
static DRIVE_MODE driveMode
Active drive control scheme.
Definition drivetrain.h:48
Drivetrain()
Initializes the Drivetrain object.
void CurvatureDrive()
Drives the robot using curvature drive.
void TankDrive()
Drives the robot using tank drive.
Contains the declaration of the Drivetrain class.
lemlib::Chassis chassis(drivetrain, lateral_controller, angular_controller, sensors, &throttle_curve, &steer_curve)
pros::Controller controller(pros::E_CONTROLLER_MASTER)
Definition auton.h:8