blob: ad33eed294b38905be250e907fae4a0c3bf8c022 [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
Filip Kujawaef687152023-11-14 22:11:32 -080014// TODO<FILIP>: Add NEUTRAL pivot pose.
15
Ariv Diggi0af59c02023-10-07 13:15:39 -070016namespace y2023_bot3 {
17namespace autonomous {
18
19class AutonomousActor : public ::frc971::autonomous::BaseAutonomousActor {
20 public:
21 explicit AutonomousActor(::aos::EventLoop *event_loop);
22
23 bool RunAction(
24 const ::frc971::autonomous::AutonomousActionParams *params) override;
25
26 private:
27 void set_preloaded(bool preloaded) { preloaded_ = preloaded; }
28
Filip Kujawaef687152023-11-14 22:11:32 -080029 void set_pivot_goal(
30 control_loops::superstructure::PivotGoal requested_pivot_goal) {
31 pivot_goal_ = requested_pivot_goal;
32 }
33
34 void set_roller_goal(
35 control_loops::superstructure::RollerGoal requested_roller_goal) {
36 roller_goal_ = requested_roller_goal;
37 }
38
Ariv Diggi0af59c02023-10-07 13:15:39 -070039 void SendSuperstructureGoal();
40
Filip Kujawaef687152023-11-14 22:11:32 -080041 [[nodiscard]] bool WaitForPreloaded();
42
43 void HighScore();
44 void MidScore();
45 void LowScore();
46 void Spit();
47 void SpitHigh();
48 void StopSpitting();
49 void Pickup();
50 void Intake();
51 void Neutral();
52
Ariv Diggi0af59c02023-10-07 13:15:39 -070053 void Reset();
54
55 void SendStartingPosition(const Eigen::Vector3d &start);
56 void MaybeSendStartingPosition();
57 void Replan();
Filip Kujawaef687152023-11-14 22:11:32 -080058 void ChargedUp();
59 void ChargedUpMiddle();
60 void OnePieceMiddle();
Ariv Diggi0af59c02023-10-07 13:15:39 -070061
62 aos::Sender<frc971::control_loops::drivetrain::LocalizerControl>
63 localizer_control_sender_;
64 aos::Fetcher<aos::JoystickState> joystick_state_fetcher_;
65 aos::Fetcher<aos::RobotState> robot_state_fetcher_;
66
67 aos::TimerHandler *replan_timer_;
68 aos::TimerHandler *button_poll_;
69
70 aos::Alliance alliance_ = aos::Alliance::kInvalid;
71 AutonomousSplines auto_splines_;
72 bool user_indicated_safe_to_reset_ = false;
73 bool sent_starting_position_ = false;
74
75 bool is_planned_ = false;
76
77 std::optional<Eigen::Vector3d> starting_position_;
78
79 bool preloaded_ = false;
80
Filip Kujawaef687152023-11-14 22:11:32 -080081 control_loops::superstructure::PivotGoal pivot_goal_;
82 control_loops::superstructure::RollerGoal roller_goal_;
83
Ariv Diggi0af59c02023-10-07 13:15:39 -070084 aos::Sender<control_loops::superstructure::Goal> superstructure_goal_sender_;
85 aos::Fetcher<y2023_bot3::control_loops::superstructure::Status>
86 superstructure_status_fetcher_;
87
88 std::optional<SplineHandle> test_spline_;
Filip Kujawaef687152023-11-14 22:11:32 -080089 std::optional<std::array<SplineHandle, 4>> charged_up_splines_;
90 std::optional<std::array<SplineHandle, 1>> charged_up_middle_splines_;
Ariv Diggi0af59c02023-10-07 13:15:39 -070091};
92
93} // namespace autonomous
94} // namespace y2023_bot3
95
96#endif // Y2023_AUTONOMOUS_AUTONOMOUS_ACTOR_H_