blob: fd5038d2d367c60425fc333767c92afdb9df23b6 [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();
Niko Sohmers3860f8a2024-01-12 21:05:19 -080043 void SendSuperstructureGoal();
44
Filip Kujawa58ffbf32024-02-24 18:28:34 -080045 void Intake();
46 void Aim();
47 void Shoot();
James Kuszmaulb5f11832024-03-15 22:30:59 -070048 void StopFiring();
49
50 uint32_t shot_count();
Niko Sohmers3860f8a2024-01-12 21:05:19 -080051
Filip Kujawa58ffbf32024-02-24 18:28:34 -080052 [[nodiscard]] bool WaitForPreloaded();
James Kuszmaulb5f11832024-03-15 22:30:59 -070053 [[nodiscard]] bool WaitForNoteFired(uint32_t penultimate_target_shot_count,
54 std::chrono::nanoseconds timeout);
55 [[nodiscard]] bool WaitForCatapultReady();
Niko Sohmers3860f8a2024-01-12 21:05:19 -080056
57 aos::Sender<frc971::control_loops::drivetrain::LocalizerControl>
58 localizer_control_sender_;
Niko Sohmers3860f8a2024-01-12 21:05:19 -080059
Filip Kujawa58ffbf32024-02-24 18:28:34 -080060 aos::Sender<control_loops::superstructure::GoalStatic>
61 superstructure_goal_sender_;
Niko Sohmers3860f8a2024-01-12 21:05:19 -080062
Niko Sohmers3860f8a2024-01-12 21:05:19 -080063 aos::Fetcher<y2024::control_loops::superstructure::Status>
64 superstructure_status_fetcher_;
65
James Kuszmaulb5f11832024-03-15 22:30:59 -070066 const Constants *robot_constants_;
67
Filip Kujawa58ffbf32024-02-24 18:28:34 -080068 AutonomousSplines auto_splines_;
69
Niko Sohmers3860f8a2024-01-12 21:05:19 -080070 std::optional<SplineHandle> test_spline_;
James Kuszmaulb5f11832024-03-15 22:30:59 -070071 std::optional<std::array<SplineHandle, 1>> mobility_and_shoot_splines_;
72 std::optional<std::array<SplineHandle, 5>> four_piece_splines_;
Niko Sohmers3860f8a2024-01-12 21:05:19 -080073
Filip Kujawa58ffbf32024-02-24 18:28:34 -080074 control_loops::superstructure::IntakeGoal intake_goal_ =
75 control_loops::superstructure::IntakeGoal::NONE;
76
77 control_loops::superstructure::NoteGoal note_goal_ =
James Kuszmaulb5f11832024-03-15 22:30:59 -070078 control_loops::superstructure::NoteGoal::CATAPULT;
Filip Kujawa58ffbf32024-02-24 18:28:34 -080079
80 bool auto_aim_ = false;
81 bool fire_ = false;
82 bool preloaded_ = false;
Niko Sohmers3860f8a2024-01-12 21:05:19 -080083};
84
Maxwell Henderson09a4b022024-01-19 21:39:51 -080085} // namespace y2024::autonomous
Niko Sohmers3860f8a2024-01-12 21:05:19 -080086
James Kuszmaulb5f11832024-03-15 22:30:59 -070087#endif // Y2024_AUTONOMOUS_AUTONOMOUS_ACTOR_H_