blob: efb5f59b2ee9029dd68bc10371fb402dcfdd5609 [file] [log] [blame]
Comran Morshed5323ecb2015-12-26 20:50:55 +00001#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
9namespace frc971 {
10namespace control_loops {
11namespace drivetrain {
12
13enum class ShifterType : int32_t {
14 HALL_EFFECT_SHIFTER = 0, // Detect when inbetween gears.
Adam Snaider18f44172016-10-22 15:30:21 -070015 SIMPLE_SHIFTER = 1, // Switch gears without speedmatch logic.
16 NO_SHIFTER = 2, // Only one gear ratio.
Comran Morshed5323ecb2015-12-26 20:50:55 +000017};
18
Comran Morshed76ca8f52016-02-21 17:26:28 +000019enum class LoopType : int32_t {
Adam Snaider18f44172016-10-22 15:30:21 -070020 OPEN_LOOP = 0, // Only use open loop logic.
Comran Morshed76ca8f52016-02-21 17:26:28 +000021 CLOSED_LOOP = 1, // Add in closed loop calculation.
22};
23
Comran Morshed5323ecb2015-12-26 20:50:55 +000024struct DrivetrainConfig {
25 // Shifting method we are using.
26 ShifterType shifter_type;
27
Comran Morshed76ca8f52016-02-21 17:26:28 +000028 // Type of loop to use.
29 LoopType loop_type;
30
Comran Morshed5323ecb2015-12-26 20:50:55 +000031 // 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 Snaider18f44172016-10-22 15:30:21 -070036 double dt; // Control loop time step.
Comran Morshed5323ecb2015-12-26 20:50:55 +000037 double robot_radius; // Robot radius, in meters.
38 double wheel_radius; // Wheel radius, in meters.
Adam Snaider18f44172016-10-22 15:30:21 -070039 double v; // Motor velocity constant.
Comran Morshed5323ecb2015-12-26 20:50:55 +000040
Austin Schuh09fa9bb2016-02-16 11:47:40 -080041 // Gear ratios, from wheel to motor shaft.
Comran Morshed5323ecb2015-12-26 20:50:55 +000042 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 Snaiderbc918b62016-02-27 21:03:39 -080048
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 Schuh889fee82016-04-13 22:16:36 -070052
53 double down_offset;
Adam Snaider94a52372016-10-19 20:06:01 -070054
55 double wheel_non_linearity;
56
57 double quickturn_wheel_multiplier;
Comran Morshed5323ecb2015-12-26 20:50:55 +000058};
59
60} // namespace drivetrain
61} // namespace control_loops
62} // namespace frc971
63
64#endif // FRC971_CONTROL_LOOPS_DRIVETRAIN_CONSTANTS_H_