1516b Over Under 2.0
Codebase for 1516b over under season
|
Represents the drivetrain of the robot. More...
#include <drivetrain.h>
Public Member Functions | |
void | run () |
Runs the drivetrain. | |
void | setdeadzone (int newDeadZone) |
Sets the joystick deadzone. | |
int | getdeadzone () |
Returns the current deadzone value. | |
void | SwitchDrive () |
Switches the DriveTrain mode between arcade and tank drive. | |
Drivetrain () | |
Initializes the Drivetrain object. | |
Public Attributes | |
int | driveMode |
The current drive train mode, between arcade (0) and tank (1). | |
Private Member Functions | |
void | ArcadeDrive () |
Drives the robot using arcade drive. | |
void | TankDrive () |
Drives the robot using tank drive. | |
int | CheckDeadzone (int entry) |
Checks if the controller input is inside the deadzone range. | |
Private Attributes | |
int | deadzone |
The deadzone value for the joystick. | |
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 deadzone value for the joystick. The deadzone is a range around the joystick's resting position where no movement is registered. By adjusting the deadzone value, the sensitivity of the joystick inputs can be fine-tuned.
Definition at line 23 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 38 of file drivetrain.cpp.
References 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 17 of file drivetrain.cpp.
References CheckDeadzone(), Robot::Globals::controller, deadzone, Robot::Globals::drive_left, and Robot::Globals::drive_right.
Referenced by run().
|
private |
Checks if the controller input is inside the deadzone range.
entry | The controller input to check. |
Definition at line 8 of file drivetrain.cpp.
References deadzone.
Referenced by ArcadeDrive(), and TankDrive().
int Robot::Drivetrain::getdeadzone | ( | ) |
Returns the current deadzone value.
The deadzone is a range around the joystick's resting position where no movement is registered. This function returns the current deadzone value that is being used by the drivetrain.
The deadzone value can be used to fine-tune the drivetrain's responsiveness to joystick inputs. By retrieving the current deadzone value, you can adjust other parts of your code to take it into account.
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 67 of file drivetrain.cpp.
References ArcadeDrive(), driveMode, and TankDrive().
Referenced by opcontrol().
void Robot::Drivetrain::setdeadzone | ( | int | newDeadZone | ) |
Sets the joystick deadzone.
newDeadZone | The new deadzone value. |
The deadzone is a range around the joystick's resting position where no movement is registered. This function allows you to set the deadzone value to filter out small joystick movements.
The deadzone value determines the sensitivity of the joystick inputs. A higher deadzone value will require larger joystick movements to register any movement in the drivetrain. Conversely, a lower deadzone value will make the drivetrain more responsive to small joystick movements.
void Drivetrain::SwitchDrive | ( | ) |
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 78 of file drivetrain.cpp.
References Robot::Globals::controller, and driveMode.
Referenced by Robot::Utility::toggleSubsystemOptions().
|
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 42 of file drivetrain.cpp.
References CheckDeadzone(), Robot::Globals::controller, deadzone, Robot::Globals::drive_left, and Robot::Globals::drive_right.
Referenced by run().
|
private |
The deadzone value for the joystick.
Definition at line 104 of file drivetrain.h.
Referenced by ArcadeDrive(), CheckDeadzone(), and TankDrive().
int Robot::Drivetrain::driveMode |
The current drive train mode, between arcade (0) and tank (1).
Definition at line 72 of file drivetrain.h.
Referenced by Drivetrain(), run(), and SwitchDrive().