From 81c38765373bbf59374af6cdbee0d387f5227fff Mon Sep 17 00:00:00 2001 From: Jason Date: Sun, 7 Feb 2016 21:22:23 -0500 Subject: [PATCH 1/3] 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_ */ From 62a93449cb15120d046c100964540cc65df1bd42 Mon Sep 17 00:00:00 2001 From: Jason Date: Sun, 7 Feb 2016 22:37:10 -0500 Subject: [PATCH 2/3] Added an 'unjam' method to the shooter --- DriveBase/src/Shooter.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/DriveBase/src/Shooter.h b/DriveBase/src/Shooter.h index dd5d6ff..a16eee0 100644 --- a/DriveBase/src/Shooter.h +++ b/DriveBase/src/Shooter.h @@ -45,7 +45,7 @@ public: } void PickUp(bool state = true) { - pickup->Set((float) (state * PICKUP_POWER), false); + pickup->Set((float) (state * PICKUP_POWER)); } void SetRamp(RampState state) { @@ -53,6 +53,14 @@ public: // Move the Ramp to the set position. } + /** + * Call this to run the pickup backwards if the ball gets jammed somehow... + */ + void Unjam() + { + pickup->Set(-1 * PICKUP_POWER); + } + void SetPower(float power) { shooterDrive->TankDrive(power, -power, false); } From 2299016c7e3229becc09647b214c0f04e2b3ec6f Mon Sep 17 00:00:00 2001 From: Jason Date: Sun, 7 Feb 2016 22:42:43 -0500 Subject: [PATCH 3/3] Added some more comments. --- DriveBase/src/Shooter.h | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/DriveBase/src/Shooter.h b/DriveBase/src/Shooter.h index a16eee0..6971715 100644 --- a/DriveBase/src/Shooter.h +++ b/DriveBase/src/Shooter.h @@ -11,10 +11,18 @@ #define PICKUP_POWER 0.5 #define RAMP_LOWER_DURATION 2 //Rotations. + +/** + * 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. + */ enum RampState { Shoot = 0, // 0 rotations - Half = 1, // 1 rotation - Down = 2, // 2 rotations + Half = 1, // 1 rotation? + Down = 2, // 2 rotations? Uncalibrated = -1 }; @@ -32,6 +40,10 @@ public: rampState = Uncalibrated; } + /** + * Call this method on TeleopInit so that the ramp is properly + * set at the beginning of the match. + */ RampState CalibrateRamp() { // TODO: // Raise ramp until limit switch is triggered, @@ -42,6 +54,8 @@ public: virtual ~Shooter() { delete shooterDrive; + delete pickup; + delete ramp; } void PickUp(bool state = true) {