1516b Over Under 2.0
Codebase for 1516b over under season
Loading...
Searching...
No Matches
drivetrain.h
Go to the documentation of this file.
1// Header guard - Ensures that the header file will not get double imported.
2#pragma once
3
4/**
5 * @file drivetrain.h
6 * @brief Contains the declaration of the Drivetrain class.
7 */
8
9namespace Robot {
10
11 /**
12 * @class Drivetrain
13 * @brief Represents the drivetrain of the robot.
14 *
15 * The Drivetrain class is responsible for controlling the movement of the robot's drivetrain.
16 * It provides functions to interpret joystick inputs and convert them into appropriate drivetrain movements.
17 * The drivetrain can be controlled using different drive modes, such as tank drive or arcade drive.
18 *
19 * The Drivetrain class also allows setting and retrieving the deadzone value for the joystick.
20 * The deadzone is a range around the joystick's resting position where no movement is registered.
21 * By adjusting the deadzone value, the sensitivity of the joystick inputs can be fine-tuned.
22 */
23 class Drivetrain {
24 public:
25 /**
26 * @brief Runs the drivetrain.
27 *
28 * This function is responsible for controlling the movement of the robot's drivetrain.
29 * It executes the necessary actions to make the robot move according to the current drive mode.
30 *
31 * @details The drivetrain can be controlled using different drive modes, such as tank drive or arcade drive.
32 * This function implements the logic to interpret the joystick inputs and convert them into appropriate drivetrain movements.
33 */
34 void run();
35
36 /**
37 * @brief Sets the joystick deadzone.
38 *
39 * @param newDeadZone The new deadzone value.
40 *
41 * The deadzone is a range around the joystick's resting position where no movement is registered.
42 * This function allows you to set the deadzone value to filter out small joystick movements.
43 *
44 * @details The deadzone value determines the sensitivity of the joystick inputs.
45 * A higher deadzone value will require larger joystick movements to register any movement in the drivetrain.
46 * Conversely, a lower deadzone value will make the drivetrain more responsive to small joystick movements.
47 */
48 void setdeadzone(int newDeadZone);
49
50 /**
51 * @brief Returns the current deadzone value.
52 *
53 * @return The deadzone value.
54 *
55 * The deadzone is a range around the joystick's resting position where no movement is registered.
56 * This function returns the current deadzone value that is being used by the drivetrain.
57 *
58 * @details The deadzone value can be used to fine-tune the drivetrain's responsiveness to joystick inputs.
59 * By retrieving the current deadzone value, you can adjust other parts of your code to take it into account.
60 */
62
63 /**
64 * @brief Switches the DriveTrain mode between arcade and tank drive.
65 *
66 * The drive mode determines how the drivetrain interprets the joystick inputs.
67 * Arcade drive uses the left joystick for forward and backward movement, and the right joystick for left and right movement.
68 * Tank drive uses the left and right joysticks for controlling the left and right sides of the robot.
69 */
70 void SwitchDrive();
71
72 int driveMode; ///< The current drive train mode, between arcade (0) and tank (1).
73
74 /**
75 * @brief Initializes the Drivetrain object.
76 *
77 * This constructor is responsible for initializing the Drivetrain object and setting default values.
78 */
79 Drivetrain();
80
81 private:
82 /**
83 * @brief Drives the robot using arcade drive.
84 *
85 * Arcade drive uses the left joystick for forward and backward movement, and the right joystick for left and right movement.
86 */
87 void ArcadeDrive();
88
89 /**
90 * @brief Drives the robot using tank drive.
91 *
92 * Tank drive uses the left and right joysticks for controlling the left and right sides of the robot.
93 */
94 void TankDrive();
95
96 /**
97 * @brief Checks if the controller input is inside the deadzone range.
98 *
99 * @param entry The controller input to check.
100 * @return The input value if it is outside the deadzone range, otherwise 0.
101 */
102 int CheckDeadzone(int entry);
103
104 int deadzone; ///< The deadzone value for the joystick.
105 };
106}
The Autonomous class contains classes and functions related to the robot's autonomous behavior.
Definition auton.h:11
void AutoDrive(Puncher &puncher, bool autono)
Drives the robot autonomously.
Definition auton.cpp:60
void Auton1()
Runs the autonomous path for the far side defensive game strategy.
Definition auton.cpp:11
static int auton
Sets the number of the autonomous program to use.
Definition auton.h:22
void Auton2()
Runs the autonomous path for the near side offensive game strategy.
Definition auton.cpp:31
void AutonSwitcher()
Switches the autonomous program.
Definition auton.cpp:82
void Auton3(Puncher &puncher)
Runs the puncher routine for the Skills Challenge.
Definition auton.cpp:51
Represents the drivetrain of the robot.
Definition drivetrain.h:23
int getdeadzone()
Returns the current deadzone value.
void run()
Runs the drivetrain.
int driveMode
The current drive train mode, between arcade (0) and tank (1).
Definition drivetrain.h:72
void SwitchDrive()
Switches the DriveTrain mode between arcade and tank drive.
void ArcadeDrive()
Drives the robot using arcade drive.
int CheckDeadzone(int entry)
Checks if the controller input is inside the deadzone range.
Definition drivetrain.cpp:8
int deadzone
The deadzone value for the joystick.
Definition drivetrain.h:104
Drivetrain()
Initializes the Drivetrain object.
void setdeadzone(int newDeadZone)
Sets the joystick deadzone.
void TankDrive()
Drives the robot using tank drive.
Represents a Puncher mechanism for a robot.
Definition puncher.h:12
bool distancePuncher
Determines whether to use the distance sensor or not.
Definition puncher.h:61
void setDistancePuncher(bool punch)
Sets the distancePuncher variable based on the punch parameter.
Definition puncher.cpp:10
void PuncherSwitch()
Toggles whether the distance sensor is activated or not and prints it out.
Definition puncher.cpp:55
int toShoot()
Checks if the distance sensor is connected and whether to shoot.
Definition puncher.cpp:40
void run(int autonVal)
Runs the puncher based on the given autonomous value.
Definition puncher.cpp:15
The Wings class represents the wings of a robot.
Definition wings.h:11
void setState(bool wingState)
Sets the state of the wings.
Definition wings.cpp:23
void run()
Runs the wings.
Definition wings.cpp:7
bool getState()
Gets the current state of the wings.
Definition wings.cpp:27
bool state
Definition wings.h:42
Contains global variables and type definitions for the Robot namespace.
Definition globals.cpp:18
pros::Controller controller
lemlib::ChassisController_t angularController
Definition globals.cpp:73
pros::Motor LeftMid
pros::Motor IntakeMotor
pros::Distance distance
pros::Motor_Group drive_
pros::Imu inertial_sensor
pros::Motor RightBack
pros::ADIDigitalOut wing2
pros::Motor_Group drive_right
pros::Motor_Group drive_left
pros::Motor RightFront
pros::ADIDigitalOut wing
pros::ADIDigitalOut pto_2
pros::ADIDigitalOut pto_1
pros::Motor RightMid
lemlib::OdomSensors_t sensors
Definition globals.cpp:52
pros::Motor LeftFront
pros::Motor PuncherMotor2
lemlib::ChassisController_t lateralController
Definition globals.cpp:62
Robot::Wings robotWings
lemlib::Chassis chassis
pros::Motor PuncherMotor
lemlib::Drivetrain_t drivetrain
Definition globals.cpp:44
pros::Motor_Group punchers
pros::Motor LeftBack
Contains all objects generated by the 1516B team - Contains all of the subsystems,...
Definition globals.cpp:17