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