From 71bdaab9bb7b41c9ff59792638a9e298e62a0a8e Mon Sep 17 00:00:00 2001 From: Jason Cox Date: Tue, 9 Feb 2016 17:22:17 -0500 Subject: [PATCH] Added some comments and sanity to the new robot project. --- .project | 1 + src/Robot.cpp | 26 ++++++++++++++++++-------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/.project b/.project index a419617..69c1953 100644 --- a/.project +++ b/.project @@ -7,6 +7,7 @@ org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, diff --git a/src/Robot.cpp b/src/Robot.cpp index a2093bc..224e2f4 100644 --- a/src/Robot.cpp +++ b/src/Robot.cpp @@ -1,11 +1,13 @@ -#include "../wpilib/WPILib.h" +#include "WPILib.h" #include "Shooter.h" #ifndef BUTTON_LAYOUT #define BUTTON_LAYOUT -#define TRIGGER 1 // I have no idea what the right button number is... -#define THUMB 2 +#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. #endif // BUTTON_LAYOUT @@ -36,6 +38,9 @@ public: } 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. + LiveWindow *lw = LiveWindow::GetInstance(); SendableChooser *chooser; const std::string autoNameDefault = "Default"; @@ -62,6 +67,8 @@ private: */ void AutonomousInit() { + shooter.CalibrateRamp(); + autoSelected = *((std::string*)chooser->GetSelected()); //std::string autoSelected = SmartDashboard::GetString("Auto Selector", autoNameDefault); std::cout << "Auto selected: " << autoSelected << std::endl; @@ -84,18 +91,19 @@ private: void TeleopInit() { - + shooter.CalibrateRamp(); } void TeleopPeriodic() { drive.ArcadeDrive(&driver_stick); - if(operator_stick.GetRawButton(3)) + // This is shit code for testing. Replace it with real code. + if(operator_stick.GetRawButton(RAMP_RAISE)) { ramp.Set(1); } - else if(operator_stick.GetRawButton(4)) + else if(operator_stick.GetRawButton(RAMP_LOWER)) { ramp.Set(-1); } @@ -104,13 +112,15 @@ private: ramp.Set(0); } - if(operator_stick.GetRawButton(THUMB)) + if(operator_stick.GetRawButton(THUMB) && !pickupRunning) { shooter.PickUp(); + pickupRunning = true; } - else + else if(pickupRunning) { shooter.PickUp(false); + pickupRunning = false; }