blob: 37a8cdb9cf1ec3fc826a7d85530c76eb34efd0ac [file] [log] [blame]
milind-u086d7262022-01-19 20:44:18 -08001#ifndef Y2022_ACTORS_AUTONOMOUS_ACTOR_H_
2#define Y2022_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"
Ravago Jones81e50632022-03-11 16:23:51 -08009#include "frc971/control_loops/drivetrain/localizer_generated.h"
10#include "y2022/actors/auto_splines.h"
11#include "y2022/control_loops/superstructure/superstructure_goal_generated.h"
12#include "y2022/control_loops/superstructure/superstructure_status_generated.h"
milind-u086d7262022-01-19 20:44:18 -080013
14namespace y2022 {
15namespace actors {
16
Ravago Jones81e50632022-03-11 16:23:51 -080017using frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystemGoal;
18
19namespace superstructure = y2022::control_loops::superstructure;
20
milind-u086d7262022-01-19 20:44:18 -080021class AutonomousActor : public ::frc971::autonomous::BaseAutonomousActor {
22 public:
23 explicit AutonomousActor(::aos::EventLoop *event_loop);
24
25 bool RunAction(
26 const ::frc971::autonomous::AutonomousActionParams *params) override;
27
28 private:
29 void Reset();
Ravago Jones81e50632022-03-11 16:23:51 -080030
31 void set_intake_front_goal(double intake_front_goal) {
32 intake_front_goal_ = intake_front_goal;
33 }
34 void set_intake_back_goal(double intake_back_goal) {
35 intake_back_goal_ = intake_back_goal;
36 }
37 void set_roller_front_voltage(double roller_front_voltage) {
38 roller_front_voltage_ = roller_front_voltage;
39 }
40 void set_roller_back_voltage(double roller_back_voltage) {
41 roller_back_voltage_ = roller_back_voltage;
42 }
Milind Upadhyayb1a74ea2022-03-09 20:34:35 -080043 void set_transfer_roller_front_voltage(double voltage) {
44 transfer_roller_front_voltage_ = voltage;
45 }
46 void set_transfer_roller_back_voltage(double voltage) {
47 transfer_roller_back_voltage_ = voltage;
Ravago Jones81e50632022-03-11 16:23:51 -080048 }
49
50 void set_fire_at_will(bool fire) { fire_ = fire; }
51
52 void SendSuperstructureGoal();
53 void ExtendFrontIntake();
54 void RetractFrontIntake();
55 void ExtendBackIntake();
56 void RetractBackIntake();
57 void SendStartingPosition(const Eigen::Vector3d &start);
58 void MaybeSendStartingPosition();
59
60 void SplineAuto();
61
62 void Replan();
63
64 double intake_front_goal_ = 0.0;
65 double intake_back_goal_ = 0.0;
66 double roller_front_voltage_ = 0.0;
67 double roller_back_voltage_ = 0.0;
Milind Upadhyayb1a74ea2022-03-09 20:34:35 -080068 double transfer_roller_front_voltage_ = 0.0;
69 double transfer_roller_back_voltage_ = 0.0;
Ravago Jones81e50632022-03-11 16:23:51 -080070 bool fire_ = false;
71
72 aos::Sender<frc971::control_loops::drivetrain::LocalizerControl>
73 localizer_control_sender_;
74 aos::Sender<y2022::control_loops::superstructure::Goal>
75 superstructure_goal_sender_;
76 aos::Fetcher<y2022::control_loops::superstructure::Status>
77 superstructure_status_fetcher_;
78 aos::Fetcher<aos::JoystickState> joystick_state_fetcher_;
79 aos::Fetcher<aos::RobotState> robot_state_fetcher_;
80
81 aos::TimerHandler *replan_timer_;
82 aos::TimerHandler *button_poll_;
83
84 std::optional<SplineHandle> test_spline_;
85
86 aos::Alliance alliance_ = aos::Alliance::kInvalid;
87 AutonomousSplines auto_splines_;
88 bool user_indicated_safe_to_reset_ = false;
89 bool sent_starting_position_ = false;
90
91 bool is_planned_ = false;
92
93 std::optional<Eigen::Vector3d> starting_position_;
milind-u086d7262022-01-19 20:44:18 -080094};
95
96} // namespace actors
97} // namespace y2022
98
99#endif // Y2022_ACTORS_AUTONOMOUS_ACTOR_H_