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