Added CANTalon for the ramp control to robot.cpp and added some methods for the Ramp and PickUp to the Shooter class.

This commit is contained in:
Jason 2016-02-07 21:22:23 -05:00
parent 9b8b4ff845
commit 81c3876537
2 changed files with 45 additions and 4 deletions

View File

@ -15,6 +15,7 @@ class Robot: public IterativeRobot {
CANTalon l2_drive;
CANTalon shooter1;
CANTalon shooter2;
CANTalon ramp;
TankDrive drive;
Shooter shooter;
Joystick rstick, lstick;
@ -31,10 +32,11 @@ public:
l2_drive(4), // left wheel 2
shooter1(10), // shooter drive 1
shooter2(11), // shooter drive 2
ramp(12),
drive( // initialize TankDrive object.
&l1_drive, &l2_drive, &r1_drive, &r2_drive),
shooter( // initialize Shooter object.
&shooter1, &shooter2),
&shooter1, &shooter2, &ramp),
rstick(0), // right stick (operator)
lstick(1) // left stick (driver)
{

View File

@ -8,22 +8,61 @@
#ifndef SRC_SHOOTER_H_
#define SRC_SHOOTER_H_
#define PICKUP_POWER 0.5
#define RAMP_LOWER_DURATION 2 //Rotations.
enum RampState {
Shoot = 0, // 0 rotations
Half = 1, // 1 rotation
Down = 2, // 2 rotations
Uncalibrated = -1
};
class Shooter {
public:
Shooter(CANTalon *s1, CANTalon *s2) {
/**
* Shooter talons and ramp 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);
pickup = s2;
ramp = r;
rampState = Uncalibrated;
}
virtual ~Shooter()
{
RampState CalibrateRamp() {
// TODO:
// Raise ramp until limit switch is triggered,
// then lower the ramp to its lower limit.
return Down;
}
virtual ~Shooter() {
delete shooterDrive;
}
void PickUp(bool state = true) {
pickup->Set((float) (state * PICKUP_POWER), false);
}
void SetRamp(RampState state) {
// TODO:
// Move the Ramp to the set position.
}
void SetPower(float power) {
shooterDrive->TankDrive(power, -power, false);
}
private:
RobotDrive *shooterDrive;
CANTalon *pickup;
CANTalon *ramp;
RampState rampState;
};
#endif /* SRC_SHOOTER_H_ */