blob: 97e319d7247a0d6024515718a398cadd4c0e4d2d [file] [log] [blame]
Niko Sohmersc4d2c502024-02-19 19:35:35 -08001#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
14using y2024::control_loops::superstructure::AimerStatus;
15
16namespace y2024::control_loops::superstructure {
17
18class Aimer {
19 public:
Austin Schuh7cea29d2024-03-17 18:20:14 -070020 // When the turret is at 0 the note will be leaving the robot at PI.
21 static constexpr double kTurretZeroOffset = 0.13;
22
Niko Sohmersc4d2c502024-02-19 19:35:35 -080023 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 Kuszmaul4bd2b4b2024-03-16 11:51:55 -070051
52 bool received_joystick_state_ = false;
Niko Sohmersc4d2c502024-02-19 19:35:35 -080053};
54
55} // namespace y2024::control_loops::superstructure
56#endif // Y2024_CONTROL_LOOPS_SUPERSTRUCTURE_TURRET_AIMING_H_