enum ShooterState, starts of associated switch, etc.
This commit is contained in:
parent
21138d6bc6
commit
9e14cfd246
@ -35,7 +35,7 @@ public:
|
|||||||
shooter( // initialize Shooter object.
|
shooter( // initialize Shooter object.
|
||||||
&shooter1, &shooter2, &launch_spinny),
|
&shooter1, &shooter2, &launch_spinny),
|
||||||
driver_stick(0), // right stick (operator)
|
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;
|
//std::cout << "Ramp position: "<< launch_spinny.GetEncPosition() << std::endl;
|
||||||
drive.ArcadeDrive(&driver_stick, true);
|
drive.ArcadeDrive(&driver_stick, true);
|
||||||
|
|
||||||
|
if (operator_stick.GetRawButton(TRIGGER))
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
//bool rampDoing = false;
|
//bool rampDoing = false;
|
||||||
// This is shit code for testing. Replace it with real code.
|
// This is shit code for testing. Replace it with real code.
|
||||||
if(!ramping && operator_stick.GetRawButton(RAMP_RAISE))
|
if(!ramping && operator_stick.GetRawButton(RAMP_RAISE))
|
||||||
|
@ -9,7 +9,9 @@
|
|||||||
#define SRC_SHOOTER_H_
|
#define SRC_SHOOTER_H_
|
||||||
|
|
||||||
#define PICKUP_POWER 0.5
|
#define PICKUP_POWER 0.5
|
||||||
|
#define LAUNCH_POWER 1
|
||||||
#define SPINUP_TIME 1.5 // seconds.
|
#define SPINUP_TIME 1.5 // seconds.
|
||||||
|
#define LAUNCH_TIME 0.5
|
||||||
|
|
||||||
class Shooter
|
class Shooter
|
||||||
{
|
{
|
||||||
@ -20,13 +22,24 @@ public:
|
|||||||
* s2 is also for the pickup-mechanism and can be controlled independently.
|
* 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);
|
// shooterDrive = new RobotDrive(s1, s2);
|
||||||
launcher = s1;
|
launcher = s1;
|
||||||
pickup = s2;
|
pickup = s2;
|
||||||
launch_spinny = r;
|
launch_spinny = r;
|
||||||
ready = true;
|
ready = true;
|
||||||
|
state = READY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -78,6 +91,47 @@ public:
|
|||||||
the launch-spinny should be STOPPED. Start a Timer object counting
|
the launch-spinny should be STOPPED. Start a Timer object counting
|
||||||
When... too hard to write.. I emailed you a flow chart.
|
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 *launcher;
|
||||||
CANTalon *pickup;
|
CANTalon *pickup;
|
||||||
CANTalon *launch_spinny;
|
CANTalon *launch_spinny;
|
||||||
|
ShooterState state;
|
||||||
|
|
||||||
Timer shotClock;
|
Timer shotClock;
|
||||||
bool ready;
|
bool ready;
|
||||||
|
Reference in New Issue
Block a user