Niko Sohmers | c4d2c50 | 2024-02-19 19:35:35 -0800 | [diff] [blame] | 1 | #ifndef Y2024_CONTROL_LOOPS_SUPERSTRUCTURE_AIMING_H_ |
| 2 | #define Y2024_CONTROL_LOOPS_SUPERSTRUCTURE_AIMING_H_ |
| 3 | |
| 4 | #include "frc971/control_loops/aiming/aiming.h" |
| 5 | #include "frc971/control_loops/drivetrain/drivetrain_status_generated.h" |
| 6 | #include "frc971/control_loops/pose.h" |
| 7 | #include "frc971/control_loops/static_zeroing_single_dof_profiled_subsystem.h" |
| 8 | #include "frc971/shooter_interpolation/interpolation.h" |
| 9 | #include "y2024/constants.h" |
| 10 | #include "y2024/constants/constants_generated.h" |
| 11 | #include "y2024/control_loops/drivetrain/drivetrain_base.h" |
| 12 | #include "y2024/control_loops/superstructure/superstructure_status_generated.h" |
| 13 | |
| 14 | using y2024::control_loops::superstructure::AimerStatus; |
| 15 | |
| 16 | namespace y2024::control_loops::superstructure { |
| 17 | |
| 18 | class Aimer { |
| 19 | public: |
Austin Schuh | 7cea29d | 2024-03-17 18:20:14 -0700 | [diff] [blame] | 20 | // When the turret is at 0 the note will be leaving the robot at PI. |
| 21 | static constexpr double kTurretZeroOffset = 0.13; |
| 22 | |
Niko Sohmers | c4d2c50 | 2024-02-19 19:35:35 -0800 | [diff] [blame] | 23 | Aimer(aos::EventLoop *event_loop, const Constants *robot_constants); |
| 24 | |
| 25 | void Update( |
| 26 | const frc971::control_loops::drivetrain::Status *status, |
| 27 | frc971::control_loops::aiming::ShotMode shot_mode, |
| 28 | frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystemGoalStatic |
| 29 | *turret_goal); |
| 30 | |
| 31 | double DistanceToGoal() const { return current_goal_.virtual_shot_distance; } |
| 32 | |
| 33 | flatbuffers::Offset<AimerStatus> PopulateStatus( |
| 34 | flatbuffers::FlatBufferBuilder *fbb) const; |
| 35 | |
| 36 | private: |
| 37 | aos::EventLoop *event_loop_; |
| 38 | |
| 39 | const Constants *robot_constants_; |
| 40 | |
| 41 | frc971::control_loops::drivetrain::DrivetrainConfig<double> |
| 42 | drivetrain_config_; |
| 43 | |
| 44 | frc971::shooter_interpolation::InterpolationTable< |
| 45 | y2024::constants::Values::ShotParams> |
| 46 | interpolation_table_; |
| 47 | |
| 48 | aos::Fetcher<aos::JoystickState> joystick_state_fetcher_; |
| 49 | |
| 50 | frc971::control_loops::aiming::TurretGoal current_goal_; |
James Kuszmaul | 4bd2b4b | 2024-03-16 11:51:55 -0700 | [diff] [blame] | 51 | |
| 52 | bool received_joystick_state_ = false; |
Niko Sohmers | c4d2c50 | 2024-02-19 19:35:35 -0800 | [diff] [blame] | 53 | }; |
| 54 | |
| 55 | } // namespace y2024::control_loops::superstructure |
| 56 | #endif // Y2024_CONTROL_LOOPS_SUPERSTRUCTURE_TURRET_AIMING_H_ |