blob: 2247b4a984952f91319122cb9e5600da8bde1435 [file] [log] [blame]
Filip Kujawaef687152023-11-14 22:11:32 -08001#ifndef Y2023_BOT3_AUTONOMOUS_AUTONOMOUS_ACTOR_H_
2#define Y2023_BOT3_AUTONOMOUS_AUTONOMOUS_ACTOR_H_
Ariv Diggi0af59c02023-10-07 13:15:39 -07003
4#include "aos/actions/actions.h"
5#include "aos/actions/actor.h"
6#include "frc971/autonomous/base_autonomous_actor.h"
7#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 "y2023_bot3/autonomous/auto_splines.h"
11#include "y2023_bot3/control_loops/superstructure/superstructure_goal_generated.h"
12#include "y2023_bot3/control_loops/superstructure/superstructure_status_generated.h"
13
Stephan Pleinesd99b1ee2024-02-02 20:56:44 -080014namespace y2023_bot3::autonomous {
Ariv Diggi0af59c02023-10-07 13:15:39 -070015
16class AutonomousActor : public ::frc971::autonomous::BaseAutonomousActor {
17 public:
18 explicit AutonomousActor(::aos::EventLoop *event_loop);
19
20 bool RunAction(
21 const ::frc971::autonomous::AutonomousActionParams *params) override;
22
23 private:
Ariv Diggi0af59c02023-10-07 13:15:39 -070024 void SendSuperstructureGoal();
25
26 void Reset();
27
28 void SendStartingPosition(const Eigen::Vector3d &start);
29 void MaybeSendStartingPosition();
30 void Replan();
Filip Kujawaef687152023-11-14 22:11:32 -080031 void ChargedUp();
32 void ChargedUpMiddle();
33 void OnePieceMiddle();
Ariv Diggi0af59c02023-10-07 13:15:39 -070034
35 aos::Sender<frc971::control_loops::drivetrain::LocalizerControl>
36 localizer_control_sender_;
37 aos::Fetcher<aos::JoystickState> joystick_state_fetcher_;
38 aos::Fetcher<aos::RobotState> robot_state_fetcher_;
39
40 aos::TimerHandler *replan_timer_;
41 aos::TimerHandler *button_poll_;
42
43 aos::Alliance alliance_ = aos::Alliance::kInvalid;
44 AutonomousSplines auto_splines_;
45 bool user_indicated_safe_to_reset_ = false;
46 bool sent_starting_position_ = false;
47
48 bool is_planned_ = false;
49
50 std::optional<Eigen::Vector3d> starting_position_;
51
Ariv Diggi0af59c02023-10-07 13:15:39 -070052 aos::Sender<control_loops::superstructure::Goal> superstructure_goal_sender_;
53 aos::Fetcher<y2023_bot3::control_loops::superstructure::Status>
54 superstructure_status_fetcher_;
55
56 std::optional<SplineHandle> test_spline_;
Filip Kujawaef687152023-11-14 22:11:32 -080057 std::optional<std::array<SplineHandle, 4>> charged_up_splines_;
58 std::optional<std::array<SplineHandle, 1>> charged_up_middle_splines_;
Ariv Diggi0af59c02023-10-07 13:15:39 -070059};
60
Stephan Pleinesd99b1ee2024-02-02 20:56:44 -080061} // namespace y2023_bot3::autonomous
Ariv Diggi0af59c02023-10-07 13:15:39 -070062
63#endif // Y2023_AUTONOMOUS_AUTONOMOUS_ACTOR_H_