Sabina Davis | 92d2efa | 2017-11-04 22:35:25 -0700 | [diff] [blame] | 1 | #ifndef AOS_INPUT_DRIVETRAIN_INPUT_H_ |
| 2 | #define AOS_INPUT_DRIVETRAIN_INPUT_H_ |
| 3 | |
Sabina Davis | 92d2efa | 2017-11-04 22:35:25 -0700 | [diff] [blame] | 4 | #include <cmath> |
Tyler Chatow | bf0609c | 2021-07-31 16:13:27 -0700 | [diff] [blame] | 5 | #include <cstdio> |
| 6 | #include <cstring> |
Sabina Davis | 92d2efa | 2017-11-04 22:35:25 -0700 | [diff] [blame] | 7 | #include <memory> |
| 8 | |
John Park | 33858a3 | 2018-09-28 23:05:48 -0700 | [diff] [blame] | 9 | #include "aos/logging/logging.h" |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 10 | #include "frc971/control_loops/control_loops_generated.h" |
Sabina Davis | 82b1918 | 2017-11-10 09:30:25 -0800 | [diff] [blame] | 11 | #include "frc971/control_loops/drivetrain/drivetrain_config.h" |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 12 | #include "frc971/control_loops/drivetrain/drivetrain_goal_generated.h" |
| 13 | #include "frc971/control_loops/drivetrain/drivetrain_status_generated.h" |
Nikolai Sohmers | 0991b1f | 2024-10-20 14:24:34 -0700 | [diff] [blame^] | 14 | #include "frc971/control_loops/swerve/swerve_drivetrain_goal_static.h" |
| 15 | #include "frc971/control_loops/swerve/swerve_drivetrain_joystick_goal_static.h" |
James Kuszmaul | 7077d34 | 2021-06-09 20:23:58 -0700 | [diff] [blame] | 16 | #include "frc971/input/driver_station_data.h" |
Sabina Davis | 92d2efa | 2017-11-04 22:35:25 -0700 | [diff] [blame] | 17 | |
Stephan Pleines | d99b1ee | 2024-02-02 20:56:44 -0800 | [diff] [blame] | 18 | namespace frc971::input { |
Sabina Davis | 92d2efa | 2017-11-04 22:35:25 -0700 | [diff] [blame] | 19 | |
Maxwell Henderson | 24f89f3 | 2023-03-25 15:55:46 -0700 | [diff] [blame] | 20 | using control_loops::drivetrain::PistolBottomButtonUse; |
| 21 | using control_loops::drivetrain::PistolSecondButtonUse; |
| 22 | using control_loops::drivetrain::PistolTopButtonUse; |
| 23 | |
Sabina Davis | 92d2efa | 2017-11-04 22:35:25 -0700 | [diff] [blame] | 24 | // We have a couple different joystick configurations used to drive our skid |
| 25 | // steer robots. These configurations don't change very often, and there are a |
| 26 | // small, discrete, set of them. The interface to the drivetrain is the same |
| 27 | // across all of our drivetrains, so we can abstract that away from our users. |
| 28 | // |
| 29 | // We want to be able to re-use that code across years, and switch joystick |
| 30 | // types quickly and efficiently. |
| 31 | // |
| 32 | // DrivetrainInputReader is the abstract base class which provides a consistent |
| 33 | // API to control drivetrains. |
| 34 | // |
| 35 | // To construct the appropriate DrivetrainInputReader, call |
| 36 | // DrivetrainInputReader::Make with the input type enum. |
| 37 | // To use it, call HandleDrivetrain(data) every time a joystick packet is |
| 38 | // received. |
| 39 | // |
| 40 | // Base class for the interface to the drivetrain implemented by multiple |
| 41 | // joystick types. |
| 42 | class DrivetrainInputReader { |
| 43 | public: |
James Kuszmaul | 8bad241 | 2019-03-10 10:47:56 -0700 | [diff] [blame] | 44 | // What to use the turn1/2 buttons for. |
| 45 | enum class TurnButtonUse { |
| 46 | // Use the button to enable control loop driving. |
| 47 | kControlLoopDriving, |
| 48 | // Use the button to set line following mode. |
| 49 | kLineFollow, |
| 50 | }; |
Sabina Davis | 92d2efa | 2017-11-04 22:35:25 -0700 | [diff] [blame] | 51 | // Inputs driver station button and joystick locations |
Austin Schuh | bd0a40f | 2019-06-30 14:56:31 -0700 | [diff] [blame] | 52 | DrivetrainInputReader(::aos::EventLoop *event_loop, |
| 53 | driver_station::JoystickAxis wheel, |
Austin Schuh | 2b1fce0 | 2018-03-02 20:05:20 -0800 | [diff] [blame] | 54 | driver_station::JoystickAxis throttle, |
Sabina Davis | 82b1918 | 2017-11-10 09:30:25 -0800 | [diff] [blame] | 55 | driver_station::ButtonLocation quick_turn, |
| 56 | driver_station::ButtonLocation turn1, |
James Kuszmaul | 8bad241 | 2019-03-10 10:47:56 -0700 | [diff] [blame] | 57 | TurnButtonUse turn1_use, |
| 58 | driver_station::ButtonLocation turn2, |
| 59 | TurnButtonUse turn2_use) |
Austin Schuh | 2b1fce0 | 2018-03-02 20:05:20 -0800 | [diff] [blame] | 60 | : wheel_(wheel), |
| 61 | throttle_(throttle), |
Sabina Davis | 82b1918 | 2017-11-10 09:30:25 -0800 | [diff] [blame] | 62 | quick_turn_(quick_turn), |
| 63 | turn1_(turn1), |
James Kuszmaul | 8bad241 | 2019-03-10 10:47:56 -0700 | [diff] [blame] | 64 | turn1_use_(turn1_use), |
| 65 | turn2_(turn2), |
Austin Schuh | bd0a40f | 2019-06-30 14:56:31 -0700 | [diff] [blame] | 66 | turn2_use_(turn2_use), |
| 67 | drivetrain_status_fetcher_( |
| 68 | event_loop |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 69 | ->MakeFetcher<::frc971::control_loops::drivetrain::Status>( |
| 70 | "/drivetrain")), |
Austin Schuh | bd0a40f | 2019-06-30 14:56:31 -0700 | [diff] [blame] | 71 | drivetrain_goal_sender_( |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 72 | event_loop->MakeSender<::frc971::control_loops::drivetrain::Goal>( |
| 73 | "/drivetrain")) {} |
Sabina Davis | 92d2efa | 2017-11-04 22:35:25 -0700 | [diff] [blame] | 74 | |
| 75 | virtual ~DrivetrainInputReader() = default; |
| 76 | |
| 77 | // List of driver joystick types. |
| 78 | enum class InputType { |
| 79 | kSteeringWheel, |
| 80 | kPistol, |
| 81 | kXbox, |
| 82 | }; |
| 83 | |
| 84 | // Constructs the appropriate DrivetrainInputReader. |
Sabina Davis | 82b1918 | 2017-11-10 09:30:25 -0800 | [diff] [blame] | 85 | static std::unique_ptr<DrivetrainInputReader> Make( |
Austin Schuh | bd0a40f | 2019-06-30 14:56:31 -0700 | [diff] [blame] | 86 | ::aos::EventLoop *event_loop, InputType type, |
Austin Schuh | bcce26a | 2018-03-26 23:41:24 -0700 | [diff] [blame] | 87 | const ::frc971::control_loops::drivetrain::DrivetrainConfig<double> |
| 88 | &dt_config); |
Sabina Davis | 92d2efa | 2017-11-04 22:35:25 -0700 | [diff] [blame] | 89 | |
| 90 | // Processes new joystick data and publishes drivetrain goal messages. |
James Kuszmaul | 7077d34 | 2021-06-09 20:23:58 -0700 | [diff] [blame] | 91 | void HandleDrivetrain(const ::frc971::input::driver_station::Data &data); |
Sabina Davis | 92d2efa | 2017-11-04 22:35:25 -0700 | [diff] [blame] | 92 | |
| 93 | // Sets the scalar for the steering wheel for closed loop mode converting |
| 94 | // steering ratio to meters displacement on the two wheels. |
| 95 | void set_wheel_multiplier(double wheel_multiplier) { |
| 96 | wheel_multiplier_ = wheel_multiplier; |
| 97 | } |
| 98 | |
| 99 | // Returns the current robot velocity in m/s. |
| 100 | double robot_velocity() const { return robot_velocity_; } |
| 101 | |
Austin Schuh | 0b00c86 | 2021-10-17 17:39:10 -0700 | [diff] [blame] | 102 | // Returns the current drivetrain status. |
| 103 | const control_loops::drivetrain::Status *drivetrain_status() const { |
| 104 | return drivetrain_status_fetcher_.get(); |
| 105 | } |
| 106 | |
Austin Schuh | a250b2d | 2019-05-27 16:14:02 -0700 | [diff] [blame] | 107 | void set_vision_align_fn( |
James Kuszmaul | 7077d34 | 2021-06-09 20:23:58 -0700 | [diff] [blame] | 108 | ::std::function<bool(const ::frc971::input::driver_station::Data &data)> |
Austin Schuh | a250b2d | 2019-05-27 16:14:02 -0700 | [diff] [blame] | 109 | vision_align_fn) { |
| 110 | vision_align_fn_ = vision_align_fn; |
| 111 | } |
| 112 | |
Sabina Davis | 92d2efa | 2017-11-04 22:35:25 -0700 | [diff] [blame] | 113 | protected: |
Austin Schuh | 2b1fce0 | 2018-03-02 20:05:20 -0800 | [diff] [blame] | 114 | const driver_station::JoystickAxis wheel_; |
| 115 | const driver_station::JoystickAxis throttle_; |
Sabina Davis | 82b1918 | 2017-11-10 09:30:25 -0800 | [diff] [blame] | 116 | const driver_station::ButtonLocation quick_turn_; |
James Kuszmaul | 8bad241 | 2019-03-10 10:47:56 -0700 | [diff] [blame] | 117 | // Button for enabling control loop driving. |
Sabina Davis | 82b1918 | 2017-11-10 09:30:25 -0800 | [diff] [blame] | 118 | const driver_station::ButtonLocation turn1_; |
James Kuszmaul | 8bad241 | 2019-03-10 10:47:56 -0700 | [diff] [blame] | 119 | const TurnButtonUse turn1_use_; |
| 120 | // But for enabling line following. |
Sabina Davis | 82b1918 | 2017-11-10 09:30:25 -0800 | [diff] [blame] | 121 | const driver_station::ButtonLocation turn2_; |
James Kuszmaul | 8bad241 | 2019-03-10 10:47:56 -0700 | [diff] [blame] | 122 | const TurnButtonUse turn2_use_; |
Sabina Davis | 92d2efa | 2017-11-04 22:35:25 -0700 | [diff] [blame] | 123 | |
Austin Schuh | 48d3a96 | 2019-03-17 18:12:32 -0700 | [diff] [blame] | 124 | bool last_is_control_loop_driving_ = false; |
| 125 | |
Sabina Davis | 92d2efa | 2017-11-04 22:35:25 -0700 | [diff] [blame] | 126 | // Structure containing the (potentially adjusted) steering and throttle |
| 127 | // values from the joysticks. |
| 128 | struct WheelAndThrottle { |
| 129 | double wheel; |
Austin Schuh | 2b1fce0 | 2018-03-02 20:05:20 -0800 | [diff] [blame] | 130 | double wheel_velocity; |
| 131 | double wheel_torque; |
Sabina Davis | 92d2efa | 2017-11-04 22:35:25 -0700 | [diff] [blame] | 132 | double throttle; |
Austin Schuh | 2b1fce0 | 2018-03-02 20:05:20 -0800 | [diff] [blame] | 133 | double throttle_velocity; |
| 134 | double throttle_torque; |
Sabina Davis | 82b1918 | 2017-11-10 09:30:25 -0800 | [diff] [blame] | 135 | bool high_gear; |
Sabina Davis | 92d2efa | 2017-11-04 22:35:25 -0700 | [diff] [blame] | 136 | }; |
| 137 | |
| 138 | private: |
| 139 | // Computes the steering and throttle from the provided driverstation data. |
| 140 | virtual WheelAndThrottle GetWheelAndThrottle( |
James Kuszmaul | 7077d34 | 2021-06-09 20:23:58 -0700 | [diff] [blame] | 141 | const ::frc971::input::driver_station::Data &data) = 0; |
Sabina Davis | 92d2efa | 2017-11-04 22:35:25 -0700 | [diff] [blame] | 142 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 143 | ::aos::Fetcher<::frc971::control_loops::drivetrain::Status> |
Austin Schuh | bd0a40f | 2019-06-30 14:56:31 -0700 | [diff] [blame] | 144 | drivetrain_status_fetcher_; |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 145 | ::aos::Sender<::frc971::control_loops::drivetrain::Goal> |
Austin Schuh | bd0a40f | 2019-06-30 14:56:31 -0700 | [diff] [blame] | 146 | drivetrain_goal_sender_; |
| 147 | |
Sabina Davis | 92d2efa | 2017-11-04 22:35:25 -0700 | [diff] [blame] | 148 | double robot_velocity_ = 0.0; |
| 149 | // Goals to send to the drivetrain in closed loop mode. |
| 150 | double left_goal_ = 0.0; |
| 151 | double right_goal_ = 0.0; |
| 152 | // The scale for the joysticks for closed loop mode converting |
| 153 | // joysticks to meters displacement on the two wheels. |
| 154 | double wheel_multiplier_ = 0.5; |
Austin Schuh | a250b2d | 2019-05-27 16:14:02 -0700 | [diff] [blame] | 155 | |
James Kuszmaul | 7077d34 | 2021-06-09 20:23:58 -0700 | [diff] [blame] | 156 | ::std::function<bool(const ::frc971::input::driver_station::Data &data)> |
Austin Schuh | a250b2d | 2019-05-27 16:14:02 -0700 | [diff] [blame] | 157 | vision_align_fn_; |
Sabina Davis | 92d2efa | 2017-11-04 22:35:25 -0700 | [diff] [blame] | 158 | }; |
| 159 | |
Nikolai Sohmers | 0991b1f | 2024-10-20 14:24:34 -0700 | [diff] [blame^] | 160 | class SwerveDrivetrainInputReader { |
| 161 | SwerveDrivetrainInputReader(::aos::EventLoop *event_loop, |
| 162 | driver_station::JoystickAxis vx_axis, |
| 163 | driver_station::JoystickAxis vy_axis, |
| 164 | driver_station::JoystickAxis omega_axis) |
| 165 | : vx_axis_(vx_axis), |
| 166 | vy_axis_(vy_axis), |
| 167 | omega_axis_(omega_axis), |
| 168 | goal_sender_(event_loop->MakeSender<control_loops::swerve::GoalStatic>( |
| 169 | "/drivetrain")) {} |
| 170 | |
| 171 | public: |
| 172 | virtual ~SwerveDrivetrainInputReader() = default; |
| 173 | |
| 174 | // Constructs the appropriate DrivetrainInputReader. |
| 175 | static std::unique_ptr<SwerveDrivetrainInputReader> Make( |
| 176 | ::aos::EventLoop *event_loop); |
| 177 | |
| 178 | // Processes new joystick data and publishes drivetrain goal messages. |
| 179 | void HandleDrivetrain(const ::frc971::input::driver_station::Data &data); |
| 180 | |
| 181 | // Sets the scalar for the steering wheel for closed loop mode converting |
| 182 | // steering ratio to meters displacement on the two wheels. |
| 183 | void set_wheel_multiplier(double wheel_multiplier) { |
| 184 | wheel_multiplier_ = wheel_multiplier; |
| 185 | } |
| 186 | |
| 187 | protected: |
| 188 | const driver_station::JoystickAxis vx_axis_; |
| 189 | const driver_station::JoystickAxis vy_axis_; |
| 190 | const driver_station::JoystickAxis omega_axis_; |
| 191 | |
| 192 | // Structure containing the (potentially adjusted) steering and throttle |
| 193 | // values from the joysticks. |
| 194 | struct SwerveGoals { |
| 195 | double vx; |
| 196 | double vy; |
| 197 | double omega; |
| 198 | }; |
| 199 | |
| 200 | private: |
| 201 | // Computes the steering and throttle from the provided driverstation data. |
| 202 | SwerveGoals GetSwerveGoals(const ::frc971::input::driver_station::Data &data); |
| 203 | |
| 204 | ::aos::Sender<control_loops::swerve::GoalStatic> goal_sender_; |
| 205 | |
| 206 | // The scale for the joysticks for closed loop mode converting |
| 207 | // joysticks to meters displacement on the two wheels. |
| 208 | double wheel_multiplier_ = 0.5; |
| 209 | }; |
| 210 | |
Sabina Davis | 92d2efa | 2017-11-04 22:35:25 -0700 | [diff] [blame] | 211 | // Implements DrivetrainInputReader for the original steering wheel. |
| 212 | class SteeringWheelDrivetrainInputReader : public DrivetrainInputReader { |
| 213 | public: |
| 214 | using DrivetrainInputReader::DrivetrainInputReader; |
| 215 | |
| 216 | // Creates a DrivetrainInputReader with the corresponding joystick ports and |
| 217 | // axis for the big steering wheel and throttle stick. |
Sabina Davis | 82b1918 | 2017-11-10 09:30:25 -0800 | [diff] [blame] | 218 | static std::unique_ptr<SteeringWheelDrivetrainInputReader> Make( |
Austin Schuh | bd0a40f | 2019-06-30 14:56:31 -0700 | [diff] [blame] | 219 | ::aos::EventLoop *event_loop, bool default_high_gear); |
Sabina Davis | 82b1918 | 2017-11-10 09:30:25 -0800 | [diff] [blame] | 220 | |
| 221 | // Sets the default shifter position |
| 222 | void set_default_high_gear(bool default_high_gear) { |
| 223 | high_gear_ = default_high_gear; |
| 224 | default_high_gear_ = default_high_gear; |
| 225 | } |
Sabina Davis | 92d2efa | 2017-11-04 22:35:25 -0700 | [diff] [blame] | 226 | |
| 227 | private: |
| 228 | WheelAndThrottle GetWheelAndThrottle( |
James Kuszmaul | 7077d34 | 2021-06-09 20:23:58 -0700 | [diff] [blame] | 229 | const ::frc971::input::driver_station::Data &data) override; |
Sabina Davis | 82b1918 | 2017-11-10 09:30:25 -0800 | [diff] [blame] | 230 | bool high_gear_; |
| 231 | bool default_high_gear_; |
Sabina Davis | 92d2efa | 2017-11-04 22:35:25 -0700 | [diff] [blame] | 232 | }; |
| 233 | |
| 234 | class PistolDrivetrainInputReader : public DrivetrainInputReader { |
| 235 | public: |
| 236 | using DrivetrainInputReader::DrivetrainInputReader; |
| 237 | |
| 238 | // Creates a DrivetrainInputReader with the corresponding joystick ports and |
| 239 | // axis for the (cheap) pistol grip controller. |
James Kuszmaul | 8bad241 | 2019-03-10 10:47:56 -0700 | [diff] [blame] | 240 | static std::unique_ptr<PistolDrivetrainInputReader> Make( |
Austin Schuh | bd0a40f | 2019-06-30 14:56:31 -0700 | [diff] [blame] | 241 | ::aos::EventLoop *event_loop, bool default_high_gear, |
Maxwell Henderson | 24f89f3 | 2023-03-25 15:55:46 -0700 | [diff] [blame] | 242 | PistolTopButtonUse top_button_use, |
| 243 | PistolSecondButtonUse second_button_use, |
| 244 | PistolBottomButtonUse bottom_button_use); |
Sabina Davis | 92d2efa | 2017-11-04 22:35:25 -0700 | [diff] [blame] | 245 | |
| 246 | private: |
Austin Schuh | 2b1fce0 | 2018-03-02 20:05:20 -0800 | [diff] [blame] | 247 | PistolDrivetrainInputReader( |
Austin Schuh | bd0a40f | 2019-06-30 14:56:31 -0700 | [diff] [blame] | 248 | ::aos::EventLoop *event_loop, driver_station::JoystickAxis wheel_high, |
Austin Schuh | 2b1fce0 | 2018-03-02 20:05:20 -0800 | [diff] [blame] | 249 | driver_station::JoystickAxis wheel_low, |
| 250 | driver_station::JoystickAxis wheel_velocity_high, |
| 251 | driver_station::JoystickAxis wheel_velocity_low, |
| 252 | driver_station::JoystickAxis wheel_torque_high, |
| 253 | driver_station::JoystickAxis wheel_torque_low, |
| 254 | driver_station::JoystickAxis throttle_high, |
| 255 | driver_station::JoystickAxis throttle_low, |
| 256 | driver_station::JoystickAxis throttle_velocity_high, |
| 257 | driver_station::JoystickAxis throttle_velocity_low, |
| 258 | driver_station::JoystickAxis throttle_torque_high, |
| 259 | driver_station::JoystickAxis throttle_torque_low, |
| 260 | driver_station::ButtonLocation quick_turn, |
| 261 | driver_station::ButtonLocation shift_high, |
| 262 | driver_station::ButtonLocation shift_low, |
| 263 | driver_station::ButtonLocation turn1, |
James Kuszmaul | c4eb1b2 | 2019-04-13 15:48:34 -0700 | [diff] [blame] | 264 | driver_station::ButtonLocation turn2, |
| 265 | driver_station::ButtonLocation slow_down) |
Austin Schuh | bd0a40f | 2019-06-30 14:56:31 -0700 | [diff] [blame] | 266 | : DrivetrainInputReader(event_loop, wheel_high, throttle_high, quick_turn, |
| 267 | turn1, TurnButtonUse::kLineFollow, turn2, |
Austin Schuh | 48d3a96 | 2019-03-17 18:12:32 -0700 | [diff] [blame] | 268 | TurnButtonUse::kControlLoopDriving), |
Austin Schuh | 2b1fce0 | 2018-03-02 20:05:20 -0800 | [diff] [blame] | 269 | wheel_low_(wheel_low), |
| 270 | wheel_velocity_high_(wheel_velocity_high), |
| 271 | wheel_velocity_low_(wheel_velocity_low), |
| 272 | wheel_torque_high_(wheel_torque_high), |
| 273 | wheel_torque_low_(wheel_torque_low), |
| 274 | throttle_low_(throttle_low), |
| 275 | throttle_velocity_high_(throttle_velocity_high), |
| 276 | throttle_velocity_low_(throttle_velocity_low), |
| 277 | throttle_torque_high_(throttle_torque_high), |
| 278 | throttle_torque_low_(throttle_torque_low), |
| 279 | shift_high_(shift_high), |
James Kuszmaul | c4eb1b2 | 2019-04-13 15:48:34 -0700 | [diff] [blame] | 280 | shift_low_(shift_low), |
| 281 | slow_down_(slow_down) {} |
Austin Schuh | 2b1fce0 | 2018-03-02 20:05:20 -0800 | [diff] [blame] | 282 | |
Sabina Davis | 92d2efa | 2017-11-04 22:35:25 -0700 | [diff] [blame] | 283 | WheelAndThrottle GetWheelAndThrottle( |
James Kuszmaul | 7077d34 | 2021-06-09 20:23:58 -0700 | [diff] [blame] | 284 | const ::frc971::input::driver_station::Data &data) override; |
Austin Schuh | 2b1fce0 | 2018-03-02 20:05:20 -0800 | [diff] [blame] | 285 | |
| 286 | // Sets the default shifter position |
| 287 | void set_default_high_gear(bool default_high_gear) { |
| 288 | high_gear_ = default_high_gear; |
| 289 | default_high_gear_ = default_high_gear; |
| 290 | } |
| 291 | |
| 292 | const driver_station::JoystickAxis wheel_low_; |
| 293 | const driver_station::JoystickAxis wheel_velocity_high_; |
| 294 | const driver_station::JoystickAxis wheel_velocity_low_; |
| 295 | const driver_station::JoystickAxis wheel_torque_high_; |
| 296 | const driver_station::JoystickAxis wheel_torque_low_; |
| 297 | |
| 298 | const driver_station::JoystickAxis throttle_low_; |
| 299 | const driver_station::JoystickAxis throttle_velocity_high_; |
| 300 | const driver_station::JoystickAxis throttle_velocity_low_; |
| 301 | const driver_station::JoystickAxis throttle_torque_high_; |
| 302 | const driver_station::JoystickAxis throttle_torque_low_; |
| 303 | |
| 304 | const driver_station::ButtonLocation shift_high_; |
| 305 | const driver_station::ButtonLocation shift_low_; |
James Kuszmaul | c4eb1b2 | 2019-04-13 15:48:34 -0700 | [diff] [blame] | 306 | const driver_station::ButtonLocation slow_down_; |
Austin Schuh | 2b1fce0 | 2018-03-02 20:05:20 -0800 | [diff] [blame] | 307 | |
| 308 | bool high_gear_; |
| 309 | bool default_high_gear_; |
Sabina Davis | 92d2efa | 2017-11-04 22:35:25 -0700 | [diff] [blame] | 310 | }; |
| 311 | |
| 312 | class XboxDrivetrainInputReader : public DrivetrainInputReader { |
| 313 | public: |
| 314 | using DrivetrainInputReader::DrivetrainInputReader; |
| 315 | |
| 316 | // Creates a DrivetrainInputReader with the corresponding joystick ports and |
| 317 | // axis for the Xbox controller. |
Austin Schuh | bd0a40f | 2019-06-30 14:56:31 -0700 | [diff] [blame] | 318 | static std::unique_ptr<XboxDrivetrainInputReader> Make( |
| 319 | ::aos::EventLoop *event_loop); |
Sabina Davis | 92d2efa | 2017-11-04 22:35:25 -0700 | [diff] [blame] | 320 | |
| 321 | private: |
| 322 | WheelAndThrottle GetWheelAndThrottle( |
James Kuszmaul | 7077d34 | 2021-06-09 20:23:58 -0700 | [diff] [blame] | 323 | const ::frc971::input::driver_station::Data &data) override; |
Sabina Davis | 92d2efa | 2017-11-04 22:35:25 -0700 | [diff] [blame] | 324 | }; |
| 325 | |
Stephan Pleines | d99b1ee | 2024-02-02 20:56:44 -0800 | [diff] [blame] | 326 | } // namespace frc971::input |
Sabina Davis | 92d2efa | 2017-11-04 22:35:25 -0700 | [diff] [blame] | 327 | |
| 328 | #endif // AOS_INPUT_DRIVETRAIN_INPUT_H_ |