From 323627dbb795a000c60d83296cc55db02fcfc7fc Mon Sep 17 00:00:00 2001 From: Dieter Brehm Date: Wed, 10 Feb 2016 21:24:35 -0500 Subject: [PATCH 01/31] Changed todo to reflect lack of ramp. --- src/Shooter.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Shooter.h b/src/Shooter.h index ccb3c9b..fe94f43 100644 --- a/src/Shooter.h +++ b/src/Shooter.h @@ -48,8 +48,7 @@ public: */ RampState CalibrateRamp() { // TODO: - // Raise ramp until limit switch is triggered, - // then lower the ramp to its lower limit. + // Ramp no longer exists, replace with more wheels. return Down; } From 08bc03df1c501783039984055244eef0efa236b2 Mon Sep 17 00:00:00 2001 From: Aidan Ferguson Date: Thu, 11 Feb 2016 16:18:58 -0500 Subject: [PATCH 02/31] Made shooter_power private instead of global because that actually makes sense. --- src/Robot.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Robot.cpp b/src/Robot.cpp index 4913f17..2e61871 100644 --- a/src/Robot.cpp +++ b/src/Robot.cpp @@ -19,7 +19,6 @@ class Robot: public IterativeRobot RobotDrive drive; Shooter shooter; Joystick driver_stick, operator_stick; - float power; public: Robot(): left_drive(0), // Left DriveTrain Talons plug into PWM channel 1 with a Y-splitter @@ -40,6 +39,7 @@ private: // instance variables bool pickupRunning; // don't want to spam the Talon with set messages. Toggle the pickup when a button is pressed or released. bool inverting; + float shooter_power; LiveWindow *lw = LiveWindow::GetInstance(); SendableChooser *chooser; @@ -145,10 +145,10 @@ private: inverting = false; } - if(((1.0 - operator_stick.GetThrottle()) / 2.0) > power + 0.005||((1.0 - operator_stick.GetThrottle()) / 2.0) < power -0.005) + if(((1.0 - operator_stick.GetThrottle()) / 2.0) > shooter_power + 0.005||((1.0 - operator_stick.GetThrottle()) / 2.0) < shooter_power -0.005) { - power = (1.0 - operator_stick.GetThrottle()) / 2.0; - shooter.SetPower(power); + shooter_power = (1.0 - operator_stick.GetThrottle()) / 2.0; + shooter.SetPower(shooter_power); } } From 7ac2c9904a911a6b41cbaaa23ddb0d68848f7fcf Mon Sep 17 00:00:00 2001 From: Aidan Ferguson Date: Thu, 11 Feb 2016 16:35:41 -0500 Subject: [PATCH 03/31] Swapped Talon objects for TalonSRX objects. --- src/Robot.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Robot.cpp b/src/Robot.cpp index 2cc4f0a..3813ab6 100644 --- a/src/Robot.cpp +++ b/src/Robot.cpp @@ -13,7 +13,7 @@ class Robot: public IterativeRobot { - Talon left_drive, right_drive; + TalonSRX left_drive, right_drive; CANTalon shooter1, shooter2, ramp; RobotDrive drive; From 9ce495f073f0ad9eae3528e6dd58ee93dec814f9 Mon Sep 17 00:00:00 2001 From: Aidan Ferguson Date: Thu, 11 Feb 2016 16:51:13 -0500 Subject: [PATCH 04/31] purged the concept of a ramp --- src/Robot.cpp | 9 ++------ src/Shooter.h | 64 ++++----------------------------------------------- 2 files changed, 6 insertions(+), 67 deletions(-) diff --git a/src/Robot.cpp b/src/Robot.cpp index 2e61871..a4073cb 100644 --- a/src/Robot.cpp +++ b/src/Robot.cpp @@ -53,12 +53,12 @@ private: chooser->AddDefault(autoNameDefault, (void*)&autoNameDefault); chooser->AddObject(autoNameCustom, (void*)&autoNameCustom); SmartDashboard::PutData("Auto Modes", chooser); - ramp.Enable(); shooter1.Enable(); shooter2.Enable(); left_drive.SetInverted(true); right_drive.SetInverted(true); inverting = false; + shooter_power = 0; } @@ -74,9 +74,6 @@ private: */ void AutonomousInit() { - shooter.CalibrateRamp(); - shooter.SetRamp(Shoot); - autoSelected = *((std::string*)chooser->GetSelected()); //std::string autoSelected = SmartDashboard::GetString("Auto Selector", autoNameDefault); std::cout << "Auto selected: " << autoSelected << std::endl; @@ -99,9 +96,7 @@ private: void TeleopInit() { - shooter.CalibrateRamp(); - shooter.SetRamp(Shoot); // start in the full up position! - power = 0; + } void TeleopPeriodic() diff --git a/src/Shooter.h b/src/Shooter.h index fe94f43..2486d8a 100644 --- a/src/Shooter.h +++ b/src/Shooter.h @@ -9,28 +9,11 @@ #define SRC_SHOOTER_H_ #define PICKUP_POWER 0.8 -#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 = (RAMP_LOWER_DURATION / 2), // 1 rotation? - Down = RAMP_LOWER_DURATION, // 2 rotations? - Uncalibrated = -1, - Transitioning = -2 -}; class Shooter { public: /** - * Shooter talons and ramp talon. + * Shooter talons and launch-spinny talon. * s2 is also for the pickup-mechanism and can be controlled independently. * */ @@ -38,25 +21,18 @@ public: // shooterDrive = new RobotDrive(s1, s2); launcher = s1; pickup = s2; - ramp = r; - rampState = Uncalibrated; + launch_spinny = r; } /** * Call this method on TeleopInit so that the ramp is properly * set at the beginning of the match. */ - RampState CalibrateRamp() { - // TODO: - // Ramp no longer exists, replace with more wheels. - - return Down; - } virtual ~Shooter() { delete launcher; delete pickup; - delete ramp; + delete launch_spinny; } void PickUp(bool state = true) { @@ -64,34 +40,6 @@ public: std::cout << "picking up!\n"; } - void SetRamp(RampState state) { - // TODO: - // Move the Ramp to the set position. - switch (state) - { - case Shoot: - { - if (ramp->GetForwardLimitOK()) - { - ramp->Set(1); - } else - { - ramp->Set(0); - } - } - case Half: - { - //yeah, put something here when you get the encoder working. - std::cout << "Hey! Didja install an encoder? Because this is placeholder that Aidan would have removed if you had installed one and told him about it.\n"; - } - case Down: - { - //see half. - std::cout << "Hey! Didja install an encoder? Because this is placeholder that Aidan would have removed if you had installed one and told him about it.\n"; - } - } - } - /** * Call this to run the pickup backwards if the ball gets jammed somehow... */ @@ -110,11 +58,7 @@ private: RobotDrive *shooterDrive; CANTalon *launcher; CANTalon *pickup; - CANTalon *ramp; - - RampState rampState; - RampState targetState; - RampState previousState; + CANTalon *launch_spinny; }; #endif /* SRC_SHOOTER_H_ */ From 71b8e5eeff89bd93199955c468a9890df9ffa0ed Mon Sep 17 00:00:00 2001 From: Aidan Ferguson Date: Thu, 11 Feb 2016 17:17:42 -0500 Subject: [PATCH 05/31] launch spinny does stuff --- src/Robot.cpp | 14 +++++++------- src/Shooter.h | 3 ++- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Robot.cpp b/src/Robot.cpp index a4073cb..3111ca2 100644 --- a/src/Robot.cpp +++ b/src/Robot.cpp @@ -15,7 +15,7 @@ class Robot: public IterativeRobot { Talon left_drive, right_drive; CANTalon shooter1, shooter2, - ramp; + launch_spinny; RobotDrive drive; Shooter shooter; Joystick driver_stick, operator_stick; @@ -25,10 +25,10 @@ public: right_drive(1), // Right DriveTrain Talons plug // left wheel 2 shooter1(11), // shooter drive 1 shooter2(10), // shooter drive 2 - ramp(12), + launch_spinny(12), drive(&left_drive, &right_drive), shooter( // initialize Shooter object. - &shooter1, &shooter2, &ramp), + &shooter1, &shooter2, &launch_spinny), driver_stick(0), // right stick (operator) operator_stick(1) // left stick (driver) { @@ -101,21 +101,21 @@ private: void TeleopPeriodic() { - std::cout << "Ramp position: "<< ramp.GetEncPosition() << std::endl; + std::cout << "Ramp position: "<< launch_spinny.GetEncPosition() << std::endl; drive.ArcadeDrive(&driver_stick, true); // This is shit code for testing. Replace it with real code. if(operator_stick.GetRawButton(RAMP_RAISE)) { - ramp.Set(1); + launch_spinny.Set(1); } else if(operator_stick.GetRawButton(RAMP_LOWER)) { - ramp.Set(-1); + launch_spinny.Set(-1); } else { - ramp.Set(0); + launch_spinny.Set(0); } if(operator_stick.GetRawButton(THUMB) && !pickupRunning) diff --git a/src/Shooter.h b/src/Shooter.h index 2486d8a..f63bdf1 100644 --- a/src/Shooter.h +++ b/src/Shooter.h @@ -8,7 +8,7 @@ #ifndef SRC_SHOOTER_H_ #define SRC_SHOOTER_H_ -#define PICKUP_POWER 0.8 +#define PICKUP_POWER 1.0 class Shooter { public: @@ -37,6 +37,7 @@ public: void PickUp(bool state = true) { pickup->Set((float) (state * PICKUP_POWER)); + launch_spinny->Set(-1.0*PICKUP_POWER); std::cout << "picking up!\n"; } From 86e7e2e3beb9935fc50aaf44b5bbe1268aff19e3 Mon Sep 17 00:00:00 2001 From: Jason Date: Thu, 11 Feb 2016 20:40:41 -0500 Subject: [PATCH 06/31] Added comments about the use of the boolean variables in the TeleopPeriodic method --- src/Robot.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Robot.cpp b/src/Robot.cpp index 3111ca2..8e4b800 100644 --- a/src/Robot.cpp +++ b/src/Robot.cpp @@ -118,6 +118,13 @@ private: launch_spinny.Set(0); } + /* + * Run the Shooter only while the THUMB button is held down on the operator stick. + * the 'pickupRunning' boolean is there to prevent the shooter from calling PickUp + * every itteration of the TeleopPeriodic method (once every 10ms!) + * The pickup is disabled when the thumb button is released, but the code still + * has 'pickupRunning' as true. + */ if(operator_stick.GetRawButton(THUMB) && !pickupRunning) { shooter.PickUp(); @@ -129,6 +136,12 @@ private: pickupRunning = false; } + /* + * The 'inverting' variable is used to make sure that the drive train isn't getting + * inverted every itteration of the TeleopPeriodic method while the button is held down. + * This is important because the TeleopPeriodic method executes something like once every 10ms. + * Thus, this if-else if pair make the button a toggle. + */ if(driver_stick.GetRawButton(THUMB) && !inverting) { left_drive.SetInverted(!left_drive.GetInverted()); @@ -140,7 +153,10 @@ private: inverting = false; } - if(((1.0 - operator_stick.GetThrottle()) / 2.0) > shooter_power + 0.005||((1.0 - operator_stick.GetThrottle()) / 2.0) < shooter_power -0.005) + + + if(((1.0 - operator_stick.GetThrottle()) / 2.0) > shooter_power + 0.005 + || ((1.0 - operator_stick.GetThrottle()) / 2.0) < shooter_power -0.005) { shooter_power = (1.0 - operator_stick.GetThrottle()) / 2.0; shooter.SetPower(shooter_power); From c083f6cd1018708cfd568b3f39d7f8848dcf72d6 Mon Sep 17 00:00:00 2001 From: Jason Date: Thu, 11 Feb 2016 20:48:03 -0500 Subject: [PATCH 07/31] Added a define for DEADZONE_RADIUS and implemented it in the shooter power setting within TeleopPeriodic. --- src/Robot.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/Robot.cpp b/src/Robot.cpp index 8e4b800..36cef0c 100644 --- a/src/Robot.cpp +++ b/src/Robot.cpp @@ -9,6 +9,10 @@ #define RAMP_RAISE 3 // Button 3 for Raising Ramp #define RAMP_LOWER 4 // Button 4 to lower ramp. +#define DEADZONE_RADIUS 0.05 // Deadzone Radius prevents tiny twitches in the joystick's value from + // affecting the robot. Use this for cleaning up drive train and shooter. + // Also used for detecting changes in an axis' value. + #endif // BUTTON_LAYOUT class Robot: public IterativeRobot @@ -153,16 +157,23 @@ private: inverting = false; } + float opThrottle = SaneThrottle(operator_stick.GetThrottle()); - - if(((1.0 - operator_stick.GetThrottle()) / 2.0) > shooter_power + 0.005 - || ((1.0 - operator_stick.GetThrottle()) / 2.0) < shooter_power -0.005) + if( opThrottle > shooter_power + DEADZONE_RADIUS + || opThrottle < shooter_power - DEADZONE_RADIUS) { - shooter_power = (1.0 - operator_stick.GetThrottle()) / 2.0; - shooter.SetPower(shooter_power); + shooter.SetPower(opThrottle); } } + /** + * Takes the gross raw throttle input from joystick and returns a + * value between 0.0-1.0 (no negative values) + */ + float SaneThrottle(float rawThrottle) + { + return ((1.0 - rawThrottle) / 2.0); + } void TestPeriodic() { From 83cbc89a0fc17cfcc611853417b16550ffd1fa21 Mon Sep 17 00:00:00 2001 From: Jason Date: Thu, 11 Feb 2016 21:24:32 -0500 Subject: [PATCH 08/31] Added comments and info for the shooter logic. I emailed you a flow chart also... --- src/Robot.cpp | 20 +++++++++++++++++++- src/Shooter.h | 45 ++++++++++++++++++++++++++++++++++++++------- 2 files changed, 57 insertions(+), 8 deletions(-) diff --git a/src/Robot.cpp b/src/Robot.cpp index 36cef0c..6de81fa 100644 --- a/src/Robot.cpp +++ b/src/Robot.cpp @@ -62,6 +62,7 @@ private: left_drive.SetInverted(true); right_drive.SetInverted(true); inverting = false; + pickupRunning = false; shooter_power = 0; } @@ -156,7 +157,24 @@ private: { inverting = false; } - + + + /* + * Unlike the previous actions, this method does need to be called every itteration of + * TeleopPeriodic. This is because the logic running this operation needs to be checked + * Every time the method is called. This cannot be a loop in the Shoot method because + * that would lock the robot every time the trigger is hit. + */ + if(operator_stick.GetRawButton(TRIGGER)) + { + shooter.Shoot(); + } + else + { + shooter.StopShooter(); + } + + // This code will become obsolete after the Shooter logic is complete. float opThrottle = SaneThrottle(operator_stick.GetThrottle()); if( opThrottle > shooter_power + DEADZONE_RADIUS diff --git a/src/Shooter.h b/src/Shooter.h index f63bdf1..22e2eb8 100644 --- a/src/Shooter.h +++ b/src/Shooter.h @@ -10,18 +10,23 @@ #define PICKUP_POWER 1.0 -class Shooter { +class Shooter +{ public: + /** * Shooter talons and launch-spinny talon. * s2 is also for the pickup-mechanism and can be controlled independently. * */ - Shooter(CANTalon *s1, CANTalon *s2, CANTalon *r) { + Shooter(CANTalon *s1, CANTalon *s2, CANTalon *r) + { // shooterDrive = new RobotDrive(s1, s2); launcher = s1; pickup = s2; launch_spinny = r; + ready = true; + shotClock = Timer(); } /** @@ -29,13 +34,35 @@ public: * set at the beginning of the match. */ - virtual ~Shooter() { + virtual ~Shooter() + { delete launcher; delete pickup; delete launch_spinny; } - - void PickUp(bool state = true) { + + void StopShooter() + { + ready = true; + launch_spinny.Set(0); + launcher.Set(0); + pickup.Set(0); + } + + void Shoot() + { + // TODO: Shooter Logic should go as follows: + + /* + Assuming a ball is held in the shooter. When the trigger is pulled, + the launch-spinny should be STOPPED. Start a Timer object counting + When... too hard to write.. I emailed you a flow chart. + */ + + } + + void PickUp(bool state = true) + { pickup->Set((float) (state * PICKUP_POWER)); launch_spinny->Set(-1.0*PICKUP_POWER); std::cout << "picking up!\n"; @@ -49,17 +76,21 @@ public: pickup->Set(-1 * PICKUP_POWER); } - void SetPower(float power) { + void SetPower(float power) + { pickup->Set(power); launcher->Set(power); std::cout << "setting shooter power" << std::endl; } private: - RobotDrive *shooterDrive; + //RobotDrive *shooterDrive; CANTalon *launcher; CANTalon *pickup; CANTalon *launch_spinny; + + Timer shotClock; + bool ready; }; #endif /* SRC_SHOOTER_H_ */ From 91acd20f7dc1a1a96cfede4065857b8b9d265379 Mon Sep 17 00:00:00 2001 From: Jason Date: Thu, 11 Feb 2016 22:26:11 -0500 Subject: [PATCH 09/31] added SPINUP_TIME define for the shotClock Timer. Adjust the value of this define to wait longer before shooting the ball into the launch wheel. : --- src/Shooter.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Shooter.h b/src/Shooter.h index 22e2eb8..f9892bd 100644 --- a/src/Shooter.h +++ b/src/Shooter.h @@ -9,6 +9,7 @@ #define SRC_SHOOTER_H_ #define PICKUP_POWER 1.0 +#define SPINUP_TIME 1.5 // seconds. class Shooter { @@ -89,7 +90,7 @@ private: CANTalon *pickup; CANTalon *launch_spinny; - Timer shotClock; + Timer shotClock; bool ready; }; From e061b741cbc5528aa265f7279aca8962449cf376 Mon Sep 17 00:00:00 2001 From: Jason Cox Date: Fri, 12 Feb 2016 19:37:36 -0500 Subject: [PATCH 10/31] ramp reinstated --- src/Robot.cpp | 12 ++++++++++-- src/Shooter.h | 23 +++++++++++++++++++---- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/Robot.cpp b/src/Robot.cpp index 6de81fa..8826677 100644 --- a/src/Robot.cpp +++ b/src/Robot.cpp @@ -112,17 +112,25 @@ private: // This is shit code for testing. Replace it with real code. if(operator_stick.GetRawButton(RAMP_RAISE)) { - launch_spinny.Set(1); + //launch_spinny.Set(1); + shooter.RaiseRamp(); } else if(operator_stick.GetRawButton(RAMP_LOWER)) { - launch_spinny.Set(-1); + //launch_spinny.Set(-1); + shooter.LowerRamp(); + } + else if(operator_stick.GetRawButton(TRIGGER)) + { + shooter.BoostRamp(); } else { launch_spinny.Set(0); } + + /* * Run the Shooter only while the THUMB button is held down on the operator stick. * the 'pickupRunning' boolean is there to prevent the shooter from calling PickUp diff --git a/src/Shooter.h b/src/Shooter.h index f9892bd..b273940 100644 --- a/src/Shooter.h +++ b/src/Shooter.h @@ -45,9 +45,24 @@ public: void StopShooter() { ready = true; - launch_spinny.Set(0); - launcher.Set(0); - pickup.Set(0); + launch_spinny->Set(0); + launcher->Set(0); + pickup->Set(0); + } + + void LowerRamp() + { + launch_spinny->Set(-0.1); + } + + void RaiseRamp() + { + launch_spinny->Set(0.1); + } + + void BoostRamp() + { + launch_spinny->Set(0.5); } void Shoot() @@ -65,7 +80,7 @@ public: void PickUp(bool state = true) { pickup->Set((float) (state * PICKUP_POWER)); - launch_spinny->Set(-1.0*PICKUP_POWER); + //launch_spinny->Set(-1.0*PICKUP_POWER); std::cout << "picking up!\n"; } From 63f3c48267cd05926d35c98aa18ee9250d5b2df1 Mon Sep 17 00:00:00 2001 From: Jason Cox Date: Fri, 12 Feb 2016 21:17:45 -0500 Subject: [PATCH 11/31] Fixed a bunch of logic errors. --- src/Robot.cpp | 7 ++++--- src/Shooter.h | 5 ++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Robot.cpp b/src/Robot.cpp index 8826677..6ec1e54 100644 --- a/src/Robot.cpp +++ b/src/Robot.cpp @@ -61,6 +61,7 @@ private: shooter2.Enable(); left_drive.SetInverted(true); right_drive.SetInverted(true); + launch_spinny.SetInverted(true); inverting = false; pickupRunning = false; shooter_power = 0; @@ -143,7 +144,7 @@ private: shooter.PickUp(); pickupRunning = true; } - else if(pickupRunning) + else if(!operator_stick.GetRawButton(THUMB) && pickupRunning) { shooter.PickUp(false); pickupRunning = false; @@ -185,8 +186,8 @@ private: // This code will become obsolete after the Shooter logic is complete. float opThrottle = SaneThrottle(operator_stick.GetThrottle()); - if( opThrottle > shooter_power + DEADZONE_RADIUS - || opThrottle < shooter_power - DEADZONE_RADIUS) + if(!pickupRunning && ( opThrottle > shooter_power + DEADZONE_RADIUS + || opThrottle < shooter_power - DEADZONE_RADIUS)) { shooter.SetPower(opThrottle); } diff --git a/src/Shooter.h b/src/Shooter.h index b273940..7b4705d 100644 --- a/src/Shooter.h +++ b/src/Shooter.h @@ -27,7 +27,6 @@ public: pickup = s2; launch_spinny = r; ready = true; - shotClock = Timer(); } /** @@ -52,12 +51,12 @@ public: void LowerRamp() { - launch_spinny->Set(-0.1); + launch_spinny->Set(-0.25); } void RaiseRamp() { - launch_spinny->Set(0.1); + launch_spinny->Set(0.25); } void BoostRamp() From ae2dfe00471a67b515bb2462963798a52d257f98 Mon Sep 17 00:00:00 2001 From: Jason Cox Date: Sat, 13 Feb 2016 11:12:20 -0500 Subject: [PATCH 12/31] Fixed some really bad logic in the shooter... --- src/Robot.cpp | 24 +++++++++++++++++------- src/Shooter.h | 11 ++++++++--- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/Robot.cpp b/src/Robot.cpp index 6ec1e54..6dd945d 100644 --- a/src/Robot.cpp +++ b/src/Robot.cpp @@ -43,6 +43,8 @@ private: // instance variables bool pickupRunning; // don't want to spam the Talon with set messages. Toggle the pickup when a button is pressed or released. bool inverting; + bool ramping; + bool shooting; float shooter_power; LiveWindow *lw = LiveWindow::GetInstance(); @@ -61,9 +63,11 @@ private: shooter2.Enable(); left_drive.SetInverted(true); right_drive.SetInverted(true); - launch_spinny.SetInverted(true); + //launch_spinny.SetInverted(true); inverting = false; pickupRunning = false; + ramping = false; + shooting = false; shooter_power = 0; } @@ -110,22 +114,26 @@ private: std::cout << "Ramp position: "<< launch_spinny.GetEncPosition() << std::endl; drive.ArcadeDrive(&driver_stick, true); + //bool rampDoing = false; // This is shit code for testing. Replace it with real code. - if(operator_stick.GetRawButton(RAMP_RAISE)) + if(!ramping && operator_stick.GetRawButton(RAMP_RAISE)) { //launch_spinny.Set(1); shooter.RaiseRamp(); + ramping =true; } - else if(operator_stick.GetRawButton(RAMP_LOWER)) + else if(!ramping && operator_stick.GetRawButton(RAMP_LOWER)) { //launch_spinny.Set(-1); shooter.LowerRamp(); + ramping = true; } - else if(operator_stick.GetRawButton(TRIGGER)) + else if(!ramping && operator_stick.GetRawButton(TRIGGER)) { shooter.BoostRamp(); + ramping = true; } - else + else if(ramping) { launch_spinny.Set(0); } @@ -174,12 +182,14 @@ private: * Every time the method is called. This cannot be a loop in the Shoot method because * that would lock the robot every time the trigger is hit. */ - if(operator_stick.GetRawButton(TRIGGER)) + if(operator_stick.GetRawButton(TRIGGER) && !shooting) { + shooting = true; shooter.Shoot(); } - else + else if(shooting) { + shooting = false; shooter.StopShooter(); } diff --git a/src/Shooter.h b/src/Shooter.h index 7b4705d..8dbdc57 100644 --- a/src/Shooter.h +++ b/src/Shooter.h @@ -51,17 +51,22 @@ public: void LowerRamp() { - launch_spinny->Set(-0.25); + launch_spinny->Set(-1); } void RaiseRamp() { - launch_spinny->Set(0.25); + launch_spinny->Set(1); + } + + void StopRamp() + { + launch_spinny->Set(0); } void BoostRamp() { - launch_spinny->Set(0.5); + launch_spinny->Set(1); } void Shoot() From bf3c89bd6e3f944ec394ad86d4038ee4bdece2b3 Mon Sep 17 00:00:00 2001 From: Jason Cox Date: Sat, 13 Feb 2016 11:26:07 -0500 Subject: [PATCH 13/31] Now has Sane pickup logic~ --- src/Robot.cpp | 14 +++++++++----- src/Shooter.h | 3 ++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/Robot.cpp b/src/Robot.cpp index 6dd945d..7688ac4 100644 --- a/src/Robot.cpp +++ b/src/Robot.cpp @@ -9,7 +9,7 @@ #define RAMP_RAISE 3 // Button 3 for Raising Ramp #define RAMP_LOWER 4 // Button 4 to lower ramp. -#define DEADZONE_RADIUS 0.05 // Deadzone Radius prevents tiny twitches in the joystick's value from +#define DEADZONE_RADIUS 0.01 // Deadzone Radius prevents tiny twitches in the joystick's value from // affecting the robot. Use this for cleaning up drive train and shooter. // Also used for detecting changes in an axis' value. @@ -118,24 +118,28 @@ private: // This is shit code for testing. Replace it with real code. if(!ramping && operator_stick.GetRawButton(RAMP_RAISE)) { + std::cout << "Raising Ramp."; //launch_spinny.Set(1); shooter.RaiseRamp(); ramping =true; } else if(!ramping && operator_stick.GetRawButton(RAMP_LOWER)) { + std::cout << "Lowering Ramp."; //launch_spinny.Set(-1); shooter.LowerRamp(); ramping = true; } - else if(!ramping && operator_stick.GetRawButton(TRIGGER)) + /*else if(!ramping && operator_stick.GetRawButton(TRIGGER)) { shooter.BoostRamp(); ramping = true; - } + }*/ else if(ramping) { - launch_spinny.Set(0); + std::cout << "Stopping Ramp."; + shooter.StopRamp(); + ramping = false; } @@ -182,7 +186,7 @@ private: * Every time the method is called. This cannot be a loop in the Shoot method because * that would lock the robot every time the trigger is hit. */ - if(operator_stick.GetRawButton(TRIGGER) && !shooting) + if(operator_stick.GetRawButton(TRIGGER)) { shooting = true; shooter.Shoot(); diff --git a/src/Shooter.h b/src/Shooter.h index 8dbdc57..a388f33 100644 --- a/src/Shooter.h +++ b/src/Shooter.h @@ -8,7 +8,7 @@ #ifndef SRC_SHOOTER_H_ #define SRC_SHOOTER_H_ -#define PICKUP_POWER 1.0 +#define PICKUP_POWER 0.5 #define SPINUP_TIME 1.5 // seconds. class Shooter @@ -84,6 +84,7 @@ public: void PickUp(bool state = true) { pickup->Set((float) (state * PICKUP_POWER)); + launcher->Set((float) (state * PICKUP_POWER * -1)); //launch_spinny->Set(-1.0*PICKUP_POWER); std::cout << "picking up!\n"; } From c64916128334f3ae38f0ee550c86fab39ae485eb Mon Sep 17 00:00:00 2001 From: Jason Cox Date: Sat, 13 Feb 2016 12:00:28 -0500 Subject: [PATCH 14/31] some more bug fixes. --- src/Robot.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/Robot.cpp b/src/Robot.cpp index 7688ac4..b356e3d 100644 --- a/src/Robot.cpp +++ b/src/Robot.cpp @@ -8,6 +8,7 @@ #define THUMB 2 // Thumb button number #define RAMP_RAISE 3 // Button 3 for Raising Ramp #define RAMP_LOWER 4 // Button 4 to lower ramp. +#define UNJAM 11 #define DEADZONE_RADIUS 0.01 // Deadzone Radius prevents tiny twitches in the joystick's value from // affecting the robot. Use this for cleaning up drive train and shooter. @@ -45,6 +46,7 @@ private: bool inverting; bool ramping; bool shooting; + bool unjamming; float shooter_power; LiveWindow *lw = LiveWindow::GetInstance(); @@ -68,6 +70,7 @@ private: pickupRunning = false; ramping = false; shooting = false; + unjamming = false; shooter_power = 0; } @@ -135,7 +138,9 @@ private: shooter.BoostRamp(); ramping = true; }*/ - else if(ramping) + else if(ramping + && !operator_stick.GetRawButton(RAMP_LOWER) + && !operator_stick.GetRawButton(RAMP_RAISE)) { std::cout << "Stopping Ramp."; shooter.StopRamp(); @@ -143,6 +148,17 @@ private: } + if(!unjamming && operator_stick.GetRawButton(UNJAM)) + { + unjamming = true; + shooter.Unjam(); + } + else if(unjamming && !operator_stick.GetRawButton(UNJAM)) + { + shooter.PickUp(false); + unjamming = false; + } + /* * Run the Shooter only while the THUMB button is held down on the operator stick. @@ -191,7 +207,7 @@ private: shooting = true; shooter.Shoot(); } - else if(shooting) + else if(shooting && !operator_stick.GetRawButton(TRIGGER)) { shooting = false; shooter.StopShooter(); From 21138d6bc6f5372f50ed863d2b1ae534c963e821 Mon Sep 17 00:00:00 2001 From: Jason Cox Date: Sat, 13 Feb 2016 12:09:08 -0500 Subject: [PATCH 15/31] removed old debug statements --- src/Robot.cpp | 3 ++- src/Shooter.h | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Robot.cpp b/src/Robot.cpp index b356e3d..cab8ba8 100644 --- a/src/Robot.cpp +++ b/src/Robot.cpp @@ -114,7 +114,7 @@ private: void TeleopPeriodic() { - std::cout << "Ramp position: "<< launch_spinny.GetEncPosition() << std::endl; + //std::cout << "Ramp position: "<< launch_spinny.GetEncPosition() << std::endl; drive.ArcadeDrive(&driver_stick, true); //bool rampDoing = false; @@ -186,6 +186,7 @@ private: */ if(driver_stick.GetRawButton(THUMB) && !inverting) { + std::cout << "Inverting Drive Train."; left_drive.SetInverted(!left_drive.GetInverted()); right_drive.SetInverted(!right_drive.GetInverted()); inverting = true; diff --git a/src/Shooter.h b/src/Shooter.h index a388f33..2ec7e5f 100644 --- a/src/Shooter.h +++ b/src/Shooter.h @@ -86,7 +86,7 @@ public: pickup->Set((float) (state * PICKUP_POWER)); launcher->Set((float) (state * PICKUP_POWER * -1)); //launch_spinny->Set(-1.0*PICKUP_POWER); - std::cout << "picking up!\n"; + //std::cout << "picking up!\n"; } /** @@ -101,7 +101,7 @@ public: { pickup->Set(power); launcher->Set(power); - std::cout << "setting shooter power" << std::endl; + //std::cout << "setting shooter power" << std::endl; } private: From 9e14cfd2463d2a734314a59dd57e2270eb40b094 Mon Sep 17 00:00:00 2001 From: Aidan Ferguson Date: Sat, 13 Feb 2016 16:40:07 -0500 Subject: [PATCH 16/31] enum ShooterState, starts of associated switch, etc. --- src/Robot.cpp | 6 +++++- src/Shooter.h | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 61 insertions(+), 2 deletions(-) diff --git a/src/Robot.cpp b/src/Robot.cpp index cab8ba8..86b0612 100644 --- a/src/Robot.cpp +++ b/src/Robot.cpp @@ -35,7 +35,7 @@ public: shooter( // initialize Shooter object. &shooter1, &shooter2, &launch_spinny), driver_stick(0), // right stick (operator) - operator_stick(1) // left stick (driver) + operator_stick(1) // left stick (driver) { } @@ -117,6 +117,10 @@ private: //std::cout << "Ramp position: "<< launch_spinny.GetEncPosition() << std::endl; drive.ArcadeDrive(&driver_stick, true); + if (operator_stick.GetRawButton(TRIGGER)) + { + + } //bool rampDoing = false; // This is shit code for testing. Replace it with real code. if(!ramping && operator_stick.GetRawButton(RAMP_RAISE)) diff --git a/src/Shooter.h b/src/Shooter.h index 2ec7e5f..aeeab87 100644 --- a/src/Shooter.h +++ b/src/Shooter.h @@ -9,7 +9,9 @@ #define SRC_SHOOTER_H_ #define PICKUP_POWER 0.5 +#define LAUNCH_POWER 1 #define SPINUP_TIME 1.5 // seconds. +#define LAUNCH_TIME 0.5 class Shooter { @@ -20,13 +22,24 @@ public: * s2 is also for the pickup-mechanism and can be controlled independently. * */ - Shooter(CANTalon *s1, CANTalon *s2, CANTalon *r) + enum ShooterState + { + READY, + ON_FIRE, + SPINNINGUP, + LAUNCH, + LAUNCHING, + RESETTING + }; + + Shooter(CANTalon *s1, CANTalon *s2, CANTalon *r) { // shooterDrive = new RobotDrive(s1, s2); launcher = s1; pickup = s2; launch_spinny = r; ready = true; + state = READY; } /** @@ -78,6 +91,47 @@ public: the launch-spinny should be STOPPED. Start a Timer object counting When... too hard to write.. I emailed you a flow chart. */ + switch (state) + { + case READY: + { + state = SPINNINGUP; + launch_spinny->Set(-1); + launcher->Set(PICKUP_POWER); + pickup->Set(PICKUP_POWER); + shotClock.Reset(); + shotClock.Start(); + break; + } + case SPINNINGUP: + { + if (shotClock.Get() > SPINUP_TIME) + { + state = LAUNCH; + shotClock.Reset(); + shotClock.Start(); + } else + { + std::cout << "*Goku noises*\n"; + } + break; + } + case LAUNCH: + { + launch_spinny->Set(1); + state = LAUNCHING; + break; + } + case LAUNCHING: + { + if (shotClock.Get() > LAUNCH_TIME) + { + + state = RESETTING; + } + break; + } + } } @@ -109,6 +163,7 @@ private: CANTalon *launcher; CANTalon *pickup; CANTalon *launch_spinny; + ShooterState state; Timer shotClock; bool ready; From 19ed530a85478b10128986c15a55771d870f3779 Mon Sep 17 00:00:00 2001 From: Jason Cox Date: Sat, 13 Feb 2016 16:44:57 -0500 Subject: [PATCH 17/31] Initial Arm stuff --- src/Robot.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Robot.cpp b/src/Robot.cpp index 86b0612..399834c 100644 --- a/src/Robot.cpp +++ b/src/Robot.cpp @@ -20,7 +20,8 @@ class Robot: public IterativeRobot { Talon left_drive, right_drive; CANTalon shooter1, shooter2, - launch_spinny; + launch_spinny, + arms; RobotDrive drive; Shooter shooter; Joystick driver_stick, operator_stick; @@ -31,6 +32,7 @@ public: shooter1(11), // shooter drive 1 shooter2(10), // shooter drive 2 launch_spinny(12), + arms(13), drive(&left_drive, &right_drive), shooter( // initialize Shooter object. &shooter1, &shooter2, &launch_spinny), @@ -47,6 +49,7 @@ private: bool ramping; bool shooting; bool unjamming; + bool arming; float shooter_power; LiveWindow *lw = LiveWindow::GetInstance(); @@ -71,6 +74,7 @@ private: ramping = false; shooting = false; unjamming = false; + arming = false; shooter_power = 0; } @@ -218,6 +222,8 @@ private: shooter.StopShooter(); } + + // This code will become obsolete after the Shooter logic is complete. float opThrottle = SaneThrottle(operator_stick.GetThrottle()); From 0644b08316ac69b84d240fec2ac48dc92416317d Mon Sep 17 00:00:00 2001 From: Aidan Ferguson Date: Sat, 13 Feb 2016 16:46:09 -0500 Subject: [PATCH 18/31] removed a redundant if statement because I'm a doofus. --- src/Robot.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Robot.cpp b/src/Robot.cpp index 86b0612..1af8deb 100644 --- a/src/Robot.cpp +++ b/src/Robot.cpp @@ -117,10 +117,6 @@ private: //std::cout << "Ramp position: "<< launch_spinny.GetEncPosition() << std::endl; drive.ArcadeDrive(&driver_stick, true); - if (operator_stick.GetRawButton(TRIGGER)) - { - - } //bool rampDoing = false; // This is shit code for testing. Replace it with real code. if(!ramping && operator_stick.GetRawButton(RAMP_RAISE)) From fee9a526e12e32e1ced5fceaf5937b3913879f83 Mon Sep 17 00:00:00 2001 From: Jason Cox Date: Sat, 13 Feb 2016 16:47:57 -0500 Subject: [PATCH 19/31] Code for moving arms... boring --- src/Robot.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Robot.cpp b/src/Robot.cpp index 399834c..29f1b8f 100644 --- a/src/Robot.cpp +++ b/src/Robot.cpp @@ -222,7 +222,21 @@ private: shooter.StopShooter(); } - + if(!arming && driver_stick.GetRawButton(RAMP_RAISE)) + { + arming = true; + arms.Set(1); + } + else if(!arming && driver_stick.GetRawButton(RAMP_LOWER)) + { + arming = true; + arms.Set(-1); + } + else if(arming && !driver_stick.GetRawButton(RAMP_RAISE) && !driver_stick.GetRawButton(RAMP_LOWER)) + { + arming = false; + arms.Set(0); + } // This code will become obsolete after the Shooter logic is complete. float opThrottle = SaneThrottle(operator_stick.GetThrottle()); From dedcbe4bf7178d86e24df4387695e503353f9d45 Mon Sep 17 00:00:00 2001 From: Aidan Ferguson Date: Mon, 15 Feb 2016 15:14:20 -0500 Subject: [PATCH 20/31] Finished shooter switch. --- src/Shooter.h | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/Shooter.h b/src/Shooter.h index aeeab87..a8469b7 100644 --- a/src/Shooter.h +++ b/src/Shooter.h @@ -96,9 +96,9 @@ public: case READY: { state = SPINNINGUP; - launch_spinny->Set(-1); - launcher->Set(PICKUP_POWER); - pickup->Set(PICKUP_POWER); + launch_spinny->Set(0); + launcher->Set(LAUNCH_POWER); + pickup->Set(LAUNCH_POWER); shotClock.Reset(); shotClock.Start(); break; @@ -118,7 +118,7 @@ public: } case LAUNCH: { - launch_spinny->Set(1); + launch_spinny->Set(LAUNCH_POWER); state = LAUNCHING; break; } @@ -131,6 +131,19 @@ public: } break; } + case RESETTING: + { + launch_spinny->Set(0); + launcher->Set(0); + pickup->Set(0); + state = READY; + break; + } + case ON_FIRE: + { + std::cout << "Something is wrong with the launch sequence.\n"; + break; + } } } From 043707478d97497cc986677853d0b963975a10e5 Mon Sep 17 00:00:00 2001 From: Aidan Ferguson Date: Mon, 15 Feb 2016 20:14:48 -0500 Subject: [PATCH 21/31] fixed a typo --- src/Shooter.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Shooter.h b/src/Shooter.h index a8469b7..c8980f5 100644 --- a/src/Shooter.h +++ b/src/Shooter.h @@ -96,7 +96,7 @@ public: case READY: { state = SPINNINGUP; - launch_spinny->Set(0); + launch_spinny->Set(-1); launcher->Set(LAUNCH_POWER); pickup->Set(LAUNCH_POWER); shotClock.Reset(); From 6b3bcbe38d22d2ca306b96d6e86fdcf7d44ce92c Mon Sep 17 00:00:00 2001 From: Jason Cox Date: Fri, 19 Feb 2016 15:48:18 -0500 Subject: [PATCH 22/31] Sane code for the Demo --- src/Robot.cpp | 18 +++++++----------- src/Shooter.h | 4 ++-- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/Robot.cpp b/src/Robot.cpp index 5e25294..f735af2 100644 --- a/src/Robot.cpp +++ b/src/Robot.cpp @@ -1,13 +1,14 @@ #include "WPILib.h" #include "Shooter.h" +#include #ifndef BUTTON_LAYOUT #define BUTTON_LAYOUT #define TRIGGER 1 // Trigger button number #define THUMB 2 // Thumb button number -#define RAMP_RAISE 3 // Button 3 for Raising Ramp -#define RAMP_LOWER 4 // Button 4 to lower ramp. +#define RAMP_RAISE 5 // Button 3 for Raising Ramp +#define RAMP_LOWER 3 // Button 4 to lower ramp. #define UNJAM 11 #define DEADZONE_RADIUS 0.01 // Deadzone Radius prevents tiny twitches in the joystick's value from @@ -63,8 +64,8 @@ private: SmartDashboard::PutData("Auto Modes", chooser); shooter1.Enable(); shooter2.Enable(); - left_drive.SetInverted(true); - right_drive.SetInverted(true); + //left_drive.SetInverted(true); + //right_drive.SetInverted(true); //launch_spinny.SetInverted(true); inverting = false; pickupRunning = false; @@ -100,11 +101,7 @@ private: void AutonomousPeriodic() { - if(autoSelected == autoNameCustom){ - //Custom Auto goes here - } else { - //Default Auto goes here - } + } void TeleopInit() @@ -115,8 +112,7 @@ private: void TeleopPeriodic() { //std::cout << "Ramp position: "<< launch_spinny.GetEncPosition() << std::endl; - drive.ArcadeDrive(&driver_stick, true); - + drive.ArcadeDrive(-driver_stick.GetY(), -driver_stick.GetX() * 0.75); //bool rampDoing = false; // This is shit code for testing. Replace it with real code. if(!ramping && operator_stick.GetRawButton(RAMP_RAISE)) diff --git a/src/Shooter.h b/src/Shooter.h index c8980f5..31ec588 100644 --- a/src/Shooter.h +++ b/src/Shooter.h @@ -64,12 +64,12 @@ public: void LowerRamp() { - launch_spinny->Set(-1); + launch_spinny->Set(-0.5); } void RaiseRamp() { - launch_spinny->Set(1); + launch_spinny->Set(0.5); } void StopRamp() From bbcd3ed4943c38ba1f54bfe83cdc0b7d981c8b70 Mon Sep 17 00:00:00 2001 From: Aidan Ferguson Date: Sat, 20 Feb 2016 13:28:56 -0500 Subject: [PATCH 23/31] debug code to tell what the H-E-double-hockey-sticks the int the encoder returns is doing. --- src/Robot.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Robot.cpp b/src/Robot.cpp index ca3e071..75f2aba 100644 --- a/src/Robot.cpp +++ b/src/Robot.cpp @@ -118,7 +118,8 @@ private: void TeleopPeriodic() { - //std::cout << "Ramp position: "<< launch_spinny.GetEncPosition() << std::endl; + std::cout << "arm encoder position: " << arms.GetEncPosition() << std::endl; + std::cout << "arm encoder velocity: " << arms.GetEncVel() << std::endl; drive.ArcadeDrive(&driver_stick, true); //bool rampDoing = false; From 37458e6d5cce35ab9ac4d879154d22f33347f322 Mon Sep 17 00:00:00 2001 From: Aidan Ferguson Date: Sat, 20 Feb 2016 13:30:42 -0500 Subject: [PATCH 24/31] Spelling is the foundation upon which our society stands. --- src/Robot.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Robot.cpp b/src/Robot.cpp index 75f2aba..321ea98 100644 --- a/src/Robot.cpp +++ b/src/Robot.cpp @@ -168,7 +168,7 @@ private: /* * Run the Shooter only while the THUMB button is held down on the operator stick. * the 'pickupRunning' boolean is there to prevent the shooter from calling PickUp - * every itteration of the TeleopPeriodic method (once every 10ms!) + * every iteration of the TeleopPeriodic method (once every 10ms!) * The pickup is disabled when the thumb button is released, but the code still * has 'pickupRunning' as true. */ @@ -185,7 +185,7 @@ private: /* * The 'inverting' variable is used to make sure that the drive train isn't getting - * inverted every itteration of the TeleopPeriodic method while the button is held down. + * inverted every iteration of the TeleopPeriodic method while the button is held down. * This is important because the TeleopPeriodic method executes something like once every 10ms. * Thus, this if-else if pair make the button a toggle. */ From bcae44fdb1bc8b111c3503396f3ad22a76ea1bed Mon Sep 17 00:00:00 2001 From: john sandstedt Date: Sat, 20 Feb 2016 14:27:43 -0500 Subject: [PATCH 25/31] added ramp status to the smartdashboard --- src/Shooter.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/Shooter.h b/src/Shooter.h index c8980f5..5abaf94 100644 --- a/src/Shooter.h +++ b/src/Shooter.h @@ -65,11 +65,23 @@ public: void LowerRamp() { launch_spinny->Set(-1); + if(launch_spinny->Limits::kReverseLimit){ + SmartDashboard::PutNumber("ramp", 2); //going to put a circlar dial to show where the ramp could be + } else { + SmartDashboard::PutNumber("ramp", 1); + } + + } void RaiseRamp() { launch_spinny->Set(1); + if(launch_spinny->Limits::kForwardLimit){ + SmartDashboard::PutNumber("ramp", 0); //going to put a circlar dial to show where the ramp could be + } else { + SmartDashboard::PutNumber("ramp", 1); + } } void StopRamp() @@ -80,6 +92,11 @@ public: void BoostRamp() { launch_spinny->Set(1); + if(launch_spinny->Limits::kForwardLimit){ + SmartDashboard::PutNumber("ramp", 0); //going to put a circlar dial to show where the ramp could be + } else { + SmartDashboard::PutNumber("ramp", 1); + } } void Shoot() @@ -180,6 +197,7 @@ private: Timer shotClock; bool ready; + int fake_position; }; #endif /* SRC_SHOOTER_H_ */ From 98fa52cf2635b22f2bcda75afdd537713270d1b4 Mon Sep 17 00:00:00 2001 From: Aidan Ferguson Date: Sat, 20 Feb 2016 15:14:51 -0500 Subject: [PATCH 26/31] -launch_spinny +ramp --- src/Robot.cpp | 12 ++++++------ src/Shooter.h | 22 +++++++++++----------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/Robot.cpp b/src/Robot.cpp index 321ea98..2301648 100644 --- a/src/Robot.cpp +++ b/src/Robot.cpp @@ -20,7 +20,7 @@ class Robot: public IterativeRobot { Talon left_drive, right_drive; CANTalon shooter1, shooter2, - launch_spinny, + ramp, arms; RobotDrive drive; Shooter shooter; @@ -31,11 +31,11 @@ public: right_drive(1), // Right DriveTrain Talons plug // left wheel 2 shooter1(11), // shooter drive 1 shooter2(10), // shooter drive 2 - launch_spinny(12), + ramp(12), arms(13), drive(&left_drive, &right_drive), shooter( // initialize Shooter object. - &shooter1, &shooter2, &launch_spinny), + &shooter1, &shooter2, &ramp), driver_stick(0), // right stick (operator) operator_stick(1) // left stick (driver) { @@ -68,7 +68,7 @@ private: shooter2.Enable(); left_drive.SetInverted(true); right_drive.SetInverted(true); - //launch_spinny.SetInverted(true); + //ramp.SetInverted(true); inverting = false; pickupRunning = false; ramping = false; @@ -127,14 +127,14 @@ private: if(!ramping && operator_stick.GetRawButton(RAMP_RAISE)) { std::cout << "Raising Ramp."; - //launch_spinny.Set(1); + //ramp.Set(1); shooter.RaiseRamp(); ramping =true; } else if(!ramping && operator_stick.GetRawButton(RAMP_LOWER)) { std::cout << "Lowering Ramp."; - //launch_spinny.Set(-1); + //ramp.Set(-1); shooter.LowerRamp(); ramping = true; } diff --git a/src/Shooter.h b/src/Shooter.h index aeeab87..344f38e 100644 --- a/src/Shooter.h +++ b/src/Shooter.h @@ -37,7 +37,7 @@ public: // shooterDrive = new RobotDrive(s1, s2); launcher = s1; pickup = s2; - launch_spinny = r; + ramp = r; ready = true; state = READY; } @@ -51,35 +51,35 @@ public: { delete launcher; delete pickup; - delete launch_spinny; + delete ramp; } void StopShooter() { ready = true; - launch_spinny->Set(0); + ramp->Set(0); launcher->Set(0); pickup->Set(0); } void LowerRamp() { - launch_spinny->Set(-1); + ramp->Set(-1); } void RaiseRamp() { - launch_spinny->Set(1); + ramp->Set(1); } void StopRamp() { - launch_spinny->Set(0); + ramp->Set(0); } void BoostRamp() { - launch_spinny->Set(1); + ramp->Set(1); } void Shoot() @@ -96,7 +96,7 @@ public: case READY: { state = SPINNINGUP; - launch_spinny->Set(-1); + ramp->Set(-1); launcher->Set(PICKUP_POWER); pickup->Set(PICKUP_POWER); shotClock.Reset(); @@ -118,7 +118,7 @@ public: } case LAUNCH: { - launch_spinny->Set(1); + ramp->Set(1); state = LAUNCHING; break; } @@ -139,7 +139,7 @@ public: { pickup->Set((float) (state * PICKUP_POWER)); launcher->Set((float) (state * PICKUP_POWER * -1)); - //launch_spinny->Set(-1.0*PICKUP_POWER); + //ramp->Set(-1.0*PICKUP_POWER); //std::cout << "picking up!\n"; } @@ -162,7 +162,7 @@ private: //RobotDrive *shooterDrive; CANTalon *launcher; CANTalon *pickup; - CANTalon *launch_spinny; + CANTalon *ramp; ShooterState state; Timer shotClock; From d0ebd066cb169aa1a40fbc9b9ed942b34449fb02 Mon Sep 17 00:00:00 2001 From: dkbug Date: Sat, 20 Feb 2016 16:53:38 -0500 Subject: [PATCH 27/31] make ramp more sensitive. --- src/Shooter.h | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/Shooter.h b/src/Shooter.h index 344f38e..06f139f 100644 --- a/src/Shooter.h +++ b/src/Shooter.h @@ -64,24 +64,18 @@ public: void LowerRamp() { - ramp->Set(-1); + ramp->Set(-.5); } void RaiseRamp() { - ramp->Set(1); + ramp->Set(0.5); } void StopRamp() { ramp->Set(0); } - - void BoostRamp() - { - ramp->Set(1); - } - void Shoot() { // TODO: Shooter Logic should go as follows: From bff46f5476bfd698885ee799c4aff73987a811db Mon Sep 17 00:00:00 2001 From: dkbug Date: Sat, 20 Feb 2016 17:01:51 -0500 Subject: [PATCH 28/31] fixed some git conflicts --- src/Shooter.h | 43 +++++-------------------------------------- 1 file changed, 5 insertions(+), 38 deletions(-) diff --git a/src/Shooter.h b/src/Shooter.h index d8bf4bc..0b9d9ee 100644 --- a/src/Shooter.h +++ b/src/Shooter.h @@ -64,51 +64,28 @@ public: void LowerRamp() { -<<<<<<< HEAD - launch_spinny->Set(-0.5); - if(launch_spinny->Limits::kReverseLimit){ + ramp->Set(-0.5); + if(ramp->Limits::kReverseLimit){ SmartDashboard::PutNumber("ramp", 2); //going to put a circlar dial to show where the ramp could be } else { SmartDashboard::PutNumber("ramp", 1); } - -======= - ramp->Set(-.5); ->>>>>>> arms } void RaiseRamp() { -<<<<<<< HEAD - launch_spinny->Set(0.5); - if(launch_spinny->Limits::kForwardLimit){ + ramp->Set(0.5); + if(ramp->Limits::kForwardLimit){ SmartDashboard::PutNumber("ramp", 0); //going to put a circlar dial to show where the ramp could be } else { SmartDashboard::PutNumber("ramp", 1); } -======= - ramp->Set(0.5); ->>>>>>> arms } void StopRamp() { ramp->Set(0); } -<<<<<<< HEAD - - void BoostRamp() - { - launch_spinny->Set(1); - if(launch_spinny->Limits::kForwardLimit){ - SmartDashboard::PutNumber("ramp", 0); //going to put a circlar dial to show where the ramp could be - } else { - SmartDashboard::PutNumber("ramp", 1); - } - } - -======= ->>>>>>> arms void Shoot() { // TODO: Shooter Logic should go as follows: @@ -123,15 +100,9 @@ public: case READY: { state = SPINNINGUP; -<<<<<<< HEAD - launch_spinny->Set(-1); - launcher->Set(LAUNCH_POWER); - pickup->Set(LAUNCH_POWER); -======= ramp->Set(-1); launcher->Set(PICKUP_POWER); pickup->Set(PICKUP_POWER); ->>>>>>> arms shotClock.Reset(); shotClock.Start(); break; @@ -151,11 +122,7 @@ public: } case LAUNCH: { -<<<<<<< HEAD - launch_spinny->Set(LAUNCH_POWER); -======= ramp->Set(1); ->>>>>>> arms state = LAUNCHING; break; } @@ -170,7 +137,7 @@ public: } case RESETTING: { - launch_spinny->Set(0); + ramp->Set(0); launcher->Set(0); pickup->Set(0); state = READY; From d914ecf5e01e1b8368c6bb27bf2734ddd0525733 Mon Sep 17 00:00:00 2001 From: dkbug Date: Sat, 20 Feb 2016 17:12:23 -0500 Subject: [PATCH 29/31] invert the driving --- src/Robot.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Robot.cpp b/src/Robot.cpp index 6d0e6b1..f93c676 100644 --- a/src/Robot.cpp +++ b/src/Robot.cpp @@ -67,8 +67,8 @@ private: SmartDashboard::PutData("Auto Modes", chooser); shooter1.Enable(); shooter2.Enable(); - //left_drive.SetInverted(true); - //right_drive.SetInverted(true); + left_drive.SetInverted(true); + right_drive.SetInverted(true); //ramp.SetInverted(true); inverting = false; pickupRunning = false; @@ -117,7 +117,7 @@ private: { std::cout << "arm encoder position: " << arms.GetEncPosition() << std::endl; std::cout << "arm encoder velocity: " << arms.GetEncVel() << std::endl; - drive.ArcadeDrive(&driver_stick, true); + drive.ArcadeDrive(-driver_stick.GetY(), -driver_stick.GetX()*0.75); //bool rampDoing = false; // This is shit code for testing. Replace it with real code. From 4d13792643cca95edb7a8493b285b4e653a8d617 Mon Sep 17 00:00:00 2001 From: Jason Cox Date: Sat, 20 Feb 2016 18:15:28 -0500 Subject: [PATCH 30/31] Tweaking pickup --- src/Robot.cpp | 9 ++++++--- src/Shooter.h | 9 +++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/Robot.cpp b/src/Robot.cpp index f93c676..17f8986 100644 --- a/src/Robot.cpp +++ b/src/Robot.cpp @@ -155,13 +155,16 @@ private: unjamming = true; shooter.Unjam(); } - else if(unjamming && !operator_stick.GetRawButton(UNJAM)) + else if(!unjamming && operator_stick.GetRawButton(TRIGGER)) + { + shooter.ShootLow(); + unjamming = true; + } + else if(unjamming && !operator_stick.GetRawButton(UNJAM) && !operator_stick.GetRawButton(TRIGGER)) { shooter.PickUp(false); unjamming = false; } - - /* * Run the Shooter only while the THUMB button is held down on the operator stick. * the 'pickupRunning' boolean is there to prevent the shooter from calling PickUp diff --git a/src/Shooter.h b/src/Shooter.h index 0b9d9ee..2b729cc 100644 --- a/src/Shooter.h +++ b/src/Shooter.h @@ -8,7 +8,7 @@ #ifndef SRC_SHOOTER_H_ #define SRC_SHOOTER_H_ -#define PICKUP_POWER 0.5 +#define PICKUP_POWER 0.75 #define LAUNCH_POWER 1 #define SPINUP_TIME 1.5 // seconds. #define LAUNCH_TIME 0.5 @@ -155,7 +155,7 @@ public: void PickUp(bool state = true) { pickup->Set((float) (state * PICKUP_POWER)); - launcher->Set((float) (state * PICKUP_POWER * -1)); + launcher->Set((float) (state * PICKUP_POWER * -0.75)); //ramp->Set(-1.0*PICKUP_POWER); //std::cout << "picking up!\n"; } @@ -168,6 +168,11 @@ public: pickup->Set(-1 * PICKUP_POWER); } + void ShootLow() + { + pickup->Set(-1); + } + void SetPower(float power) { pickup->Set(power); From 62819bc05c39580c2fd97b609febd209e8e343ad Mon Sep 17 00:00:00 2001 From: Jason Cox Date: Sat, 20 Feb 2016 18:32:40 -0500 Subject: [PATCH 31/31] More Tweaking --- src/Robot.cpp | 4 ++-- src/Shooter.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Robot.cpp b/src/Robot.cpp index 17f8986..a8b3198 100644 --- a/src/Robot.cpp +++ b/src/Robot.cpp @@ -208,7 +208,7 @@ private: * Every time the method is called. This cannot be a loop in the Shoot method because * that would lock the robot every time the trigger is hit. */ - if(operator_stick.GetRawButton(TRIGGER)) + /*if(operator_stick.GetRawButton(TRIGGER)) { shooting = true; shooter.Shoot(); @@ -217,7 +217,7 @@ private: { shooting = false; shooter.StopShooter(); - } + }*/ if(!arming && driver_stick.GetRawButton(RAMP_RAISE)) { diff --git a/src/Shooter.h b/src/Shooter.h index 2b729cc..82e4ace 100644 --- a/src/Shooter.h +++ b/src/Shooter.h @@ -165,7 +165,7 @@ public: */ void Unjam() { - pickup->Set(-1 * PICKUP_POWER); + pickup->Set(PICKUP_POWER * -0.75); } void ShootLow()