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