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