blob: cf0b458f9bfbcb500b4aa43048cf601cc0e80183 [file] [log] [blame]
Maxwell Hendersonad312342023-01-10 12:07:47 -08001#ifndef Y2023_ACTORS_AUTONOMOUS_ACTOR_H_
2#define Y2023_ACTORS_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"
James Kuszmaul713c5ce2023-03-04 18:23:24 -08009#include "frc971/control_loops/drivetrain/localizer_generated.h"
10#include "y2023/autonomous/auto_splines.h"
Maxwell Hendersonad312342023-01-10 12:07:47 -080011
12namespace y2023 {
13namespace actors {
14
15class AutonomousActor : public ::frc971::autonomous::BaseAutonomousActor {
16 public:
17 explicit AutonomousActor(::aos::EventLoop *event_loop);
18
19 bool RunAction(
20 const ::frc971::autonomous::AutonomousActionParams *params) override;
21
22 private:
23 void Reset();
James Kuszmaul713c5ce2023-03-04 18:23:24 -080024
25 void SendStartingPosition(const Eigen::Vector3d &start);
26 void MaybeSendStartingPosition();
27 void SplineAuto();
28 void Replan();
29
30 aos::Sender<frc971::control_loops::drivetrain::LocalizerControl>
31 localizer_control_sender_;
32 aos::Fetcher<aos::JoystickState> joystick_state_fetcher_;
33 aos::Fetcher<aos::RobotState> robot_state_fetcher_;
34
35 aos::TimerHandler *replan_timer_;
36 aos::TimerHandler *button_poll_;
37
38 std::optional<SplineHandle> test_spline_;
39 aos::Alliance alliance_ = aos::Alliance::kInvalid;
40 AutonomousSplines auto_splines_;
41 bool user_indicated_safe_to_reset_ = false;
42 bool sent_starting_position_ = false;
43
44 bool is_planned_ = false;
45
46 std::optional<Eigen::Vector3d> starting_position_;
Maxwell Hendersonad312342023-01-10 12:07:47 -080047};
48
49} // namespace actors
50} // namespace y2023
51
52#endif // Y2023_ACTORS_AUTONOMOUS_ACTOR_H_