enum ShooterState, starts of associated switch, etc.
This commit is contained in:
parent
71e2ec4eba
commit
e6934c9117
@ -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,6 +22,16 @@ 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.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
enum ShooterState
|
||||||
|
{
|
||||||
|
READY,
|
||||||
|
ON_FIRE,
|
||||||
|
SPINNINGUP,
|
||||||
|
LAUNCH,
|
||||||
|
LAUNCHING,
|
||||||
|
RESETTING
|
||||||
|
};
|
||||||
|
|
||||||
Shooter(CANTalon *s1, CANTalon *s2, CANTalon *r)
|
Shooter(CANTalon *s1, CANTalon *s2, CANTalon *r)
|
||||||
{
|
{
|
||||||
// shooterDrive = new RobotDrive(s1, s2);
|
// shooterDrive = new RobotDrive(s1, s2);
|
||||||
@ -27,6 +39,7 @@ public:
|
|||||||
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