Added comments and info for the shooter logic. I emailed you a flow chart also...

This commit is contained in:
Jason 2016-02-11 21:24:32 -05:00
parent b4bbdf092b
commit 5211275da5
2 changed files with 57 additions and 8 deletions

View File

@ -62,6 +62,7 @@ private:
left_drive.SetInverted(true); left_drive.SetInverted(true);
right_drive.SetInverted(true); right_drive.SetInverted(true);
inverting = false; inverting = false;
pickupRunning = false;
shooter_power = 0; shooter_power = 0;
} }
@ -156,7 +157,24 @@ private:
{ {
inverting = false; inverting = false;
} }
/*
* Unlike the previous actions, this method does need to be called every itteration of
* TeleopPeriodic. This is because the logic running this operation needs to be checked
* Every time the method is called. This cannot be a loop in the Shoot method because
* that would lock the robot every time the trigger is hit.
*/
if(operator_stick.GetRawButton(TRIGGER))
{
shooter.Shoot();
}
else
{
shooter.StopShooter();
}
// This code will become obsolete after the Shooter logic is complete.
float opThrottle = SaneThrottle(operator_stick.GetThrottle()); float opThrottle = SaneThrottle(operator_stick.GetThrottle());
if( opThrottle > shooter_power + DEADZONE_RADIUS if( opThrottle > shooter_power + DEADZONE_RADIUS

View File

@ -10,18 +10,23 @@
#define PICKUP_POWER 1.0 #define PICKUP_POWER 1.0
class Shooter { class Shooter
{
public: public:
/** /**
* Shooter talons and launch-spinny talon. * Shooter talons and launch-spinny talon.
* 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) { 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;
shotClock = Timer();
} }
/** /**
@ -29,13 +34,35 @@ public:
* set at the beginning of the match. * set at the beginning of the match.
*/ */
virtual ~Shooter() { virtual ~Shooter()
{
delete launcher; delete launcher;
delete pickup; delete pickup;
delete launch_spinny; delete launch_spinny;
} }
void PickUp(bool state = true) { void StopShooter()
{
ready = true;
launch_spinny.Set(0);
launcher.Set(0);
pickup.Set(0);
}
void Shoot()
{
// TODO: Shooter Logic should go as follows:
/*
Assuming a ball is held in the shooter. When the trigger is pulled,
the launch-spinny should be STOPPED. Start a Timer object counting
When... too hard to write.. I emailed you a flow chart.
*/
}
void PickUp(bool state = true)
{
pickup->Set((float) (state * PICKUP_POWER)); pickup->Set((float) (state * PICKUP_POWER));
launch_spinny->Set(-1.0*PICKUP_POWER); launch_spinny->Set(-1.0*PICKUP_POWER);
std::cout << "picking up!\n"; std::cout << "picking up!\n";
@ -49,17 +76,21 @@ public:
pickup->Set(-1 * PICKUP_POWER); pickup->Set(-1 * PICKUP_POWER);
} }
void SetPower(float power) { void SetPower(float power)
{
pickup->Set(power); pickup->Set(power);
launcher->Set(power); launcher->Set(power);
std::cout << "setting shooter power" << std::endl; std::cout << "setting shooter power" << std::endl;
} }
private: private:
RobotDrive *shooterDrive; //RobotDrive *shooterDrive;
CANTalon *launcher; CANTalon *launcher;
CANTalon *pickup; CANTalon *pickup;
CANTalon *launch_spinny; CANTalon *launch_spinny;
Timer shotClock;
bool ready;
}; };
#endif /* SRC_SHOOTER_H_ */ #endif /* SRC_SHOOTER_H_ */