blob: b7978c7b03e6259e5e4e9a55490e9bd59f0ed5b0 [file] [log] [blame]
Ariv Diggi0af59c02023-10-07 13:15:39 -07001#ifndef Y2023_AUTONOMOUS_AUTONOMOUS_ACTOR_H_
2#define Y2023_AUTONOMOUS_AUTONOMOUS_ACTOR_H_
3
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:
25 void set_preloaded(bool preloaded) { preloaded_ = preloaded; }
26
27 void SendSuperstructureGoal();
28
29 void Reset();
30
31 void SendStartingPosition(const Eigen::Vector3d &start);
32 void MaybeSendStartingPosition();
33 void Replan();
34
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
52 bool preloaded_ = false;
53
54 aos::Sender<control_loops::superstructure::Goal> superstructure_goal_sender_;
55 aos::Fetcher<y2023_bot3::control_loops::superstructure::Status>
56 superstructure_status_fetcher_;
57
58 std::optional<SplineHandle> test_spline_;
59};
60
61} // namespace autonomous
62} // namespace y2023_bot3
63
64#endif // Y2023_AUTONOMOUS_AUTONOMOUS_ACTOR_H_