blob: 24df091942f2c066791c488637fad87980ac73d8 [file] [log] [blame]
Comran Morshede68e3732016-03-12 14:12:11 +00001#ifndef Y2016_ACTORS_AUTONOMOUS_ACTOR_H_
2#define Y2016_ACTORS_AUTONOMOUS_ACTOR_H_
3
Austin Schuhf2a50ba2016-12-24 16:16:26 -08004#include <chrono>
Comran Morshede68e3732016-03-12 14:12:11 +00005#include <memory>
6
Comran Morshede68e3732016-03-12 14:12:11 +00007#include "aos/common/actions/actions.h"
Austin Schuhf2a50ba2016-12-24 16:16:26 -08008#include "aos/common/actions/actor.h"
Philipp Schrader4bd29b12017-02-22 04:42:27 +00009#include "frc971/autonomous/base_autonomous_actor.h"
Comran Morshed435f1112016-03-12 14:20:45 +000010#include "frc971/control_loops/drivetrain/drivetrain.q.h"
11#include "frc971/control_loops/drivetrain/drivetrain_config.h"
Austin Schuhf2a50ba2016-12-24 16:16:26 -080012#include "y2016/actors/vision_align_actor.h"
Comran Morshede68e3732016-03-12 14:12:11 +000013
14namespace y2016 {
15namespace actors {
Comran Morshedb134e772016-03-16 21:05:05 +000016using ::frc971::ProfileParameters;
Comran Morshede68e3732016-03-12 14:12:11 +000017
Philipp Schrader4bd29b12017-02-22 04:42:27 +000018class AutonomousActor : public ::frc971::autonomous::BaseAutonomousActor {
Comran Morshede68e3732016-03-12 14:12:11 +000019 public:
Philipp Schrader4bd29b12017-02-22 04:42:27 +000020 explicit AutonomousActor(::frc971::autonomous::AutonomousActionQueueGroup *s);
Comran Morshede68e3732016-03-12 14:12:11 +000021
Philipp Schrader4bd29b12017-02-22 04:42:27 +000022 bool RunAction(
23 const ::frc971::autonomous::AutonomousActionParams &params) override;
Comran Morshed435f1112016-03-12 14:20:45 +000024
25 private:
Austin Schuhe4ec49c2016-04-24 19:07:15 -070026 void WaitForBallOrDriveDone();
27
28 void StealAndMoveOverBy(double distance);
Comran Morshed435f1112016-03-12 14:20:45 +000029
Comran Morshedb134e772016-03-16 21:05:05 +000030 // 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 Schuhf59b8ee2016-03-19 21:31:36 -070042 const ProfileParameters wrist_params,
Austin Schuh23b21802016-04-03 21:18:56 -070043 bool traverse_up, double roller_power);
Comran Morshedb134e772016-03-16 21:05:05 +000044 void WaitForSuperstructure();
Austin Schuhe4ec49c2016-04-24 19:07:15 -070045 void WaitForSuperstructureProfile();
Austin Schuh23b21802016-04-03 21:18:56 -070046 void WaitForSuperstructureLow();
47 void WaitForIntake();
48 bool IntakeDone();
Austin Schuhf59b8ee2016-03-19 21:31:36 -070049
Austin Schuh3e4a5272016-04-20 20:11:00 -070050 void FrontLongShot();
51 void FrontMiddleShot();
Austin Schuhf59b8ee2016-03-19 21:31:36 -070052 void BackLongShot();
Austin Schuh23b21802016-04-03 21:18:56 -070053 void BackLongShotTwoBall();
Austin Schuhe4ec49c2016-04-24 19:07:15 -070054 void BackLongShotTwoBallFinish();
Austin Schuh23b21802016-04-03 21:18:56 -070055 void BackLongShotLowBarTwoBall();
Austin Schuhf59b8ee2016-03-19 21:31:36 -070056 void BackMiddleShot();
Austin Schuh23b21802016-04-03 21:18:56 -070057 void WaitForBall();
Austin Schuhf59b8ee2016-03-19 21:31:36 -070058 void TuckArm(bool arm_down, bool traverse_down);
Austin Schuh23b21802016-04-03 21:18:56 -070059 void OpenShooter();
60 void CloseShooter();
61 void CloseIfBall();
62 bool SuperstructureProfileDone();
63 bool SuperstructureDone();
Austin Schuh3e4a5272016-04-20 20:11:00 -070064 void TippyDrive(double goal_distance, double tip_distance, double below,
65 double above);
Austin Schuhf59b8ee2016-03-19 21:31:36 -070066
Austin Schuh3e4a5272016-04-20 20:11:00 -070067 void DoFullShot();
Austin Schuhf59b8ee2016-03-19 21:31:36 -070068 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 Schuhf2a50ba2016-12-24 16:16:26 -080082 void WaitForAlignedWithVision(::std::chrono::nanoseconds align_duration);
Austin Schuhf59b8ee2016-03-19 21:31:36 -070083
Austin Schuh3e4a5272016-04-20 20:11:00 -070084 void TwoBallAuto();
85
Austin Schuhf59b8ee2016-03-19 21:31:36 -070086 ::std::unique_ptr<actors::VisionAlignAction> vision_action_;
Comran Morshede68e3732016-03-12 14:12:11 +000087};
88
Comran Morshede68e3732016-03-12 14:12:11 +000089} // namespace actors
90} // namespace y2016
91
92#endif // Y2016_ACTORS_AUTONOMOUS_ACTOR_H_