James Kuszmaul | 84083f4 | 2022-02-27 17:24:38 -0800 | [diff] [blame] | 1 | #ifndef Y2022_CONTROL_LOOPS_SUPERSTRUCTURE_TURRET_AIMING_H_ |
| 2 | #define Y2022_CONTROL_LOOPS_SUPERSTRUCTURE_TURRET_AIMING_H_ |
| 3 | |
| 4 | #include "aos/flatbuffers.h" |
| 5 | #include "frc971/control_loops/drivetrain/drivetrain_status_generated.h" |
| 6 | #include "frc971/control_loops/pose.h" |
| 7 | #include "frc971/control_loops/profiled_subsystem_generated.h" |
| 8 | #include "frc971/control_loops/aiming/aiming.h" |
| 9 | #include "y2022/control_loops/superstructure/superstructure_status_generated.h" |
| 10 | |
| 11 | namespace y2022::control_loops::superstructure::turret { |
| 12 | |
| 13 | // This class manages taking in drivetrain status messages and generating turret |
| 14 | // goals so that it gets aimed at the goal. |
| 15 | class Aimer { |
| 16 | public: |
| 17 | typedef frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystemGoal |
| 18 | Goal; |
| 19 | typedef frc971::control_loops::drivetrain::Status Status; |
| 20 | typedef frc971::control_loops::aiming::ShotMode ShotMode; |
| 21 | |
| 22 | Aimer(); |
| 23 | |
| 24 | void Update(const Status *status, ShotMode shot_mode); |
| 25 | |
| 26 | const Goal *TurretGoal() const { return &goal_.message(); } |
| 27 | |
| 28 | // Returns the distance to the goal, in meters. |
| 29 | double DistanceToGoal() const { return current_goal_.virtual_shot_distance; } |
| 30 | |
| 31 | flatbuffers::Offset<AimerStatus> PopulateStatus( |
| 32 | flatbuffers::FlatBufferBuilder *fbb) const; |
| 33 | |
| 34 | private: |
| 35 | aos::FlatbufferDetachedBuffer<Goal> goal_; |
| 36 | frc971::control_loops::aiming::TurretGoal current_goal_; |
| 37 | }; |
| 38 | |
| 39 | } // namespace y2022::control_loops::superstructure::turret |
| 40 | #endif // Y2020_CONTROL_LOOPS_SUPERSTRUCTURE_TURRET_AIMING_H_ |