blob: e0b4f334664a45a882206bad0365d1205d6be2d2 [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();
Niko Sohmers3860f8a2024-01-12 21:05:19 -080046 void SendSuperstructureGoal();
47
James Kuszmaul58f51432024-03-24 15:00:06 -070048 void StopIntake();
Filip Kujawa58ffbf32024-02-24 18:28:34 -080049 void Intake();
50 void Aim();
51 void Shoot();
James Kuszmaulb5f11832024-03-15 22:30:59 -070052 void StopFiring();
53
54 uint32_t shot_count();
Niko Sohmers3860f8a2024-01-12 21:05:19 -080055
Filip Kujawa58ffbf32024-02-24 18:28:34 -080056 [[nodiscard]] bool WaitForPreloaded();
James Kuszmaulb5f11832024-03-15 22:30:59 -070057 [[nodiscard]] bool WaitForNoteFired(uint32_t penultimate_target_shot_count,
58 std::chrono::nanoseconds timeout);
59 [[nodiscard]] bool WaitForCatapultReady();
Niko Sohmers3860f8a2024-01-12 21:05:19 -080060
61 aos::Sender<frc971::control_loops::drivetrain::LocalizerControl>
62 localizer_control_sender_;
Niko Sohmers3860f8a2024-01-12 21:05:19 -080063
Filip Kujawa58ffbf32024-02-24 18:28:34 -080064 aos::Sender<control_loops::superstructure::GoalStatic>
65 superstructure_goal_sender_;
Niko Sohmers3860f8a2024-01-12 21:05:19 -080066
Niko Sohmers3860f8a2024-01-12 21:05:19 -080067 aos::Fetcher<y2024::control_loops::superstructure::Status>
68 superstructure_status_fetcher_;
69
James Kuszmaulb5f11832024-03-15 22:30:59 -070070 const Constants *robot_constants_;
71
Filip Kujawa58ffbf32024-02-24 18:28:34 -080072 AutonomousSplines auto_splines_;
73
Niko Sohmers3860f8a2024-01-12 21:05:19 -080074 std::optional<SplineHandle> test_spline_;
James Kuszmaulb5f11832024-03-15 22:30:59 -070075 std::optional<std::array<SplineHandle, 1>> mobility_and_shoot_splines_;
76 std::optional<std::array<SplineHandle, 5>> four_piece_splines_;
Maxwell Hendersona2dadd02024-03-24 13:57:09 -070077 std::optional<std::array<SplineHandle, 4>> two_piece_steal_splines_;
Niko Sohmers3860f8a2024-01-12 21:05:19 -080078
Filip Kujawa58ffbf32024-02-24 18:28:34 -080079 control_loops::superstructure::IntakeGoal intake_goal_ =
80 control_loops::superstructure::IntakeGoal::NONE;
81
82 control_loops::superstructure::NoteGoal note_goal_ =
James Kuszmaulb5f11832024-03-15 22:30:59 -070083 control_loops::superstructure::NoteGoal::CATAPULT;
Filip Kujawa58ffbf32024-02-24 18:28:34 -080084
Filip Kujawa1286c012024-03-31 22:53:27 -070085 control_loops::superstructure::AutoAimMode auto_aim_ =
86 control_loops::superstructure::AutoAimMode::NONE;
Filip Kujawa58ffbf32024-02-24 18:28:34 -080087 bool fire_ = false;
88 bool preloaded_ = false;
Niko Sohmers3860f8a2024-01-12 21:05:19 -080089};
90
Maxwell Henderson09a4b022024-01-19 21:39:51 -080091} // namespace y2024::autonomous
Niko Sohmers3860f8a2024-01-12 21:05:19 -080092
James Kuszmaulb5f11832024-03-15 22:30:59 -070093#endif // Y2024_AUTONOMOUS_AUTONOMOUS_ACTOR_H_