blob: d13003db2a697246709a84dd75c7269714a796d2 [file] [log] [blame]
Maxwell Henderson64f37452023-03-11 13:39:21 -08001#ifndef Y2023_AUTONOMOUS_AUTONOMOUS_ACTOR_H_
2#define Y2023_AUTONOMOUS_AUTONOMOUS_ACTOR_H_
Maxwell Hendersonad312342023-01-10 12:07:47 -08003
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"
James Kuszmaul713c5ce2023-03-04 18:23:24 -08009#include "frc971/control_loops/drivetrain/localizer_generated.h"
10#include "y2023/autonomous/auto_splines.h"
Maxwell Henderson64f37452023-03-11 13:39:21 -080011#include "y2023/control_loops/superstructure/superstructure_goal_generated.h"
12#include "y2023/control_loops/superstructure/superstructure_status_generated.h"
Maxwell Hendersonad312342023-01-10 12:07:47 -080013
14namespace y2023 {
Maxwell Henderson64f37452023-03-11 13:39:21 -080015namespace autonomous {
Maxwell Hendersonad312342023-01-10 12:07:47 -080016
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:
Maxwell Henderson64f37452023-03-11 13:39:21 -080025 void set_arm_goal_position(uint32_t requested_arm_goal_position) {
26 arm_goal_position_ = requested_arm_goal_position;
27 }
28
29 void set_roller_goal(
30 control_loops::superstructure::RollerGoal requested_roller_goal) {
31 roller_goal_ = requested_roller_goal;
32 }
33
34 void set_wrist_goal(double requested_wrist_goal) {
35 wrist_goal_ = requested_wrist_goal;
36 }
37
38 void set_preloaded(bool preloaded) { preloaded_ = preloaded; }
39
40 void SendSuperstructureGoal();
41 void HighCubeScore();
42 void MidCubeScore();
43 void MidConeScore();
44 void PickupCube();
45 void Spit();
46 void IntakeCube();
47
48 [[nodiscard]] bool WaitForArmGoal();
49
50 [[nodiscard]] bool WaitForPreloaded();
51
Maxwell Hendersonad312342023-01-10 12:07:47 -080052 void Reset();
James Kuszmaul713c5ce2023-03-04 18:23:24 -080053
54 void SendStartingPosition(const Eigen::Vector3d &start);
55 void MaybeSendStartingPosition();
56 void SplineAuto();
Maxwell Henderson64f37452023-03-11 13:39:21 -080057 void ChargedUp();
James Kuszmaul713c5ce2023-03-04 18:23:24 -080058 void Replan();
59
60 aos::Sender<frc971::control_loops::drivetrain::LocalizerControl>
61 localizer_control_sender_;
62 aos::Fetcher<aos::JoystickState> joystick_state_fetcher_;
63 aos::Fetcher<aos::RobotState> robot_state_fetcher_;
64
Maxwell Henderson64f37452023-03-11 13:39:21 -080065 double wrist_goal_ = 0.0;
66 control_loops::superstructure::RollerGoal roller_goal_ =
67 control_loops::superstructure::RollerGoal::IDLE;
68
James Kuszmaul713c5ce2023-03-04 18:23:24 -080069 aos::TimerHandler *replan_timer_;
70 aos::TimerHandler *button_poll_;
71
James Kuszmaul713c5ce2023-03-04 18:23:24 -080072 aos::Alliance alliance_ = aos::Alliance::kInvalid;
73 AutonomousSplines auto_splines_;
74 bool user_indicated_safe_to_reset_ = false;
75 bool sent_starting_position_ = false;
76
77 bool is_planned_ = false;
78
79 std::optional<Eigen::Vector3d> starting_position_;
Maxwell Henderson64f37452023-03-11 13:39:21 -080080
81 uint32_t arm_goal_position_;
82 bool preloaded_ = false;
83
84 aos::Sender<control_loops::superstructure::Goal> superstructure_goal_sender_;
85 aos::Fetcher<y2023::control_loops::superstructure::Status>
86 superstructure_status_fetcher_;
87
88 std::optional<SplineHandle> test_spline_;
89 std::optional<std::array<SplineHandle, 5>> charged_up_splines_;
90
91 // List of arm angles from arm::PointsList
92 const ::std::vector<::Eigen::Matrix<double, 3, 1>> points_;
Maxwell Hendersonad312342023-01-10 12:07:47 -080093};
94
Maxwell Henderson64f37452023-03-11 13:39:21 -080095} // namespace autonomous
Maxwell Hendersonad312342023-01-10 12:07:47 -080096} // namespace y2023
97
Maxwell Henderson64f37452023-03-11 13:39:21 -080098#endif // Y2023_AUTONOMOUS_AUTONOMOUS_ACTOR_H_