blob: 0de85bfe69e3541cd65ac12b9aa2a499571cfa20 [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 }
31 void set_auto_aim(bool auto_aim) { auto_aim_ = auto_aim; }
32 void set_fire(bool fire) { fire_ = fire; }
33 void set_preloaded(bool preloaded) { preloaded_ = preloaded; }
34
35 bool Run(const ::frc971::autonomous::AutonomousActionParams *params) override;
36 void Replan() override;
37 void SendStartingPosition(const Eigen::Vector3d &start) override;
38 void Reset() override;
39
40 void SplineAuto();
James Kuszmaulb5f11832024-03-15 22:30:59 -070041 void MobilityAndShoot();
42 void FourPieceAuto();
Maxwell Hendersona2dadd02024-03-24 13:57:09 -070043 void TwoPieceStealAuto();
Niko Sohmers3860f8a2024-01-12 21:05:19 -080044 void SendSuperstructureGoal();
45
Filip Kujawa58ffbf32024-02-24 18:28:34 -080046 void Intake();
47 void Aim();
48 void Shoot();
James Kuszmaulb5f11832024-03-15 22:30:59 -070049 void StopFiring();
50
51 uint32_t shot_count();
Niko Sohmers3860f8a2024-01-12 21:05:19 -080052
Filip Kujawa58ffbf32024-02-24 18:28:34 -080053 [[nodiscard]] bool WaitForPreloaded();
James Kuszmaulb5f11832024-03-15 22:30:59 -070054 [[nodiscard]] bool WaitForNoteFired(uint32_t penultimate_target_shot_count,
55 std::chrono::nanoseconds timeout);
56 [[nodiscard]] bool WaitForCatapultReady();
Niko Sohmers3860f8a2024-01-12 21:05:19 -080057
58 aos::Sender<frc971::control_loops::drivetrain::LocalizerControl>
59 localizer_control_sender_;
Niko Sohmers3860f8a2024-01-12 21:05:19 -080060
Filip Kujawa58ffbf32024-02-24 18:28:34 -080061 aos::Sender<control_loops::superstructure::GoalStatic>
62 superstructure_goal_sender_;
Niko Sohmers3860f8a2024-01-12 21:05:19 -080063
Niko Sohmers3860f8a2024-01-12 21:05:19 -080064 aos::Fetcher<y2024::control_loops::superstructure::Status>
65 superstructure_status_fetcher_;
66
James Kuszmaulb5f11832024-03-15 22:30:59 -070067 const Constants *robot_constants_;
68
Filip Kujawa58ffbf32024-02-24 18:28:34 -080069 AutonomousSplines auto_splines_;
70
Niko Sohmers3860f8a2024-01-12 21:05:19 -080071 std::optional<SplineHandle> test_spline_;
James Kuszmaulb5f11832024-03-15 22:30:59 -070072 std::optional<std::array<SplineHandle, 1>> mobility_and_shoot_splines_;
73 std::optional<std::array<SplineHandle, 5>> four_piece_splines_;
Maxwell Hendersona2dadd02024-03-24 13:57:09 -070074 std::optional<std::array<SplineHandle, 4>> two_piece_steal_splines_;
Niko Sohmers3860f8a2024-01-12 21:05:19 -080075
Filip Kujawa58ffbf32024-02-24 18:28:34 -080076 control_loops::superstructure::IntakeGoal intake_goal_ =
77 control_loops::superstructure::IntakeGoal::NONE;
78
79 control_loops::superstructure::NoteGoal note_goal_ =
James Kuszmaulb5f11832024-03-15 22:30:59 -070080 control_loops::superstructure::NoteGoal::CATAPULT;
Filip Kujawa58ffbf32024-02-24 18:28:34 -080081
82 bool auto_aim_ = false;
83 bool fire_ = false;
84 bool preloaded_ = false;
Niko Sohmers3860f8a2024-01-12 21:05:19 -080085};
86
Maxwell Henderson09a4b022024-01-19 21:39:51 -080087} // namespace y2024::autonomous
Niko Sohmers3860f8a2024-01-12 21:05:19 -080088
James Kuszmaulb5f11832024-03-15 22:30:59 -070089#endif // Y2024_AUTONOMOUS_AUTONOMOUS_ACTOR_H_