milind-u | 086d726 | 2022-01-19 20:44:18 -0800 | [diff] [blame] | 1 | #include "y2022/control_loops/drivetrain/drivetrain_base.h" |
| 2 | |
| 3 | #include <chrono> |
| 4 | |
| 5 | #include "frc971/control_loops/drivetrain/drivetrain_config.h" |
| 6 | #include "frc971/control_loops/state_feedback_loop.h" |
| 7 | #include "y2022/control_loops/drivetrain/drivetrain_dog_motor_plant.h" |
| 8 | #include "y2022/control_loops/drivetrain/hybrid_velocity_drivetrain.h" |
| 9 | #include "y2022/control_loops/drivetrain/kalman_drivetrain_motor_plant.h" |
| 10 | #include "y2022/control_loops/drivetrain/polydrivetrain_dog_motor_plant.h" |
| 11 | |
James Kuszmaul | 6802533 | 2024-01-20 17:06:02 -0800 | [diff] [blame] | 12 | using ::frc971::control_loops::drivetrain::DownEstimatorConfigT; |
Philipp Schrader | 790cb54 | 2023-07-05 21:06:52 -0700 | [diff] [blame] | 13 | using ::frc971::control_loops::drivetrain::DrivetrainConfig; |
milind-u | 086d726 | 2022-01-19 20:44:18 -0800 | [diff] [blame] | 14 | |
| 15 | namespace chrono = ::std::chrono; |
| 16 | |
Stephan Pleines | f63bde8 | 2024-01-13 15:59:33 -0800 | [diff] [blame] | 17 | namespace y2022::control_loops::drivetrain { |
milind-u | 086d726 | 2022-01-19 20:44:18 -0800 | [diff] [blame] | 18 | |
| 19 | using ::frc971::constants::ShifterHallEffect; |
| 20 | |
| 21 | const ShifterHallEffect kThreeStateDriveShifter{0.0, 0.0, 0.25, 0.75}; |
| 22 | |
| 23 | const DrivetrainConfig<double> &GetDrivetrainConfig() { |
James Kuszmaul | 207ae32 | 2022-02-25 21:15:31 -0800 | [diff] [blame] | 24 | // Yaw of the IMU relative to the robot frame. |
James Kuszmaul | 82189eb | 2022-03-05 17:58:34 -0800 | [diff] [blame] | 25 | static constexpr double kImuYaw = 0.0; |
milind-u | 086d726 | 2022-01-19 20:44:18 -0800 | [diff] [blame] | 26 | static DrivetrainConfig<double> kDrivetrainConfig{ |
James Kuszmaul | 6802533 | 2024-01-20 17:06:02 -0800 | [diff] [blame] | 27 | ::frc971::control_loops::drivetrain::ShifterType::kSimpleShifter, |
| 28 | ::frc971::control_loops::drivetrain::LoopType::kClosedLoop, |
| 29 | ::frc971::control_loops::drivetrain::GyroType::kSpartanGyro, |
| 30 | ::frc971::control_loops::drivetrain::ImuType::kImuFlippedX, |
milind-u | 086d726 | 2022-01-19 20:44:18 -0800 | [diff] [blame] | 31 | |
| 32 | drivetrain::MakeDrivetrainLoop, |
| 33 | drivetrain::MakeVelocityDrivetrainLoop, |
| 34 | drivetrain::MakeKFDrivetrainLoop, |
| 35 | drivetrain::MakeHybridVelocityDrivetrainLoop, |
| 36 | |
| 37 | chrono::duration_cast<chrono::nanoseconds>( |
| 38 | chrono::duration<double>(drivetrain::kDt)), |
| 39 | drivetrain::kRobotRadius, |
| 40 | drivetrain::kWheelRadius, |
| 41 | drivetrain::kV, |
| 42 | |
| 43 | drivetrain::kHighGearRatio, |
| 44 | drivetrain::kLowGearRatio, |
| 45 | drivetrain::kJ, |
| 46 | drivetrain::kMass, |
| 47 | kThreeStateDriveShifter, |
| 48 | kThreeStateDriveShifter, |
| 49 | true /* default_high_gear */, |
| 50 | 0 /* down_offset if using constants use |
| 51 | constants::GetValues().down_error */ |
| 52 | , |
| 53 | 0.7 /* wheel_non_linearity */, |
| 54 | 1.2 /* quickturn_wheel_multiplier */, |
| 55 | 1.2 /* wheel_multiplier */, |
| 56 | true /*pistol_grip_shift_enables_line_follow*/, |
James Kuszmaul | 207ae32 | 2022-02-25 21:15:31 -0800 | [diff] [blame] | 57 | (Eigen::Matrix<double, 3, 3>() << std::cos(kImuYaw), -std::sin(kImuYaw), |
| 58 | 0.0, std::sin(kImuYaw), std::cos(kImuYaw), 0.0, 0.0, 0.0, 1.0) |
| 59 | .finished(), |
| 60 | false /*is_simulated*/, |
James Kuszmaul | 6802533 | 2024-01-20 17:06:02 -0800 | [diff] [blame] | 61 | DownEstimatorConfigT{{}, 0.015, 1000}}; |
milind-u | 086d726 | 2022-01-19 20:44:18 -0800 | [diff] [blame] | 62 | |
| 63 | return kDrivetrainConfig; |
| 64 | }; |
| 65 | |
Stephan Pleines | f63bde8 | 2024-01-13 15:59:33 -0800 | [diff] [blame] | 66 | } // namespace y2022::control_loops::drivetrain |