Comran Morshed | e68e373 | 2016-03-12 14:12:11 +0000 | [diff] [blame] | 1 | #ifndef Y2016_ACTORS_AUTONOMOUS_ACTOR_H_ |
| 2 | #define Y2016_ACTORS_AUTONOMOUS_ACTOR_H_ |
| 3 | |
Austin Schuh | f2a50ba | 2016-12-24 16:16:26 -0800 | [diff] [blame] | 4 | #include <chrono> |
Comran Morshed | e68e373 | 2016-03-12 14:12:11 +0000 | [diff] [blame] | 5 | #include <memory> |
| 6 | |
John Park | 33858a3 | 2018-09-28 23:05:48 -0700 | [diff] [blame] | 7 | #include "aos/actions/actions.h" |
| 8 | #include "aos/actions/actor.h" |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame^] | 9 | #include "aos/events/event_loop.h" |
Philipp Schrader | 4bd29b1 | 2017-02-22 04:42:27 +0000 | [diff] [blame] | 10 | #include "frc971/autonomous/base_autonomous_actor.h" |
Comran Morshed | 435f111 | 2016-03-12 14:20:45 +0000 | [diff] [blame] | 11 | #include "frc971/control_loops/drivetrain/drivetrain_config.h" |
Austin Schuh | f2a50ba | 2016-12-24 16:16:26 -0800 | [diff] [blame] | 12 | #include "y2016/actors/vision_align_actor.h" |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame^] | 13 | #include "y2016/control_loops/shooter/shooter_goal_generated.h" |
| 14 | #include "y2016/control_loops/shooter/shooter_status_generated.h" |
| 15 | #include "y2016/control_loops/superstructure/superstructure_goal_generated.h" |
| 16 | #include "y2016/control_loops/superstructure/superstructure_status_generated.h" |
| 17 | #include "y2016/queues/ball_detector_generated.h" |
Comran Morshed | e68e373 | 2016-03-12 14:12:11 +0000 | [diff] [blame] | 18 | |
| 19 | namespace y2016 { |
| 20 | namespace actors { |
| 21 | |
Philipp Schrader | 4bd29b1 | 2017-02-22 04:42:27 +0000 | [diff] [blame] | 22 | class AutonomousActor : public ::frc971::autonomous::BaseAutonomousActor { |
Comran Morshed | e68e373 | 2016-03-12 14:12:11 +0000 | [diff] [blame] | 23 | public: |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 24 | explicit AutonomousActor(::aos::EventLoop *event_loop); |
Comran Morshed | e68e373 | 2016-03-12 14:12:11 +0000 | [diff] [blame] | 25 | |
Philipp Schrader | 4bd29b1 | 2017-02-22 04:42:27 +0000 | [diff] [blame] | 26 | bool RunAction( |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame^] | 27 | const ::frc971::autonomous::AutonomousActionParams *params) override; |
Comran Morshed | 435f111 | 2016-03-12 14:20:45 +0000 | [diff] [blame] | 28 | |
| 29 | private: |
Austin Schuh | e4ec49c | 2016-04-24 19:07:15 -0700 | [diff] [blame] | 30 | void WaitForBallOrDriveDone(); |
| 31 | |
| 32 | void StealAndMoveOverBy(double distance); |
Comran Morshed | 435f111 | 2016-03-12 14:20:45 +0000 | [diff] [blame] | 33 | |
Comran Morshed | b134e77 | 2016-03-16 21:05:05 +0000 | [diff] [blame] | 34 | // Internal struct holding superstructure goals sent by autonomous to the |
| 35 | // loop. |
| 36 | struct SuperstructureGoal { |
| 37 | double intake; |
| 38 | double shoulder; |
| 39 | double wrist; |
| 40 | }; |
| 41 | SuperstructureGoal superstructure_goal_; |
| 42 | |
| 43 | void MoveSuperstructure(double intake, double shoulder, double wrist, |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame^] | 44 | const frc971::ProfileParametersT intake_params, |
| 45 | const frc971::ProfileParametersT shoulder_params, |
| 46 | const frc971::ProfileParametersT wrist_params, |
Austin Schuh | 23b2180 | 2016-04-03 21:18:56 -0700 | [diff] [blame] | 47 | bool traverse_up, double roller_power); |
Comran Morshed | b134e77 | 2016-03-16 21:05:05 +0000 | [diff] [blame] | 48 | void WaitForSuperstructure(); |
Austin Schuh | e4ec49c | 2016-04-24 19:07:15 -0700 | [diff] [blame] | 49 | void WaitForSuperstructureProfile(); |
Austin Schuh | 23b2180 | 2016-04-03 21:18:56 -0700 | [diff] [blame] | 50 | void WaitForSuperstructureLow(); |
| 51 | void WaitForIntake(); |
| 52 | bool IntakeDone(); |
Austin Schuh | f59b8ee | 2016-03-19 21:31:36 -0700 | [diff] [blame] | 53 | |
Austin Schuh | 3e4a527 | 2016-04-20 20:11:00 -0700 | [diff] [blame] | 54 | void FrontLongShot(); |
| 55 | void FrontMiddleShot(); |
Austin Schuh | f59b8ee | 2016-03-19 21:31:36 -0700 | [diff] [blame] | 56 | void BackLongShot(); |
Austin Schuh | 23b2180 | 2016-04-03 21:18:56 -0700 | [diff] [blame] | 57 | void BackLongShotTwoBall(); |
Austin Schuh | e4ec49c | 2016-04-24 19:07:15 -0700 | [diff] [blame] | 58 | void BackLongShotTwoBallFinish(); |
Austin Schuh | 23b2180 | 2016-04-03 21:18:56 -0700 | [diff] [blame] | 59 | void BackLongShotLowBarTwoBall(); |
Austin Schuh | f59b8ee | 2016-03-19 21:31:36 -0700 | [diff] [blame] | 60 | void BackMiddleShot(); |
| 61 | void TuckArm(bool arm_down, bool traverse_down); |
Austin Schuh | 23b2180 | 2016-04-03 21:18:56 -0700 | [diff] [blame] | 62 | void OpenShooter(); |
| 63 | void CloseShooter(); |
| 64 | void CloseIfBall(); |
| 65 | bool SuperstructureProfileDone(); |
| 66 | bool SuperstructureDone(); |
Austin Schuh | 3e4a527 | 2016-04-20 20:11:00 -0700 | [diff] [blame] | 67 | void TippyDrive(double goal_distance, double tip_distance, double below, |
| 68 | double above); |
Austin Schuh | f59b8ee | 2016-03-19 21:31:36 -0700 | [diff] [blame] | 69 | |
Austin Schuh | 3e4a527 | 2016-04-20 20:11:00 -0700 | [diff] [blame] | 70 | void DoFullShot(); |
Austin Schuh | f59b8ee | 2016-03-19 21:31:36 -0700 | [diff] [blame] | 71 | void LowBarDrive(); |
| 72 | // Drive to the middle spot over the middle position. Designed for the rock |
| 73 | // wall, rough terain, or ramparts. |
| 74 | void MiddleDrive(); |
| 75 | |
| 76 | void OneFromMiddleDrive(bool left); |
| 77 | void TwoFromMiddleDrive(); |
| 78 | |
| 79 | double shooter_speed_ = 0.0; |
| 80 | void SetShooterSpeed(double speed); |
| 81 | void WaitForShooterSpeed(); |
| 82 | void Shoot(); |
| 83 | |
| 84 | void AlignWithVisionGoal(); |
Austin Schuh | f2a50ba | 2016-12-24 16:16:26 -0800 | [diff] [blame] | 85 | void WaitForAlignedWithVision(::std::chrono::nanoseconds align_duration); |
Austin Schuh | f59b8ee | 2016-03-19 21:31:36 -0700 | [diff] [blame] | 86 | |
Austin Schuh | 3e4a527 | 2016-04-20 20:11:00 -0700 | [diff] [blame] | 87 | void TwoBallAuto(); |
| 88 | |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 89 | actors::VisionAlignActor::Factory vision_align_actor_factory_; |
| 90 | ::std::unique_ptr<::aos::common::actions::Action> vision_action_; |
Austin Schuh | 28bde30 | 2019-05-26 22:24:33 -0700 | [diff] [blame] | 91 | |
| 92 | ::aos::Fetcher<::y2016::vision::VisionStatus> vision_status_fetcher_; |
Austin Schuh | 4b652c9 | 2019-05-27 13:22:27 -0700 | [diff] [blame] | 93 | ::aos::Fetcher<::y2016::sensors::BallDetector> ball_detector_fetcher_; |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame^] | 94 | ::aos::Sender<::y2016::control_loops::shooter::Goal> shooter_goal_sender_; |
| 95 | ::aos::Fetcher<::y2016::control_loops::shooter::Status> |
Austin Schuh | ae023fb | 2019-06-29 17:11:45 -0700 | [diff] [blame] | 96 | shooter_status_fetcher_; |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame^] | 97 | ::aos::Fetcher<::y2016::control_loops::superstructure::Status> |
Austin Schuh | 9481d0d | 2019-06-29 21:56:17 -0700 | [diff] [blame] | 98 | superstructure_status_fetcher_; |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame^] | 99 | ::aos::Sender<::y2016::control_loops::superstructure::Goal> |
Austin Schuh | 9481d0d | 2019-06-29 21:56:17 -0700 | [diff] [blame] | 100 | superstructure_goal_sender_; |
Comran Morshed | e68e373 | 2016-03-12 14:12:11 +0000 | [diff] [blame] | 101 | }; |
| 102 | |
Comran Morshed | e68e373 | 2016-03-12 14:12:11 +0000 | [diff] [blame] | 103 | } // namespace actors |
| 104 | } // namespace y2016 |
| 105 | |
| 106 | #endif // Y2016_ACTORS_AUTONOMOUS_ACTOR_H_ |