113 lines
1.9 KiB
C++
113 lines
1.9 KiB
C++
/*
|
|
* Shooter.h
|
|
*
|
|
* Created on: Feb 2, 2016
|
|
* Author: Jason
|
|
*/
|
|
|
|
#ifndef SRC_SHOOTER_H_
|
|
#define SRC_SHOOTER_H_
|
|
|
|
#define PICKUP_POWER 1.0
|
|
#define SPINUP_TIME 1.5 // seconds.
|
|
|
|
class Shooter
|
|
{
|
|
public:
|
|
|
|
/**
|
|
* Shooter talons and launch-spinny talon.
|
|
* s2 is also for the pickup-mechanism and can be controlled independently.
|
|
*
|
|
*/
|
|
Shooter(CANTalon *s1, CANTalon *s2, CANTalon *r)
|
|
{
|
|
// shooterDrive = new RobotDrive(s1, s2);
|
|
launcher = s1;
|
|
pickup = s2;
|
|
launch_spinny = r;
|
|
ready = true;
|
|
shotClock = Timer();
|
|
}
|
|
|
|
/**
|
|
* Call this method on TeleopInit so that the ramp is properly
|
|
* set at the beginning of the match.
|
|
*/
|
|
|
|
virtual ~Shooter()
|
|
{
|
|
delete launcher;
|
|
delete pickup;
|
|
delete launch_spinny;
|
|
}
|
|
|
|
void StopShooter()
|
|
{
|
|
ready = true;
|
|
launch_spinny->Set(0);
|
|
launcher->Set(0);
|
|
pickup->Set(0);
|
|
}
|
|
|
|
void LowerRamp()
|
|
{
|
|
launch_spinny->Set(-0.1);
|
|
}
|
|
|
|
void RaiseRamp()
|
|
{
|
|
launch_spinny->Set(0.1);
|
|
}
|
|
|
|
void BoostRamp()
|
|
{
|
|
launch_spinny->Set(0.5);
|
|
}
|
|
|
|
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));
|
|
//launch_spinny->Set(-1.0*PICKUP_POWER);
|
|
std::cout << "picking up!\n";
|
|
}
|
|
|
|
/**
|
|
* Call this to run the pickup backwards if the ball gets jammed somehow...
|
|
*/
|
|
void Unjam()
|
|
{
|
|
pickup->Set(-1 * PICKUP_POWER);
|
|
}
|
|
|
|
void SetPower(float power)
|
|
{
|
|
pickup->Set(power);
|
|
launcher->Set(power);
|
|
std::cout << "setting shooter power" << std::endl;
|
|
}
|
|
private:
|
|
|
|
//RobotDrive *shooterDrive;
|
|
CANTalon *launcher;
|
|
CANTalon *pickup;
|
|
CANTalon *launch_spinny;
|
|
|
|
Timer shotClock;
|
|
bool ready;
|
|
};
|
|
|
|
#endif /* SRC_SHOOTER_H_ */
|