Make a mutual drivetrain between robots.
Change-Id: I23cc9634d9af5d0482dc5a5501dccc064b7b53d3
diff --git a/frc971/control_loops/drivetrain/drivetrain_config.h b/frc971/control_loops/drivetrain/drivetrain_config.h
new file mode 100644
index 0000000..07fbe93
--- /dev/null
+++ b/frc971/control_loops/drivetrain/drivetrain_config.h
@@ -0,0 +1,54 @@
+#ifndef FRC971_CONTROL_LOOPS_DRIVETRAIN_CONSTANTS_H_
+#define FRC971_CONTROL_LOOPS_DRIVETRAIN_CONSTANTS_H_
+
+#include <functional>
+
+#include "frc971/shifter_hall_effect.h"
+#include "frc971/control_loops/state_feedback_loop.h"
+
+namespace frc971 {
+namespace control_loops {
+namespace drivetrain {
+
+enum class ShifterType : int32_t {
+ HALL_EFFECT_SHIFTER = 0, // Detect when inbetween gears.
+ SIMPLE_SHIFTER = 1, // Switch gears without speedmatch logic.
+};
+
+struct DrivetrainConfig {
+ // Shifting method we are using.
+ ShifterType shifter_type;
+
+ // Polydrivetrain functions returning various controller loops with plants.
+ ::std::function<StateFeedbackLoop<4, 2, 2>()> make_drivetrain_loop;
+ ::std::function<StateFeedbackLoop<2, 2, 2>()> make_v_drivetrain_loop;
+ ::std::function<StateFeedbackLoop<7, 2, 3>()> make_kf_drivetrain_loop;
+
+ double dt; // Control loop time step.
+ double stall_torque; // Stall torque in N m.
+ double stall_current; // Stall current in amps.
+ double free_speed_rpm; // Free speed in rpm.
+ double free_current; // Free current in amps.
+ double j; // CIM moment of inertia in kg m^2.
+ double mass; // Mass of the robot.
+ double robot_radius; // Robot radius, in meters.
+ double wheel_radius; // Wheel radius, in meters.
+ double r; // Motor resistance.
+ double v; // Motor velocity constant.
+ double t; // Torque constant.
+
+ double turn_width; // Robot turn width, in meters.
+ // Gear ratios, from encoder shaft to transmission output.
+ double high_gear_ratio;
+ double low_gear_ratio;
+
+ // Hall effect constants. Unused if not applicable to shifter type.
+ constants::ShifterHallEffect left_drive;
+ constants::ShifterHallEffect right_drive;
+};
+
+} // namespace drivetrain
+} // namespace control_loops
+} // namespace frc971
+
+#endif // FRC971_CONTROL_LOOPS_DRIVETRAIN_CONSTANTS_H_