blob: 4eabe3eca42f5d12f9ad4ae90137bfac115710a8 [file] [log] [blame]
James Kuszmaul84083f42022-02-27 17:24:38 -08001#ifndef Y2022_CONTROL_LOOPS_SUPERSTRUCTURE_TURRET_AIMING_H_
2#define Y2022_CONTROL_LOOPS_SUPERSTRUCTURE_TURRET_AIMING_H_
3
4#include "aos/flatbuffers.h"
James Kuszmaulb9ba9a52022-03-31 22:16:01 -07005#include "frc971/control_loops/aiming/aiming.h"
James Kuszmaul84083f42022-02-27 17:24:38 -08006#include "frc971/control_loops/drivetrain/drivetrain_status_generated.h"
7#include "frc971/control_loops/pose.h"
8#include "frc971/control_loops/profiled_subsystem_generated.h"
James Kuszmaulb9ba9a52022-03-31 22:16:01 -07009#include "y2022/constants.h"
James Kuszmaul84083f42022-02-27 17:24:38 -080010#include "y2022/control_loops/superstructure/superstructure_status_generated.h"
11
12namespace y2022::control_loops::superstructure::turret {
13
14// This class manages taking in drivetrain status messages and generating turret
15// goals so that it gets aimed at the goal.
16class Aimer {
17 public:
18 typedef frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystemGoal
19 Goal;
20 typedef frc971::control_loops::drivetrain::Status Status;
21 typedef frc971::control_loops::aiming::ShotMode ShotMode;
22
James Kuszmaulb9ba9a52022-03-31 22:16:01 -070023 Aimer(std::shared_ptr<const constants::Values> constants);
James Kuszmaul84083f42022-02-27 17:24:38 -080024
25 void Update(const Status *status, ShotMode shot_mode);
26
27 const Goal *TurretGoal() const { return &goal_.message(); }
28
29 // Returns the distance to the goal, in meters.
30 double DistanceToGoal() const { return current_goal_.virtual_shot_distance; }
31
32 flatbuffers::Offset<AimerStatus> PopulateStatus(
33 flatbuffers::FlatBufferBuilder *fbb) const;
34
35 private:
James Kuszmaulb9ba9a52022-03-31 22:16:01 -070036 std::shared_ptr<const constants::Values> constants_;
James Kuszmaul84083f42022-02-27 17:24:38 -080037 aos::FlatbufferDetachedBuffer<Goal> goal_;
38 frc971::control_loops::aiming::TurretGoal current_goal_;
39};
40
41} // namespace y2022::control_loops::superstructure::turret
42#endif // Y2020_CONTROL_LOOPS_SUPERSTRUCTURE_TURRET_AIMING_H_