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