From a0bcd18711b229144e1928e2d8306440ee053a48 Mon Sep 17 00:00:00 2001 From: Jason Cox Date: Wed, 3 Feb 2016 19:05:03 -0500 Subject: [PATCH 1/6] Cqqq C C C C C C C C --- DriveBase/src/TankDrive.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DriveBase/src/TankDrive.h b/DriveBase/src/TankDrive.h index d3ae424..23867fd 100644 --- a/DriveBase/src/TankDrive.h +++ b/DriveBase/src/TankDrive.h @@ -51,7 +51,7 @@ public: } float speed = y * th; - float rot = -x * th; // do some math here to smooth out turning? + float rot = x * th; // do some math here to smooth out turning? dt1->ArcadeDrive(speed, rot, false); dt2->ArcadeDrive(speed, rot, false); From 81c38765373bbf59374af6cdbee0d387f5227fff Mon Sep 17 00:00:00 2001 From: Jason Date: Sun, 7 Feb 2016 21:22:23 -0500 Subject: [PATCH 2/6] 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 3/6] 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 4/6] 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) { From ea8d9899d8afb13fe636c96af6bce06dbeb1d896 Mon Sep 17 00:00:00 2001 From: Jason Date: Sun, 7 Feb 2016 22:54:31 -0500 Subject: [PATCH 5/6] Added another TODO comment. Signed-off-by: Jason --- DriveBase/src/TankDrive.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/DriveBase/src/TankDrive.h b/DriveBase/src/TankDrive.h index b41c796..d20d264 100644 --- a/DriveBase/src/TankDrive.h +++ b/DriveBase/src/TankDrive.h @@ -51,7 +51,8 @@ public: } float speed = y * th; - float rot = x; // do some math here to smooth out turning? + + float rot = x; // TODO: do some math here to smooth out turning? dt1->ArcadeDrive(speed, rot, false); dt2->ArcadeDrive(speed, rot, false); From bc81c928a8b30f773b64d9ad908a2c05321750ec Mon Sep 17 00:00:00 2001 From: Jason Cox Date: Mon, 8 Feb 2016 19:26:44 -0500 Subject: [PATCH 6/6] Shooter Test COde... --- DriveBase/src/Robot.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/DriveBase/src/Robot.cpp b/DriveBase/src/Robot.cpp index e65d1b1..b9c1817 100644 --- a/DriveBase/src/Robot.cpp +++ b/DriveBase/src/Robot.cpp @@ -11,8 +11,8 @@ #ifndef BUTTON_LAYOUT #define BUTTON_LAYOUT -#define TRIGGER 10 // I have no idea what the right button number is... -#define THUMB 11 +#define TRIGGER 0 +#define THUMB 1 #endif @@ -77,15 +77,18 @@ public: if(rstick.GetRawButton(TRIGGER)) { // SHOOT THE BALL + ramp.Set(-0.5); } if(rstick.GetRawButton(THUMB)) { // lower the ramp + ramp.Set(0.5); } else { // raise the ramp to HALF (so it isn't down all the time!) + ramp.Set(0); } // How to pickup?