Comran Morshed | 5323ecb | 2015-12-26 20:50:55 +0000 | [diff] [blame] | 1 | #ifndef FRC971_CONTROL_LOOPS_DRIVETRAIN_CONSTANTS_H_ |
| 2 | #define FRC971_CONTROL_LOOPS_DRIVETRAIN_CONSTANTS_H_ |
| 3 | |
| 4 | #include <functional> |
| 5 | |
| 6 | #include "frc971/shifter_hall_effect.h" |
| 7 | #include "frc971/control_loops/state_feedback_loop.h" |
| 8 | |
| 9 | namespace frc971 { |
| 10 | namespace control_loops { |
| 11 | namespace drivetrain { |
| 12 | |
| 13 | enum class ShifterType : int32_t { |
| 14 | HALL_EFFECT_SHIFTER = 0, // Detect when inbetween gears. |
Adam Snaider | 18f4417 | 2016-10-22 15:30:21 -0700 | [diff] [blame] | 15 | SIMPLE_SHIFTER = 1, // Switch gears without speedmatch logic. |
| 16 | NO_SHIFTER = 2, // Only one gear ratio. |
Comran Morshed | 5323ecb | 2015-12-26 20:50:55 +0000 | [diff] [blame] | 17 | }; |
| 18 | |
Comran Morshed | 76ca8f5 | 2016-02-21 17:26:28 +0000 | [diff] [blame] | 19 | enum class LoopType : int32_t { |
Adam Snaider | 18f4417 | 2016-10-22 15:30:21 -0700 | [diff] [blame] | 20 | OPEN_LOOP = 0, // Only use open loop logic. |
Comran Morshed | 76ca8f5 | 2016-02-21 17:26:28 +0000 | [diff] [blame] | 21 | CLOSED_LOOP = 1, // Add in closed loop calculation. |
| 22 | }; |
| 23 | |
Comran Morshed | 5323ecb | 2015-12-26 20:50:55 +0000 | [diff] [blame] | 24 | struct DrivetrainConfig { |
| 25 | // Shifting method we are using. |
| 26 | ShifterType shifter_type; |
| 27 | |
Comran Morshed | 76ca8f5 | 2016-02-21 17:26:28 +0000 | [diff] [blame] | 28 | // Type of loop to use. |
| 29 | LoopType loop_type; |
| 30 | |
Comran Morshed | 5323ecb | 2015-12-26 20:50:55 +0000 | [diff] [blame] | 31 | // Polydrivetrain functions returning various controller loops with plants. |
| 32 | ::std::function<StateFeedbackLoop<4, 2, 2>()> make_drivetrain_loop; |
| 33 | ::std::function<StateFeedbackLoop<2, 2, 2>()> make_v_drivetrain_loop; |
| 34 | ::std::function<StateFeedbackLoop<7, 2, 3>()> make_kf_drivetrain_loop; |
| 35 | |
Adam Snaider | 18f4417 | 2016-10-22 15:30:21 -0700 | [diff] [blame] | 36 | double dt; // Control loop time step. |
Comran Morshed | 5323ecb | 2015-12-26 20:50:55 +0000 | [diff] [blame] | 37 | double robot_radius; // Robot radius, in meters. |
| 38 | double wheel_radius; // Wheel radius, in meters. |
Adam Snaider | 18f4417 | 2016-10-22 15:30:21 -0700 | [diff] [blame] | 39 | double v; // Motor velocity constant. |
Comran Morshed | 5323ecb | 2015-12-26 20:50:55 +0000 | [diff] [blame] | 40 | |
Austin Schuh | 09fa9bb | 2016-02-16 11:47:40 -0800 | [diff] [blame] | 41 | // Gear ratios, from wheel to motor shaft. |
Comran Morshed | 5323ecb | 2015-12-26 20:50:55 +0000 | [diff] [blame] | 42 | double high_gear_ratio; |
| 43 | double low_gear_ratio; |
| 44 | |
| 45 | // Hall effect constants. Unused if not applicable to shifter type. |
| 46 | constants::ShifterHallEffect left_drive; |
| 47 | constants::ShifterHallEffect right_drive; |
Adam Snaider | bc918b6 | 2016-02-27 21:03:39 -0800 | [diff] [blame] | 48 | |
| 49 | // Variable that holds the default gear ratio. We use this in ZeroOutputs(). |
| 50 | // (ie. true means high gear is default). |
| 51 | bool default_high_gear; |
Austin Schuh | 889fee8 | 2016-04-13 22:16:36 -0700 | [diff] [blame] | 52 | |
| 53 | double down_offset; |
Adam Snaider | 94a5237 | 2016-10-19 20:06:01 -0700 | [diff] [blame] | 54 | |
| 55 | double wheel_non_linearity; |
| 56 | |
| 57 | double quickturn_wheel_multiplier; |
Comran Morshed | 5323ecb | 2015-12-26 20:50:55 +0000 | [diff] [blame] | 58 | }; |
| 59 | |
| 60 | } // namespace drivetrain |
| 61 | } // namespace control_loops |
| 62 | } // namespace frc971 |
| 63 | |
| 64 | #endif // FRC971_CONTROL_LOOPS_DRIVETRAIN_CONSTANTS_H_ |