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