From 81c38765373bbf59374af6cdbee0d387f5227fff Mon Sep 17 00:00:00 2001 From: Jason Date: Sun, 7 Feb 2016 21:22:23 -0500 Subject: [PATCH] Added CANTalon for the ramp control to robot.cpp and added some methods for the Ramp and PickUp to the Shooter class. --- DriveBase/src/Robot.cpp | 4 +++- DriveBase/src/Shooter.h | 45 ++++++++++++++++++++++++++++++++++++++--- 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/DriveBase/src/Robot.cpp b/DriveBase/src/Robot.cpp index 4a8ad95..cc574d5 100644 --- a/DriveBase/src/Robot.cpp +++ b/DriveBase/src/Robot.cpp @@ -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) { diff --git a/DriveBase/src/Shooter.h b/DriveBase/src/Shooter.h index 3a44dcf..dd5d6ff 100644 --- a/DriveBase/src/Shooter.h +++ b/DriveBase/src/Shooter.h @@ -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_ */