Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 1 | #ifndef y2020_ACTORS_AUTONOMOUS_ACTOR_H_ |
| 2 | #define y2020_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" |
James Kuszmaul | 5f6d1d4 | 2020-03-01 18:10:07 -0800 | [diff] [blame] | 9 | #include "frc971/control_loops/drivetrain/localizer_generated.h" |
Ravago Jones | c2a0802 | 2021-02-06 17:40:54 -0800 | [diff] [blame] | 10 | #include "y2020/actors/auto_splines.h" |
kyle | 96c406e | 2021-02-27 14:07:22 -0800 | [diff] [blame] | 11 | #include "y2020/vision/galactic_search_path_generated.h" |
Sabina Leaver | a0b43b4 | 2021-03-03 20:30:04 -0800 | [diff] [blame] | 12 | #include "y2020/control_loops/superstructure/superstructure_goal_generated.h" |
| 13 | #include "y2020/control_loops/superstructure/superstructure_status_generated.h" |
Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 14 | |
| 15 | namespace y2020 { |
| 16 | namespace actors { |
| 17 | |
James Kuszmaul | 99af8b5 | 2021-03-28 10:50:15 -0700 | [diff] [blame] | 18 | using frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystemGoal; |
Sabina Leaver | a0b43b4 | 2021-03-03 20:30:04 -0800 | [diff] [blame] | 19 | |
| 20 | namespace superstructure = y2020::control_loops::superstructure; |
| 21 | |
James Kuszmaul | 99af8b5 | 2021-03-28 10:50:15 -0700 | [diff] [blame] | 22 | class AutonomousActor : public frc971::autonomous::BaseAutonomousActor { |
Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 23 | public: |
James Kuszmaul | 99af8b5 | 2021-03-28 10:50:15 -0700 | [diff] [blame] | 24 | explicit AutonomousActor(aos::EventLoop *event_loop); |
Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 25 | |
| 26 | bool RunAction( |
James Kuszmaul | 99af8b5 | 2021-03-28 10:50:15 -0700 | [diff] [blame] | 27 | const frc971::autonomous::AutonomousActionParams *params) override; |
Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 28 | |
| 29 | private: |
| 30 | void Reset(); |
Sabina Leaver | a0b43b4 | 2021-03-03 20:30:04 -0800 | [diff] [blame] | 31 | |
| 32 | void set_intake_goal(double intake_goal) { intake_goal_ = intake_goal; } |
| 33 | void set_roller_voltage(double roller_voltage) { |
| 34 | roller_voltage_ = roller_voltage; |
| 35 | } |
Sabina Leaver | 8302e3c | 2021-03-20 16:36:05 -0700 | [diff] [blame] | 36 | |
Sabina Leaver | a0b43b4 | 2021-03-03 20:30:04 -0800 | [diff] [blame] | 37 | void SendSuperstructureGoal(); |
milind upadhyay | 5e589d7 | 2021-03-27 13:47:18 -0700 | [diff] [blame] | 38 | void RetractIntake(); |
milind upadhyay | 47a0ab3 | 2020-11-25 19:34:41 -0800 | [diff] [blame] | 39 | void SplineAuto(); |
James Kuszmaul | 99af8b5 | 2021-03-28 10:50:15 -0700 | [diff] [blame] | 40 | void SendStartingPosition(const Eigen::Vector3d &start); |
kyle | 96c406e | 2021-02-27 14:07:22 -0800 | [diff] [blame] | 41 | void GalacticSearch(); |
Ravago Jones | 9c326f5 | 2021-03-20 15:00:16 -0700 | [diff] [blame] | 42 | void AutoNavBounce(); |
| 43 | void AutoNavBarrel(); |
| 44 | void AutoNavSlalom(); |
milind upadhyay | 47a0ab3 | 2020-11-25 19:34:41 -0800 | [diff] [blame] | 45 | bool DriveFwd(); |
James Kuszmaul | 5f6d1d4 | 2020-03-01 18:10:07 -0800 | [diff] [blame] | 46 | |
James Kuszmaul | 99af8b5 | 2021-03-28 10:50:15 -0700 | [diff] [blame] | 47 | void Replan(); |
| 48 | |
Sabina Leaver | a0b43b4 | 2021-03-03 20:30:04 -0800 | [diff] [blame] | 49 | double intake_goal_ = 0.0; |
| 50 | double roller_voltage_ = 0.0; |
| 51 | const float kRollerSpeedCompensation = 2.0; |
| 52 | |
James Kuszmaul | 99af8b5 | 2021-03-28 10:50:15 -0700 | [diff] [blame] | 53 | aos::Sender<frc971::control_loops::drivetrain::LocalizerControl> |
James Kuszmaul | 5f6d1d4 | 2020-03-01 18:10:07 -0800 | [diff] [blame] | 54 | localizer_control_sender_; |
James Kuszmaul | 99af8b5 | 2021-03-28 10:50:15 -0700 | [diff] [blame] | 55 | aos::Sender<y2020::control_loops::superstructure::Goal> |
Sabina Leaver | a0b43b4 | 2021-03-03 20:30:04 -0800 | [diff] [blame] | 56 | superstructure_goal_sender_; |
James Kuszmaul | ddd2ba6 | 2020-03-08 22:17:13 -0700 | [diff] [blame] | 57 | aos::Fetcher<aos::JoystickState> joystick_state_fetcher_; |
kyle | 96c406e | 2021-02-27 14:07:22 -0800 | [diff] [blame] | 58 | aos::Fetcher<y2020::vision::GalacticSearchPath> path_fetcher_; |
James Kuszmaul | 99af8b5 | 2021-03-28 10:50:15 -0700 | [diff] [blame] | 59 | |
| 60 | aos::TimerHandler *replan_timer_; |
| 61 | |
| 62 | std::optional<std::array<SplineHandle, 4>> bounce_splines_; |
| 63 | |
| 64 | struct GalacticSearchSplines { |
| 65 | SplineHandle red_a; |
| 66 | SplineHandle red_b; |
| 67 | SplineHandle blue_a; |
| 68 | SplineHandle blue_b; |
| 69 | }; |
| 70 | std::optional<GalacticSearchSplines> galactic_search_splines_; |
| 71 | |
| 72 | std::optional<SplineHandle> barrel_spline_; |
| 73 | std::optional<SplineHandle> slalom_spline_; |
| 74 | std::optional<SplineHandle> test_spline_; |
| 75 | |
James Kuszmaul | ddd2ba6 | 2020-03-08 22:17:13 -0700 | [diff] [blame] | 76 | aos::Alliance alliance_ = aos::Alliance::kInvalid; |
Ravago Jones | c2a0802 | 2021-02-06 17:40:54 -0800 | [diff] [blame] | 77 | AutonomousSplines auto_splines_; |
Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 78 | }; |
| 79 | |
| 80 | } // namespace actors |
| 81 | } // namespace y2020 |
| 82 | |
| 83 | #endif // y2020_ACTORS_AUTONOMOUS_ACTOR_H_ |