blob: a0b6ac0bb8bafb0478f8d435fd5b737a116d552e [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.
15 SIMPLE_SHIFTER = 1, // Switch gears without speedmatch logic.
16};
17
Comran Morshed76ca8f52016-02-21 17:26:28 +000018enum 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 Morshed5323ecb2015-12-26 20:50:55 +000023struct DrivetrainConfig {
24 // Shifting method we are using.
25 ShifterType shifter_type;
26
Comran Morshed76ca8f52016-02-21 17:26:28 +000027 // Type of loop to use.
28 LoopType loop_type;
29
Comran Morshed5323ecb2015-12-26 20:50:55 +000030 // 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 Morshed5323ecb2015-12-26 20:50:55 +000036 double robot_radius; // Robot radius, in meters.
37 double wheel_radius; // Wheel radius, in meters.
Comran Morshed5323ecb2015-12-26 20:50:55 +000038 double v; // Motor velocity constant.
Comran Morshed5323ecb2015-12-26 20:50:55 +000039
Austin Schuh09fa9bb2016-02-16 11:47:40 -080040 // Gear ratios, from wheel to motor shaft.
Comran Morshed5323ecb2015-12-26 20:50:55 +000041 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 Snaiderbc918b62016-02-27 21:03:39 -080047
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 Morshed5323ecb2015-12-26 20:50:55 +000051};
52
53} // namespace drivetrain
54} // namespace control_loops
55} // namespace frc971
56
57#endif // FRC971_CONTROL_LOOPS_DRIVETRAIN_CONSTANTS_H_