2016-02-02 10:18:19 -05:00
|
|
|
/*
|
|
|
|
* Shooter.h
|
|
|
|
*
|
|
|
|
* Created on: Feb 2, 2016
|
|
|
|
* Author: Jason
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SRC_SHOOTER_H_
|
|
|
|
#define SRC_SHOOTER_H_
|
|
|
|
|
2016-02-07 21:22:23 -05:00
|
|
|
#define PICKUP_POWER 0.5
|
|
|
|
#define RAMP_LOWER_DURATION 2 //Rotations.
|
|
|
|
|
2016-02-07 22:42:43 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* You can use the values assigned to each of these values as the number
|
|
|
|
* of rotations to run the motor down from the "Shoot" position.
|
|
|
|
*
|
|
|
|
* This might not be the best way to do it, and also requires that we
|
|
|
|
* figure out how to read the Hall Effect signal from the motor.
|
|
|
|
*/
|
2016-02-07 21:22:23 -05:00
|
|
|
enum RampState {
|
|
|
|
Shoot = 0, // 0 rotations
|
2016-02-07 22:42:43 -05:00
|
|
|
Half = 1, // 1 rotation?
|
|
|
|
Down = 2, // 2 rotations?
|
2016-02-07 21:22:23 -05:00
|
|
|
Uncalibrated = -1
|
|
|
|
};
|
|
|
|
|
2016-02-02 10:18:19 -05:00
|
|
|
class Shooter {
|
|
|
|
public:
|
2016-02-07 21:22:23 -05:00
|
|
|
/**
|
|
|
|
* Shooter talons and ramp talon.
|
|
|
|
* s2 is also for the pickup-mechanism and can be controlled independently.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
Shooter(CANTalon *s1, CANTalon *s2, CANTalon *r) {
|
2016-02-03 07:50:19 -05:00
|
|
|
shooterDrive = new RobotDrive(s1, s2);
|
2016-02-07 21:22:23 -05:00
|
|
|
pickup = s2;
|
|
|
|
ramp = r;
|
|
|
|
rampState = Uncalibrated;
|
|
|
|
}
|
|
|
|
|
2016-02-07 22:42:43 -05:00
|
|
|
/**
|
|
|
|
* Call this method on TeleopInit so that the ramp is properly
|
|
|
|
* set at the beginning of the match.
|
|
|
|
*/
|
2016-02-07 21:22:23 -05:00
|
|
|
RampState CalibrateRamp() {
|
|
|
|
// TODO:
|
|
|
|
// Raise ramp until limit switch is triggered,
|
|
|
|
// then lower the ramp to its lower limit.
|
|
|
|
|
|
|
|
return Down;
|
2016-02-03 07:50:19 -05:00
|
|
|
}
|
|
|
|
|
2016-02-07 21:22:23 -05:00
|
|
|
virtual ~Shooter() {
|
2016-02-03 07:50:19 -05:00
|
|
|
delete shooterDrive;
|
2016-02-07 22:42:43 -05:00
|
|
|
delete pickup;
|
|
|
|
delete ramp;
|
2016-02-02 10:18:19 -05:00
|
|
|
}
|
|
|
|
|
2016-02-07 21:22:23 -05:00
|
|
|
void PickUp(bool state = true) {
|
2016-02-07 22:37:10 -05:00
|
|
|
pickup->Set((float) (state * PICKUP_POWER));
|
2016-02-07 21:22:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetRamp(RampState state) {
|
|
|
|
// TODO:
|
|
|
|
// Move the Ramp to the set position.
|
|
|
|
}
|
|
|
|
|
2016-02-07 22:37:10 -05:00
|
|
|
/**
|
|
|
|
* Call this to run the pickup backwards if the ball gets jammed somehow...
|
|
|
|
*/
|
|
|
|
void Unjam()
|
|
|
|
{
|
|
|
|
pickup->Set(-1 * PICKUP_POWER);
|
|
|
|
}
|
|
|
|
|
2016-02-02 10:18:19 -05:00
|
|
|
void SetPower(float power) {
|
2016-02-03 07:50:19 -05:00
|
|
|
shooterDrive->TankDrive(power, -power, false);
|
2016-02-02 10:18:19 -05:00
|
|
|
}
|
2016-02-03 07:50:19 -05:00
|
|
|
private:
|
2016-02-07 21:22:23 -05:00
|
|
|
|
2016-02-03 07:50:19 -05:00
|
|
|
RobotDrive *shooterDrive;
|
2016-02-07 21:22:23 -05:00
|
|
|
CANTalon *pickup;
|
|
|
|
CANTalon *ramp;
|
|
|
|
|
|
|
|
RampState rampState;
|
2016-02-02 10:18:19 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* SRC_SHOOTER_H_ */
|