1516X High Stakes 2.0
Codebase for 1516X High Stakes season
|
Represents the drivetrain of the robot. More...
#include <drivetrain.h>
Public Types | |
enum | DRIVE_MODE { CURVATURE_DRIVE = 0 , ARCADE_DRIVE = 1 , TANK_DRIVE = 2 } |
Drive control schemes. More... | |
Public Member Functions | |
Drivetrain () | |
Initializes the Drivetrain object. | |
void | run () |
Runs the drivetrain. | |
Static Public Member Functions | |
static std::string | SwitchDrive (int driveMode) |
Switches the DriveTrain mode between arcade and tank drive. | |
static std::string | toggleDrive () |
Cycles through each drivetrain control mode. | |
static int | thrustHandler (int thrust) |
Toggles the orientation of the drivetrain. | |
Static Public Attributes | |
static DRIVE_MODE | driveMode = CURVATURE_DRIVE |
Active drive control scheme. | |
static bool | isReversed = false |
Private Member Functions | |
void | ArcadeDrive () |
Drives the robot using arcade drive. | |
void | CurvatureDrive () |
Drives the robot using curvature drive. | |
void | TankDrive () |
Drives the robot using tank drive. | |
Represents the drivetrain of the robot.
The Drivetrain class is responsible for controlling the movement of the robot's drivetrain. It provides functions to interpret joystick inputs and convert them into appropriate drivetrain movements. The drivetrain can be controlled using different drive modes, such as tank drive or arcade drive.
The Drivetrain class also allows setting and retrieving the dead zone value for the joystick. The dead zone is a range around the joystick's resting position where no movement is registered. By adjusting the dead zone value, the sensitivity of the joystick inputs can be fine-tuned.
Definition at line 26 of file drivetrain.h.
Drive control schemes.
Data type representing all possible driving control schemes that can be used on the robot. Multiple drive modes can be used during runtime without recompilation.
Enumerator | |
---|---|
CURVATURE_DRIVE | |
ARCADE_DRIVE | |
TANK_DRIVE |
Definition at line 42 of file drivetrain.h.
Drivetrain::Drivetrain | ( | ) |
Initializes the Drivetrain object.
This constructor is responsible for initializing the Drivetrain object and setting default values.
Definition at line 12 of file drivetrain.cpp.
References CURVATURE_DRIVE, and driveMode.
|
private |
Drives the robot using arcade drive.
Arcade drive uses the left joystick for forward and backward movement, and the right joystick for left and right movement.
Definition at line 23 of file drivetrain.cpp.
References Robot::Globals::chassis(), Robot::Globals::controller(), DEFAULT_DELAY_LENGTH, and thrustHandler().
Referenced by run().
|
private |
Drives the robot using curvature drive.
Curvature drive applies curvature to turns and a negative inertia accumulator.
Definition at line 14 of file drivetrain.cpp.
References Robot::Globals::chassis(), Robot::Globals::controller(), DEFAULT_DELAY_LENGTH, and thrustHandler().
Referenced by run().
void Drivetrain::run | ( | ) |
Runs the drivetrain.
This function is responsible for controlling the movement of the robot's drivetrain. It executes the necessary actions to make the robot move according to the current drive mode.
The drivetrain can be controlled using different drive modes, such as tank drive or arcade drive. This function implements the logic to interpret the joystick inputs and convert them into appropriate drivetrain movements.
Definition at line 43 of file drivetrain.cpp.
References ARCADE_DRIVE, ArcadeDrive(), CURVATURE_DRIVE, CurvatureDrive(), driveMode, TANK_DRIVE, and TankDrive().
|
static |
Switches the DriveTrain mode between arcade and tank drive.
The drive mode determines how the drivetrain interprets the joystick inputs. Arcade drive uses the left joystick for forward and backward movement, and the right joystick for left and right movement. Tank drive uses the left and right joysticks for controlling the left and right sides of the robot.
Definition at line 72 of file drivetrain.cpp.
References ARCADE_DRIVE, CURVATURE_DRIVE, driveMode, and TANK_DRIVE.
Referenced by toggleDrive().
|
private |
Drives the robot using tank drive.
Tank drive uses the left and right joysticks for controlling the left and right sides of the robot.
Definition at line 33 of file drivetrain.cpp.
References Robot::Globals::chassis(), Robot::Globals::controller(), DEFAULT_DELAY_LENGTH, and thrustHandler().
Referenced by run().
|
static |
Toggles the orientation of the drivetrain.
Definition at line 63 of file drivetrain.cpp.
References isReversed.
Referenced by ArcadeDrive(), CurvatureDrive(), and TankDrive().
|
static |
Cycles through each drivetrain control mode.
Definition at line 58 of file drivetrain.cpp.
References driveMode, SwitchDrive(), and TANK_DRIVE.
|
static |
Active drive control scheme.
Definition at line 47 of file drivetrain.h.
Referenced by Drivetrain(), run(), SwitchDrive(), and toggleDrive().
|
static |
Definition at line 82 of file drivetrain.h.
Referenced by opcontrol(), and thrustHandler().