enum ShooterState, starts of associated switch, etc.

This commit is contained in:
Aidan Ferguson 2016-02-13 16:40:07 -05:00
parent 21138d6bc6
commit 9e14cfd246
2 changed files with 61 additions and 2 deletions

View File

@ -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))

View File

@ -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;