Maxwell Henderson | 64f3745 | 2023-03-11 13:39:21 -0800 | [diff] [blame] | 1 | #ifndef Y2023_AUTONOMOUS_AUTONOMOUS_ACTOR_H_ |
| 2 | #define Y2023_AUTONOMOUS_AUTONOMOUS_ACTOR_H_ |
Maxwell Henderson | ad31234 | 2023-01-10 12:07:47 -0800 | [diff] [blame] | 3 | |
| 4 | #include "aos/actions/actions.h" |
| 5 | #include "aos/actions/actor.h" |
Maxwell Henderson | 12b07b9 | 2024-01-08 20:17:25 -0800 | [diff] [blame] | 6 | #include "frc971/autonomous/user_button_localized_autonomous_actor.h" |
Maxwell Henderson | ad31234 | 2023-01-10 12:07:47 -0800 | [diff] [blame] | 7 | #include "frc971/control_loops/control_loops_generated.h" |
| 8 | #include "frc971/control_loops/drivetrain/drivetrain_config.h" |
James Kuszmaul | 713c5ce | 2023-03-04 18:23:24 -0800 | [diff] [blame] | 9 | #include "frc971/control_loops/drivetrain/localizer_generated.h" |
| 10 | #include "y2023/autonomous/auto_splines.h" |
Maxwell Henderson | 64f3745 | 2023-03-11 13:39:21 -0800 | [diff] [blame] | 11 | #include "y2023/control_loops/superstructure/superstructure_goal_generated.h" |
| 12 | #include "y2023/control_loops/superstructure/superstructure_status_generated.h" |
Maxwell Henderson | ad31234 | 2023-01-10 12:07:47 -0800 | [diff] [blame] | 13 | |
Stephan Pleines | d99b1ee | 2024-02-02 20:56:44 -0800 | [diff] [blame^] | 14 | namespace y2023::autonomous { |
Maxwell Henderson | ad31234 | 2023-01-10 12:07:47 -0800 | [diff] [blame] | 15 | |
Maxwell Henderson | 12b07b9 | 2024-01-08 20:17:25 -0800 | [diff] [blame] | 16 | class AutonomousActor |
| 17 | : public ::frc971::autonomous::UserButtonLocalizedAutonomousActor { |
Maxwell Henderson | ad31234 | 2023-01-10 12:07:47 -0800 | [diff] [blame] | 18 | public: |
| 19 | explicit AutonomousActor(::aos::EventLoop *event_loop); |
| 20 | |
Maxwell Henderson | ad31234 | 2023-01-10 12:07:47 -0800 | [diff] [blame] | 21 | private: |
Maxwell Henderson | 64f3745 | 2023-03-11 13:39:21 -0800 | [diff] [blame] | 22 | void set_arm_goal_position(uint32_t requested_arm_goal_position) { |
| 23 | arm_goal_position_ = requested_arm_goal_position; |
| 24 | } |
| 25 | |
| 26 | void set_roller_goal( |
| 27 | control_loops::superstructure::RollerGoal requested_roller_goal) { |
| 28 | roller_goal_ = requested_roller_goal; |
| 29 | } |
| 30 | |
| 31 | void set_wrist_goal(double requested_wrist_goal) { |
| 32 | wrist_goal_ = requested_wrist_goal; |
| 33 | } |
| 34 | |
| 35 | void set_preloaded(bool preloaded) { preloaded_ = preloaded; } |
| 36 | |
| 37 | void SendSuperstructureGoal(); |
| 38 | void HighCubeScore(); |
| 39 | void MidCubeScore(); |
| 40 | void MidConeScore(); |
Maxwell Henderson | 3d0beaf | 2023-03-23 11:32:44 -0700 | [diff] [blame] | 41 | void Neutral(); |
Maxwell Henderson | 64f3745 | 2023-03-11 13:39:21 -0800 | [diff] [blame] | 42 | void PickupCube(); |
| 43 | void Spit(); |
Maxwell Henderson | 3d0beaf | 2023-03-23 11:32:44 -0700 | [diff] [blame] | 44 | void StopSpitting(); |
Maxwell Henderson | 64f3745 | 2023-03-11 13:39:21 -0800 | [diff] [blame] | 45 | void IntakeCube(); |
Maxwell Henderson | 3d0beaf | 2023-03-23 11:32:44 -0700 | [diff] [blame] | 46 | void Balance(); |
Maxwell Henderson | 64f3745 | 2023-03-11 13:39:21 -0800 | [diff] [blame] | 47 | |
Maxwell Henderson | 12b07b9 | 2024-01-08 20:17:25 -0800 | [diff] [blame] | 48 | bool Run(const ::frc971::autonomous::AutonomousActionParams *params) override; |
| 49 | void Replan() override; |
| 50 | void SendStartingPosition(const Eigen::Vector3d &start) override; |
| 51 | void Reset() override; |
| 52 | |
Maxwell Henderson | 3d0beaf | 2023-03-23 11:32:44 -0700 | [diff] [blame] | 53 | [[nodiscard]] bool WaitForArmGoal(double distance_to_go = 0.01); |
Maxwell Henderson | 64f3745 | 2023-03-11 13:39:21 -0800 | [diff] [blame] | 54 | |
| 55 | [[nodiscard]] bool WaitForPreloaded(); |
| 56 | |
James Kuszmaul | 713c5ce | 2023-03-04 18:23:24 -0800 | [diff] [blame] | 57 | void SplineAuto(); |
Maxwell Henderson | 64f3745 | 2023-03-11 13:39:21 -0800 | [diff] [blame] | 58 | void ChargedUp(); |
Maxwell Henderson | 2537883 | 2023-04-07 14:37:41 -0700 | [diff] [blame] | 59 | void ChargedUpCableSide(); |
James Kuszmaul | 713c5ce | 2023-03-04 18:23:24 -0800 | [diff] [blame] | 60 | |
| 61 | aos::Sender<frc971::control_loops::drivetrain::LocalizerControl> |
| 62 | localizer_control_sender_; |
James Kuszmaul | 713c5ce | 2023-03-04 18:23:24 -0800 | [diff] [blame] | 63 | |
Maxwell Henderson | 3d0beaf | 2023-03-23 11:32:44 -0700 | [diff] [blame] | 64 | double wrist_goal_; |
Maxwell Henderson | 64f3745 | 2023-03-11 13:39:21 -0800 | [diff] [blame] | 65 | control_loops::superstructure::RollerGoal roller_goal_ = |
| 66 | control_loops::superstructure::RollerGoal::IDLE; |
| 67 | |
James Kuszmaul | 713c5ce | 2023-03-04 18:23:24 -0800 | [diff] [blame] | 68 | AutonomousSplines auto_splines_; |
Maxwell Henderson | 64f3745 | 2023-03-11 13:39:21 -0800 | [diff] [blame] | 69 | |
| 70 | uint32_t arm_goal_position_; |
| 71 | bool preloaded_ = false; |
| 72 | |
| 73 | aos::Sender<control_loops::superstructure::Goal> superstructure_goal_sender_; |
| 74 | aos::Fetcher<y2023::control_loops::superstructure::Status> |
| 75 | superstructure_status_fetcher_; |
| 76 | |
| 77 | std::optional<SplineHandle> test_spline_; |
Maxwell Henderson | 3d0beaf | 2023-03-23 11:32:44 -0700 | [diff] [blame] | 78 | std::optional<std::array<SplineHandle, 4>> charged_up_splines_; |
Maxwell Henderson | 2537883 | 2023-04-07 14:37:41 -0700 | [diff] [blame] | 79 | std::optional<std::array<SplineHandle, 4>> charged_up_cable_splines_; |
Maxwell Henderson | 64f3745 | 2023-03-11 13:39:21 -0800 | [diff] [blame] | 80 | |
| 81 | // List of arm angles from arm::PointsList |
| 82 | const ::std::vector<::Eigen::Matrix<double, 3, 1>> points_; |
Maxwell Henderson | ad31234 | 2023-01-10 12:07:47 -0800 | [diff] [blame] | 83 | }; |
| 84 | |
Stephan Pleines | d99b1ee | 2024-02-02 20:56:44 -0800 | [diff] [blame^] | 85 | } // namespace y2023::autonomous |
Maxwell Henderson | ad31234 | 2023-01-10 12:07:47 -0800 | [diff] [blame] | 86 | |
Maxwell Henderson | 64f3745 | 2023-03-11 13:39:21 -0800 | [diff] [blame] | 87 | #endif // Y2023_AUTONOMOUS_AUTONOMOUS_ACTOR_H_ |