blob: a126feb386c5de01e1189e0a2120effd27ebb419 [file] [log] [blame]
Niko Sohmers3860f8a2024-01-12 21:05:19 -08001#ifndef Y2024_AUTONOMOUS_AUTONOMOUS_ACTOR_H_
2#define Y2024_AUTONOMOUS_AUTONOMOUS_ACTOR_H_
3
4#include "aos/actions/actions.h"
5#include "aos/actions/actor.h"
Filip Kujawa58ffbf32024-02-24 18:28:34 -08006#include "frc971/autonomous/user_button_localized_autonomous_actor.h"
Niko Sohmers3860f8a2024-01-12 21:05:19 -08007#include "frc971/control_loops/control_loops_generated.h"
8#include "frc971/control_loops/drivetrain/drivetrain_config.h"
9#include "frc971/control_loops/drivetrain/localizer_generated.h"
10#include "y2024/autonomous/auto_splines.h"
James Kuszmaulb5f11832024-03-15 22:30:59 -070011#include "y2024/constants.h"
12#include "y2024/constants/constants_generated.h"
Filip Kujawa58ffbf32024-02-24 18:28:34 -080013#include "y2024/control_loops/superstructure/superstructure_goal_static.h"
14#include "y2024/control_loops/superstructure/superstructure_status_static.h"
Niko Sohmers3860f8a2024-01-12 21:05:19 -080015
Maxwell Henderson09a4b022024-01-19 21:39:51 -080016namespace y2024::autonomous {
Niko Sohmers3860f8a2024-01-12 21:05:19 -080017
Filip Kujawa58ffbf32024-02-24 18:28:34 -080018class AutonomousActor
19 : public ::frc971::autonomous::UserButtonLocalizedAutonomousActor {
Niko Sohmers3860f8a2024-01-12 21:05:19 -080020 public:
James Kuszmaulb5f11832024-03-15 22:30:59 -070021 explicit AutonomousActor(::aos::EventLoop *event_loop,
22 const y2024::Constants *robot_constants);
Niko Sohmers3860f8a2024-01-12 21:05:19 -080023
Niko Sohmers3860f8a2024-01-12 21:05:19 -080024 private:
Filip Kujawa58ffbf32024-02-24 18:28:34 -080025 void set_intake_goal(control_loops::superstructure::IntakeGoal intake_goal) {
26 intake_goal_ = intake_goal;
27 }
28 void set_note_goal(control_loops::superstructure::NoteGoal note_goal) {
29 note_goal_ = note_goal;
30 }
Filip Kujawa1286c012024-03-31 22:53:27 -070031 void set_auto_aim(control_loops::superstructure::AutoAimMode auto_aim) {
32 auto_aim_ = auto_aim;
33 }
Filip Kujawa58ffbf32024-02-24 18:28:34 -080034 void set_fire(bool fire) { fire_ = fire; }
35 void set_preloaded(bool preloaded) { preloaded_ = preloaded; }
36
37 bool Run(const ::frc971::autonomous::AutonomousActionParams *params) override;
38 void Replan() override;
39 void SendStartingPosition(const Eigen::Vector3d &start) override;
40 void Reset() override;
41
42 void SplineAuto();
James Kuszmaulb5f11832024-03-15 22:30:59 -070043 void MobilityAndShoot();
44 void FourPieceAuto();
Maxwell Hendersona2dadd02024-03-24 13:57:09 -070045 void TwoPieceStealAuto();
James Kuszmaul337e3a52024-05-04 14:06:52 -070046 void TwoPieceViaStageAuto();
Niko Sohmers3860f8a2024-01-12 21:05:19 -080047 void SendSuperstructureGoal();
48
James Kuszmaul58f51432024-03-24 15:00:06 -070049 void StopIntake();
Filip Kujawa58ffbf32024-02-24 18:28:34 -080050 void Intake();
51 void Aim();
James Kuszmaul337e3a52024-05-04 14:06:52 -070052 void StopAiming();
Filip Kujawa58ffbf32024-02-24 18:28:34 -080053 void Shoot();
James Kuszmaulb5f11832024-03-15 22:30:59 -070054 void StopFiring();
55
56 uint32_t shot_count();
Niko Sohmers3860f8a2024-01-12 21:05:19 -080057
Filip Kujawa58ffbf32024-02-24 18:28:34 -080058 [[nodiscard]] bool WaitForPreloaded();
James Kuszmaulb5f11832024-03-15 22:30:59 -070059 [[nodiscard]] bool WaitForNoteFired(uint32_t penultimate_target_shot_count,
60 std::chrono::nanoseconds timeout);
61 [[nodiscard]] bool WaitForCatapultReady();
Niko Sohmers3860f8a2024-01-12 21:05:19 -080062
63 aos::Sender<frc971::control_loops::drivetrain::LocalizerControl>
64 localizer_control_sender_;
Niko Sohmers3860f8a2024-01-12 21:05:19 -080065
Filip Kujawa58ffbf32024-02-24 18:28:34 -080066 aos::Sender<control_loops::superstructure::GoalStatic>
67 superstructure_goal_sender_;
Niko Sohmers3860f8a2024-01-12 21:05:19 -080068
Niko Sohmers3860f8a2024-01-12 21:05:19 -080069 aos::Fetcher<y2024::control_loops::superstructure::Status>
70 superstructure_status_fetcher_;
71
James Kuszmaulb5f11832024-03-15 22:30:59 -070072 const Constants *robot_constants_;
73
Filip Kujawa58ffbf32024-02-24 18:28:34 -080074 AutonomousSplines auto_splines_;
75
Niko Sohmers3860f8a2024-01-12 21:05:19 -080076 std::optional<SplineHandle> test_spline_;
James Kuszmaulb5f11832024-03-15 22:30:59 -070077 std::optional<std::array<SplineHandle, 1>> mobility_and_shoot_splines_;
78 std::optional<std::array<SplineHandle, 5>> four_piece_splines_;
Maxwell Hendersona2dadd02024-03-24 13:57:09 -070079 std::optional<std::array<SplineHandle, 4>> two_piece_steal_splines_;
James Kuszmaul337e3a52024-05-04 14:06:52 -070080 std::optional<std::array<SplineHandle, 4>> two_piece_via_stage_splines_;
Niko Sohmers3860f8a2024-01-12 21:05:19 -080081
Filip Kujawa58ffbf32024-02-24 18:28:34 -080082 control_loops::superstructure::IntakeGoal intake_goal_ =
83 control_loops::superstructure::IntakeGoal::NONE;
84
85 control_loops::superstructure::NoteGoal note_goal_ =
James Kuszmaulb5f11832024-03-15 22:30:59 -070086 control_loops::superstructure::NoteGoal::CATAPULT;
Filip Kujawa58ffbf32024-02-24 18:28:34 -080087
Filip Kujawa1286c012024-03-31 22:53:27 -070088 control_loops::superstructure::AutoAimMode auto_aim_ =
89 control_loops::superstructure::AutoAimMode::NONE;
Filip Kujawa58ffbf32024-02-24 18:28:34 -080090 bool fire_ = false;
91 bool preloaded_ = false;
Niko Sohmers3860f8a2024-01-12 21:05:19 -080092};
93
Maxwell Henderson09a4b022024-01-19 21:39:51 -080094} // namespace y2024::autonomous
Niko Sohmers3860f8a2024-01-12 21:05:19 -080095
James Kuszmaulb5f11832024-03-15 22:30:59 -070096#endif // Y2024_AUTONOMOUS_AUTONOMOUS_ACTOR_H_