Sabina Davis | f4c5e76 | 2018-01-24 10:18:43 -0800 | [diff] [blame] | 1 | #include "y2018/control_loops/drivetrain/drivetrain_base.h" |
| 2 | |
Austin Schuh | bb735b7 | 2019-01-03 12:58:41 -0800 | [diff] [blame] | 3 | #include <chrono> |
Sabina Davis | f4c5e76 | 2018-01-24 10:18:43 -0800 | [diff] [blame] | 4 | |
Austin Schuh | bb735b7 | 2019-01-03 12:58:41 -0800 | [diff] [blame] | 5 | #include "frc971/control_loops/drivetrain/drivetrain_config.h" |
Sabina Davis | f4c5e76 | 2018-01-24 10:18:43 -0800 | [diff] [blame] | 6 | #include "frc971/control_loops/state_feedback_loop.h" |
| 7 | #include "y2018/control_loops/drivetrain/drivetrain_dog_motor_plant.h" |
Austin Schuh | a062edb | 2019-01-03 13:17:13 -0800 | [diff] [blame] | 8 | #include "y2018/control_loops/drivetrain/hybrid_velocity_drivetrain.h" |
Sabina Davis | f4c5e76 | 2018-01-24 10:18:43 -0800 | [diff] [blame] | 9 | #include "y2018/control_loops/drivetrain/kalman_drivetrain_motor_plant.h" |
Austin Schuh | bb735b7 | 2019-01-03 12:58:41 -0800 | [diff] [blame] | 10 | #include "y2018/control_loops/drivetrain/polydrivetrain_dog_motor_plant.h" |
Sabina Davis | f4c5e76 | 2018-01-24 10:18:43 -0800 | [diff] [blame] | 11 | |
| 12 | using ::frc971::control_loops::drivetrain::DrivetrainConfig; |
| 13 | |
Austin Schuh | bb735b7 | 2019-01-03 12:58:41 -0800 | [diff] [blame] | 14 | namespace chrono = ::std::chrono; |
| 15 | |
Sabina Davis | f4c5e76 | 2018-01-24 10:18:43 -0800 | [diff] [blame] | 16 | namespace y2018 { |
| 17 | namespace control_loops { |
| 18 | namespace drivetrain { |
| 19 | |
| 20 | using ::frc971::constants::ShifterHallEffect; |
| 21 | |
| 22 | const ShifterHallEffect kThreeStateDriveShifter{0.0, 0.0, 0.25, 0.75}; |
| 23 | |
Austin Schuh | bcce26a | 2018-03-26 23:41:24 -0700 | [diff] [blame] | 24 | const DrivetrainConfig<double> &GetDrivetrainConfig() { |
| 25 | static DrivetrainConfig<double> kDrivetrainConfig{ |
Austin Schuh | 3436193 | 2018-04-04 20:13:56 -0700 | [diff] [blame] | 26 | ::frc971::control_loops::drivetrain::ShifterType::SIMPLE_SHIFTER, |
Austin Schuh | e8a54c0 | 2018-03-05 00:25:58 -0800 | [diff] [blame] | 27 | ::frc971::control_loops::drivetrain::LoopType::CLOSED_LOOP, |
Diana Burgess | d0180f1 | 2018-03-21 21:24:17 -0700 | [diff] [blame] | 28 | ::frc971::control_loops::drivetrain::GyroType::IMU_Z_GYRO, |
| 29 | ::frc971::control_loops::drivetrain::IMUType::IMU_Y, |
Sabina Davis | f4c5e76 | 2018-01-24 10:18:43 -0800 | [diff] [blame] | 30 | |
Austin Schuh | a062edb | 2019-01-03 13:17:13 -0800 | [diff] [blame] | 31 | drivetrain::MakeDrivetrainLoop, |
| 32 | drivetrain::MakeVelocityDrivetrainLoop, |
| 33 | drivetrain::MakeKFDrivetrainLoop, |
| 34 | drivetrain::MakeHybridVelocityDrivetrainLoop, |
Sabina Davis | f4c5e76 | 2018-01-24 10:18:43 -0800 | [diff] [blame] | 35 | |
Austin Schuh | bb735b7 | 2019-01-03 12:58:41 -0800 | [diff] [blame] | 36 | chrono::duration_cast<chrono::nanoseconds>( |
| 37 | chrono::duration<double>(drivetrain::kDt)), |
| 38 | drivetrain::kRobotRadius, drivetrain::kWheelRadius, drivetrain::kV, |
Sabina Davis | f4c5e76 | 2018-01-24 10:18:43 -0800 | [diff] [blame] | 39 | |
| 40 | drivetrain::kHighGearRatio, drivetrain::kLowGearRatio, |
Austin Schuh | e6a9fdf | 2019-01-12 16:05:43 -0800 | [diff] [blame] | 41 | drivetrain::kJ, |
| 42 | drivetrain::kMass, |
Sabina Davis | f4c5e76 | 2018-01-24 10:18:43 -0800 | [diff] [blame] | 43 | kThreeStateDriveShifter, kThreeStateDriveShifter, |
| 44 | true /* default_high_gear */, 0 /* down_offset if using constants use |
| 45 | constants::GetValues().down_error */, |
Austin Schuh | e8a54c0 | 2018-03-05 00:25:58 -0800 | [diff] [blame] | 46 | 0.8 /* wheel_non_linearity */, 1.2 /* quickturn_wheel_multiplier */, |
Diana Burgess | d0180f1 | 2018-03-21 21:24:17 -0700 | [diff] [blame] | 47 | 1.5 /* wheel_multiplier */, |
Sabina Davis | f4c5e76 | 2018-01-24 10:18:43 -0800 | [diff] [blame] | 48 | }; |
| 49 | |
| 50 | return kDrivetrainConfig; |
| 51 | }; |
| 52 | |
| 53 | } // namespace drivetrain |
| 54 | } // namespace control_loops |
| 55 | } // namespace y2018 |