blob: bc0a35c67b2657126a60e6c26a5a67c1e8831a8c [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
14namespace y2023_bot3 {
15namespace autonomous {
16
17class AutonomousActor : public ::frc971::autonomous::BaseAutonomousActor {
18 public:
19 explicit AutonomousActor(::aos::EventLoop *event_loop);
20
21 bool RunAction(
22 const ::frc971::autonomous::AutonomousActionParams *params) override;
23
24 private:
Ariv Diggi0af59c02023-10-07 13:15:39 -070025 void SendSuperstructureGoal();
26
27 void Reset();
28
29 void SendStartingPosition(const Eigen::Vector3d &start);
30 void MaybeSendStartingPosition();
31 void Replan();
Filip Kujawaef687152023-11-14 22:11:32 -080032 void ChargedUp();
33 void ChargedUpMiddle();
34 void OnePieceMiddle();
Ariv Diggi0af59c02023-10-07 13:15:39 -070035
36 aos::Sender<frc971::control_loops::drivetrain::LocalizerControl>
37 localizer_control_sender_;
38 aos::Fetcher<aos::JoystickState> joystick_state_fetcher_;
39 aos::Fetcher<aos::RobotState> robot_state_fetcher_;
40
41 aos::TimerHandler *replan_timer_;
42 aos::TimerHandler *button_poll_;
43
44 aos::Alliance alliance_ = aos::Alliance::kInvalid;
45 AutonomousSplines auto_splines_;
46 bool user_indicated_safe_to_reset_ = false;
47 bool sent_starting_position_ = false;
48
49 bool is_planned_ = false;
50
51 std::optional<Eigen::Vector3d> starting_position_;
52
Ariv Diggi0af59c02023-10-07 13:15:39 -070053 aos::Sender<control_loops::superstructure::Goal> superstructure_goal_sender_;
54 aos::Fetcher<y2023_bot3::control_loops::superstructure::Status>
55 superstructure_status_fetcher_;
56
57 std::optional<SplineHandle> test_spline_;
Filip Kujawaef687152023-11-14 22:11:32 -080058 std::optional<std::array<SplineHandle, 4>> charged_up_splines_;
59 std::optional<std::array<SplineHandle, 1>> charged_up_middle_splines_;
Ariv Diggi0af59c02023-10-07 13:15:39 -070060};
61
62} // namespace autonomous
63} // namespace y2023_bot3
64
65#endif // Y2023_AUTONOMOUS_AUTONOMOUS_ACTOR_H_