From 9e14cfd2463d2a734314a59dd57e2270eb40b094 Mon Sep 17 00:00:00 2001 From: Aidan Ferguson Date: Sat, 13 Feb 2016 16:40:07 -0500 Subject: [PATCH] enum ShooterState, starts of associated switch, etc. --- src/Robot.cpp | 6 +++++- src/Shooter.h | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 61 insertions(+), 2 deletions(-) diff --git a/src/Robot.cpp b/src/Robot.cpp index cab8ba8..86b0612 100644 --- a/src/Robot.cpp +++ b/src/Robot.cpp @@ -35,7 +35,7 @@ public: shooter( // initialize Shooter object. &shooter1, &shooter2, &launch_spinny), driver_stick(0), // right stick (operator) - operator_stick(1) // left stick (driver) + operator_stick(1) // left stick (driver) { } @@ -117,6 +117,10 @@ private: //std::cout << "Ramp position: "<< launch_spinny.GetEncPosition() << std::endl; drive.ArcadeDrive(&driver_stick, true); + if (operator_stick.GetRawButton(TRIGGER)) + { + + } //bool rampDoing = false; // This is shit code for testing. Replace it with real code. if(!ramping && operator_stick.GetRawButton(RAMP_RAISE)) diff --git a/src/Shooter.h b/src/Shooter.h index 2ec7e5f..aeeab87 100644 --- a/src/Shooter.h +++ b/src/Shooter.h @@ -9,7 +9,9 @@ #define SRC_SHOOTER_H_ #define PICKUP_POWER 0.5 +#define LAUNCH_POWER 1 #define SPINUP_TIME 1.5 // seconds. +#define LAUNCH_TIME 0.5 class Shooter { @@ -20,13 +22,24 @@ public: * s2 is also for the pickup-mechanism and can be controlled independently. * */ - Shooter(CANTalon *s1, CANTalon *s2, CANTalon *r) + enum ShooterState + { + READY, + ON_FIRE, + SPINNINGUP, + LAUNCH, + LAUNCHING, + RESETTING + }; + + Shooter(CANTalon *s1, CANTalon *s2, CANTalon *r) { // shooterDrive = new RobotDrive(s1, s2); launcher = s1; pickup = s2; launch_spinny = r; ready = true; + state = READY; } /** @@ -78,6 +91,47 @@ public: the launch-spinny should be STOPPED. Start a Timer object counting When... too hard to write.. I emailed you a flow chart. */ + switch (state) + { + case READY: + { + state = SPINNINGUP; + launch_spinny->Set(-1); + launcher->Set(PICKUP_POWER); + pickup->Set(PICKUP_POWER); + shotClock.Reset(); + shotClock.Start(); + break; + } + case SPINNINGUP: + { + if (shotClock.Get() > SPINUP_TIME) + { + state = LAUNCH; + shotClock.Reset(); + shotClock.Start(); + } else + { + std::cout << "*Goku noises*\n"; + } + break; + } + case LAUNCH: + { + launch_spinny->Set(1); + state = LAUNCHING; + break; + } + case LAUNCHING: + { + if (shotClock.Get() > LAUNCH_TIME) + { + + state = RESETTING; + } + break; + } + } } @@ -109,6 +163,7 @@ private: CANTalon *launcher; CANTalon *pickup; CANTalon *launch_spinny; + ShooterState state; Timer shotClock; bool ready;