Filip Kujawa | ef68715 | 2023-11-14 22:11:32 -0800 | [diff] [blame^] | 1 | #ifndef Y2023_BOT3_AUTONOMOUS_AUTONOMOUS_ACTOR_H_ |
| 2 | #define Y2023_BOT3_AUTONOMOUS_AUTONOMOUS_ACTOR_H_ |
Ariv Diggi | 0af59c0 | 2023-10-07 13:15:39 -0700 | [diff] [blame] | 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 | |
Filip Kujawa | ef68715 | 2023-11-14 22:11:32 -0800 | [diff] [blame^] | 14 | // TODO<FILIP>: Add NEUTRAL pivot pose. |
| 15 | |
Ariv Diggi | 0af59c0 | 2023-10-07 13:15:39 -0700 | [diff] [blame] | 16 | namespace y2023_bot3 { |
| 17 | namespace autonomous { |
| 18 | |
| 19 | class 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 Kujawa | ef68715 | 2023-11-14 22:11:32 -0800 | [diff] [blame^] | 29 | 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 Diggi | 0af59c0 | 2023-10-07 13:15:39 -0700 | [diff] [blame] | 39 | void SendSuperstructureGoal(); |
| 40 | |
Filip Kujawa | ef68715 | 2023-11-14 22:11:32 -0800 | [diff] [blame^] | 41 | [[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 Diggi | 0af59c0 | 2023-10-07 13:15:39 -0700 | [diff] [blame] | 53 | void Reset(); |
| 54 | |
| 55 | void SendStartingPosition(const Eigen::Vector3d &start); |
| 56 | void MaybeSendStartingPosition(); |
| 57 | void Replan(); |
Filip Kujawa | ef68715 | 2023-11-14 22:11:32 -0800 | [diff] [blame^] | 58 | void ChargedUp(); |
| 59 | void ChargedUpMiddle(); |
| 60 | void OnePieceMiddle(); |
Ariv Diggi | 0af59c0 | 2023-10-07 13:15:39 -0700 | [diff] [blame] | 61 | |
| 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 Kujawa | ef68715 | 2023-11-14 22:11:32 -0800 | [diff] [blame^] | 81 | control_loops::superstructure::PivotGoal pivot_goal_; |
| 82 | control_loops::superstructure::RollerGoal roller_goal_; |
| 83 | |
Ariv Diggi | 0af59c0 | 2023-10-07 13:15:39 -0700 | [diff] [blame] | 84 | 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 Kujawa | ef68715 | 2023-11-14 22:11:32 -0800 | [diff] [blame^] | 89 | std::optional<std::array<SplineHandle, 4>> charged_up_splines_; |
| 90 | std::optional<std::array<SplineHandle, 1>> charged_up_middle_splines_; |
Ariv Diggi | 0af59c0 | 2023-10-07 13:15:39 -0700 | [diff] [blame] | 91 | }; |
| 92 | |
| 93 | } // namespace autonomous |
| 94 | } // namespace y2023_bot3 |
| 95 | |
| 96 | #endif // Y2023_AUTONOMOUS_AUTONOMOUS_ACTOR_H_ |