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 Public Attributes | |
static DRIVE_MODE | driveMode = CURVATURE_DRIVE |
Active drive control scheme. | |
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 27 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 43 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 10 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 25 of file drivetrain.cpp.
References Robot::Globals::chassis(), and Robot::Globals::controller().
Referenced by run().
|
private |
Drives the robot using curvature drive.
Curvature drive applies curvature to turns and a negative inertia accumulator.
Definition at line 15 of file drivetrain.cpp.
References Robot::Globals::chassis(), and Robot::Globals::controller().
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 48 of file drivetrain.cpp.
References ARCADE_DRIVE, ArcadeDrive(), CURVATURE_DRIVE, CurvatureDrive(), driveMode, TANK_DRIVE, and TankDrive().
Referenced by opcontrol().
|
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 71 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 36 of file drivetrain.cpp.
References Robot::Globals::chassis(), and Robot::Globals::controller().
Referenced by run().
|
static |
Cycles through each drivetrain control mode.
Definition at line 64 of file drivetrain.cpp.
References driveMode, SwitchDrive(), and TANK_DRIVE.
Referenced by opcontrol().
|
static |
Active drive control scheme.
Definition at line 48 of file drivetrain.h.
Referenced by Drivetrain(), run(), SwitchDrive(), and toggleDrive().