enum ShooterState, starts of associated switch, etc.
This commit is contained in:
parent
71e2ec4eba
commit
e6934c9117
@ -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))
|
||||
|
@ -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,6 +22,16 @@ public:
|
||||
* s2 is also for the pickup-mechanism and can be controlled independently.
|
||||
*
|
||||
*/
|
||||
enum ShooterState
|
||||
{
|
||||
READY,
|
||||
ON_FIRE,
|
||||
SPINNINGUP,
|
||||
LAUNCH,
|
||||
LAUNCHING,
|
||||
RESETTING
|
||||
};
|
||||
|
||||
Shooter(CANTalon *s1, CANTalon *s2, CANTalon *r)
|
||||
{
|
||||
// shooterDrive = new RobotDrive(s1, s2);
|
||||
@ -27,6 +39,7 @@ public:
|
||||
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;
|
||||
|
Reference in New Issue
Block a user