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 | |
| 18 | struct DrivetrainConfig { |
| 19 | // Shifting method we are using. |
| 20 | ShifterType shifter_type; |
| 21 | |
| 22 | // Polydrivetrain functions returning various controller loops with plants. |
| 23 | ::std::function<StateFeedbackLoop<4, 2, 2>()> make_drivetrain_loop; |
| 24 | ::std::function<StateFeedbackLoop<2, 2, 2>()> make_v_drivetrain_loop; |
| 25 | ::std::function<StateFeedbackLoop<7, 2, 3>()> make_kf_drivetrain_loop; |
| 26 | |
| 27 | double dt; // Control loop time step. |
| 28 | double stall_torque; // Stall torque in N m. |
| 29 | double stall_current; // Stall current in amps. |
| 30 | double free_speed_rpm; // Free speed in rpm. |
| 31 | double free_current; // Free current in amps. |
| 32 | double j; // CIM moment of inertia in kg m^2. |
| 33 | double mass; // Mass of the robot. |
| 34 | double robot_radius; // Robot radius, in meters. |
| 35 | double wheel_radius; // Wheel radius, in meters. |
| 36 | double r; // Motor resistance. |
| 37 | double v; // Motor velocity constant. |
| 38 | double t; // Torque constant. |
| 39 | |
| 40 | double turn_width; // Robot turn width, in meters. |
| 41 | // Gear ratios, from encoder shaft to transmission output. |
| 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; |
| 48 | }; |
| 49 | |
| 50 | } // namespace drivetrain |
| 51 | } // namespace control_loops |
| 52 | } // namespace frc971 |
| 53 | |
| 54 | #endif // FRC971_CONTROL_LOOPS_DRIVETRAIN_CONSTANTS_H_ |