From e2a9a695ae0360862382ac57c1dab0fbb7ba38b3 Mon Sep 17 00:00:00 2001 From: Adam Long Date: Sat, 7 Feb 2015 14:17:20 +0000 Subject: [PATCH 01/40] Added pretest code (not working) --- Commands/Autonomous/Autonomous.cpp | 17 ++------------ Commands/Test/Check.cpp | 11 +++++++++ Commands/Test/Check.h | 20 ++++++++++++++++ Commands/Test/CheckDrive.cpp | 37 ++++++++++++++++++++++++++++++ Commands/Test/CheckDrive.h | 20 ++++++++++++++++ Subsystems/Drivetrain.cpp | 20 ++++++++++++++++ Subsystems/Drivetrain.h | 7 ++++++ 7 files changed, 117 insertions(+), 15 deletions(-) create mode 100644 Commands/Test/Check.cpp create mode 100644 Commands/Test/Check.h create mode 100644 Commands/Test/CheckDrive.cpp create mode 100644 Commands/Test/CheckDrive.h diff --git a/Commands/Autonomous/Autonomous.cpp b/Commands/Autonomous/Autonomous.cpp index c3e2e3b..eaf9669 100644 --- a/Commands/Autonomous/Autonomous.cpp +++ b/Commands/Autonomous/Autonomous.cpp @@ -1,20 +1,7 @@ #include "Autonomous.h" -#include "AutoDrive.h" -#include #include "Commands/CommandGroup.h" #include "../../DentRobot.h" -Autonomous::Autonomous() : CommandGroup("Autonomous"){ +#include "" +Autonomous::Autonomous(){ AddSequential(new AutoDrive()); } -void Autonomous::Initialize(){ -} -void Autonomous::Execute(){ -} -bool Autonomous::IsFinished(){ - return false; -} -void Autonomous::End(){ -} -void Autonomous::Interrupted(){ - End(); -} diff --git a/Commands/Test/Check.cpp b/Commands/Test/Check.cpp new file mode 100644 index 0000000..6151d27 --- /dev/null +++ b/Commands/Test/Check.cpp @@ -0,0 +1,11 @@ +#include "Check.h" +#include "Commands/CommandGroup.h" +#include "../../DentRobot.h" +#include "../../RobotMap.h" +#include "CheckDrive.h" +Check::Check(){ + AddSequential(new CheckDrive(DRIVE_FRONT_LEFT_CAN)); + AddSequential(new CheckDrive(DRIVE_FRONT_RIGHT_CAN)); + AddSequential(new CheckDrive(DRIVE_BACK_LEFT_CAN)); + AddSequential(new CheckDrive(DRIVE_BACK_RIGHT_CAN)); +} diff --git a/Commands/Test/Check.h b/Commands/Test/Check.h new file mode 100644 index 0000000..37b14bf --- /dev/null +++ b/Commands/Test/Check.h @@ -0,0 +1,20 @@ +#ifndef CHECK_H +#define CHECK_H + +#include "Commands/Command.h" +#include "../../CommandBase.h" +#include "../../DentRobot.h" +#include "WPILib.h" + +class Check: public CommandGroup{ + private: + int motor; + public: + Check(); + void Initialize(); + void Execute(); + bool IsFinished(); + void End(); + void Interrupted(); +}; +#endif diff --git a/Commands/Test/CheckDrive.cpp b/Commands/Test/CheckDrive.cpp new file mode 100644 index 0000000..73aff31 --- /dev/null +++ b/Commands/Test/CheckDrive.cpp @@ -0,0 +1,37 @@ +#include "CheckDrive.h" +#include +#include "Commands/CommandGroup.h" +#include "../../DentRobot.h" +#include "../../RobotMap.h" +CheckDrive::CheckDrive(int motorID) : CommandGroup("CheckDrive"){ + Requires(DentRobot::drivetrain); +} +void CheckDrive::Initialize(){ + SetTimeout(1.0); +} +void CheckDrive::Execute(){ + switch(motor){ + case DRIVE_FRONT_LEFT_CAN: + DentRobot::drivetrain->TestMotor(DentRobot::drivetrain->FRONTLEFT,1); + break; + case DRIVE_FRONT_RIGHT_CAN: + DentRobot::drivetrain->TestMotor(DentRobot::drivetrain->FRONTRIGHT,1); + break; + case DRIVE_BACK_LEFT_CAN: + DentRobot::drivetrain->TestMotor(DentRobot::drivetrain->BACKLEFT,1); + break; + case DRIVE_BACK_RIGHT_CAN: + DentRobot::drivetrain->TestMotor(DentRobot::drivetrain->BACKRIGHT,1); + break; + default: + break; + } +} +bool CheckDrive::IsFinished(){ + return false; +} +void CheckDrive::End(){ +} +void CheckDrive::Interrupted(){ + End(); +} diff --git a/Commands/Test/CheckDrive.h b/Commands/Test/CheckDrive.h new file mode 100644 index 0000000..ec76d13 --- /dev/null +++ b/Commands/Test/CheckDrive.h @@ -0,0 +1,20 @@ +#ifndef CHECKDRIVE_H +#define CHECKDRIVE_H + +#include "Commands/Command.h" +#include "../../CommandBase.h" +#include "../../DentRobot.h" +#include "WPILib.h" + +class CheckDrive: public CommandGroup{ + private: + int motor; + public: + CheckDrive(int); + void Initialize(); + void Execute(); + bool IsFinished(); + void End(); + void Interrupted(); +}; +#endif diff --git a/Subsystems/Drivetrain.cpp b/Subsystems/Drivetrain.cpp index 80df4e7..cdb094e 100644 --- a/Subsystems/Drivetrain.cpp +++ b/Subsystems/Drivetrain.cpp @@ -20,3 +20,23 @@ void Drivetrain::DriveMecanum(float x, float y, float z, float sensitivity, floa rightRear->Set((correctX + correctY - correctZ)); leftRear->Set((-correctX + correctY + correctZ)*-1); } + +//Used in pretest +void Drivetrain::TestMotor(e_motors motor, float power){ + switch(motor){ + case FRONTRIGHT: + rightFront->Set(power); + break; + case FRONTLEFT: + leftFront->Set(power); + break; + case BACKRIGHT: + rightRear->Set(power); + break; + case BACKLEFT: + leftRear->Set(power); + break; + default: + break; + } +} diff --git a/Subsystems/Drivetrain.h b/Subsystems/Drivetrain.h index 81a5168..d4ca877 100644 --- a/Subsystems/Drivetrain.h +++ b/Subsystems/Drivetrain.h @@ -8,8 +8,15 @@ class Drivetrain: public Subsystem{ RobotDrive *drive; public: Drivetrain(); + enum e_motors{ + FRONTRIGHT, + FRONTLEFT, + BACKRIGHT, + BACKLEFT + }; void InitDefaultCommand(); void DriveMecanum(float,float,float,float,float); void DriveArcade(float, float); + void TestMotor(e_motors,float); }; #endif From fb7734f443323731d169bd77429ac2b656cc245a Mon Sep 17 00:00:00 2001 From: Adam Long Date: Fri, 13 Feb 2015 16:08:19 +0000 Subject: [PATCH 02/40] Fixed drivecheck motor var --- Commands/Test/CheckDrive.cpp | 1 + Commands/Test/CheckRobot.cpp | 2 +- Commands/Test/CheckRobot.h | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Commands/Test/CheckDrive.cpp b/Commands/Test/CheckDrive.cpp index 73aff31..d51d658 100644 --- a/Commands/Test/CheckDrive.cpp +++ b/Commands/Test/CheckDrive.cpp @@ -5,6 +5,7 @@ #include "../../RobotMap.h" CheckDrive::CheckDrive(int motorID) : CommandGroup("CheckDrive"){ Requires(DentRobot::drivetrain); + motor = motorID; } void CheckDrive::Initialize(){ SetTimeout(1.0); diff --git a/Commands/Test/CheckRobot.cpp b/Commands/Test/CheckRobot.cpp index 6d98ccd..871c51b 100644 --- a/Commands/Test/CheckRobot.cpp +++ b/Commands/Test/CheckRobot.cpp @@ -10,4 +10,4 @@ CheckRobot::CheckRobot(){ AddSequential(new CheckDrive(DRIVE_BACK_LEFT_CAN)); AddSequential(new CheckDrive(DRIVE_BACK_RIGHT_CAN)); } -// vim: ts2:sw=2:et +// vim: ts=2:sw=2:et diff --git a/Commands/Test/CheckRobot.h b/Commands/Test/CheckRobot.h index 702478d..d0df68e 100644 --- a/Commands/Test/CheckRobot.h +++ b/Commands/Test/CheckRobot.h @@ -11,4 +11,4 @@ class CheckRobot: public CommandGroup{ CheckRobot(); }; #endif -// vim: ts2:sw=2:et +// vim: ts=2:sw=2:et From a439d2ff5ee31264fcdb79abe37280e86deae79f Mon Sep 17 00:00:00 2001 From: Adam Long Date: Thu, 19 Feb 2015 15:28:29 +0000 Subject: [PATCH 03/40] Moved code version to robotmap (also test commit for jenkins --- DentRobot.cpp | 2 +- RobotMap.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/DentRobot.cpp b/DentRobot.cpp index e1662e8..4cc4c1d 100644 --- a/DentRobot.cpp +++ b/DentRobot.cpp @@ -21,7 +21,7 @@ DentRobot::DentRobot(){ printf("Initialized\n"); } void DentRobot::RobotInit(){ - //SmartDashboard::PutNumber("CodeVersion",1.0); + SmartDashboard::PutNumber("CodeVersion",CODE_VERSION); } void DentRobot::DisabledPeriodic(){ Scheduler::GetInstance()->Run(); diff --git a/RobotMap.h b/RobotMap.h index d797f4f..d17b0b0 100644 --- a/RobotMap.h +++ b/RobotMap.h @@ -3,6 +3,8 @@ #include "WPILib.h" +#define CODE_VERSION 1.0 + // Elevator #define ELEVATOR_CAN 1 #define ELEVATOR_BOTTOM_DIO 9 From 772711f5ea98334aae7feb28d947950fb776fc96 Mon Sep 17 00:00:00 2001 From: Adam Long Date: Thu, 19 Feb 2015 17:33:23 +0000 Subject: [PATCH 04/40] Moved code version to robotmap.h --- DentRobot.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/DentRobot.cpp b/DentRobot.cpp index 4cc4c1d..0f37cef 100644 --- a/DentRobot.cpp +++ b/DentRobot.cpp @@ -1,5 +1,6 @@ #include "DentRobot.h" #include "OI.h" +#include "RobotMap.h" #include "Commands/Autonomous/Autonomous.h" OI* DentRobot::oi=NULL; Collector* DentRobot::collector=NULL; From 4da1b1d22b1ed6ad0ca4870b6ad27082cacfcd34 Mon Sep 17 00:00:00 2001 From: Adam Long Date: Thu, 19 Feb 2015 20:16:09 +0000 Subject: [PATCH 05/40] Updated makefile to not build for deploy/debug configurations --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 9bf4a49..56d6863 100644 --- a/Makefile +++ b/Makefile @@ -18,10 +18,10 @@ all : $(OBJECTS) clean: $(CLEANSER) $(OBJECTS) bin/FRCUserProgram -deploy: all +deploy: @cat bin/FRCUserProgram | ssh admin@$(REMOTEIP) 'cat > /home/lvuser/FRCUserProgram2&&rm /home/lvuser/FRCUserProgram;mv /home/lvuser/FRCUserProgram2 /home/lvuser/FRCUserProgram&&. /etc/profile.d/natinst-path.sh;chmod a+x /home/lvuser/FRCUserProgram' -debug: all +debug: @cat bin/FRCUserProgram | ssh admin@$(REMOTEIP) 'cat > /home/lvuser/FRCUserProgram2&&rm /home/lvuser/FRCUserProgram;mv /home/lvuser/FRCUserProgram2 /home/lvuser/FRCUserProgram&&. /etc/profile.d/natinst-path.sh;chmod a+x /home/lvuser/FRCUserProgram;/home/lvuser/run.sh' putkey: From a1faec4c2c978201b35ef543d03617e28281ce4f Mon Sep 17 00:00:00 2001 From: Adam Long Date: Fri, 20 Feb 2015 13:24:50 +0000 Subject: [PATCH 06/40] Added readme file (needs actual words) --- README.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..d7019d8 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +2015 FRC Robot From f905bf5ea2219ed44f18737288bd60247f85fb90 Mon Sep 17 00:00:00 2001 From: Adam Long Date: Fri, 20 Feb 2015 13:28:49 +0000 Subject: [PATCH 07/40] Improved debugging --- DentRobot.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DentRobot.cpp b/DentRobot.cpp index 0f37cef..3a21d69 100644 --- a/DentRobot.cpp +++ b/DentRobot.cpp @@ -19,7 +19,7 @@ DentRobot::DentRobot(){ CameraServer::GetInstance()->StartAutomaticCapture("cam0"); //SmartDashboard::PutNumber("Auto Wait Time", 1.0); //SmartDashboard::PutNumber("Auto Sequence", 0); - printf("Initialized\n"); + printf("The robot is on\n"); } void DentRobot::RobotInit(){ SmartDashboard::PutNumber("CodeVersion",CODE_VERSION); From a75a5b48673e7e76e25f95fd53efef680b3f904b Mon Sep 17 00:00:00 2001 From: Adam Long Date: Fri, 20 Feb 2015 13:43:31 +0000 Subject: [PATCH 08/40] Added auto running debug message --- DentRobot.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/DentRobot.cpp b/DentRobot.cpp index 3a21d69..0eb8ffc 100644 --- a/DentRobot.cpp +++ b/DentRobot.cpp @@ -33,6 +33,7 @@ void DentRobot::AutonomousInit(){ } } void DentRobot::AutonomousPeriodic(){ + printf("Running auto.\n"); Scheduler::GetInstance()->Run(); } void DentRobot::TeleopInit(){ From ce28d23c4b3aa0ece677c52b14a34d92576ce124 Mon Sep 17 00:00:00 2001 From: Adam Long Date: Fri, 20 Feb 2015 16:27:39 +0000 Subject: [PATCH 09/40] Added solenoid subsystem --- Subsystems/Pnuematics.cpp | 19 +++++++++++++++++++ Subsystems/Pnuematics.h | 15 +++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 Subsystems/Pnuematics.cpp create mode 100644 Subsystems/Pnuematics.h diff --git a/Subsystems/Pnuematics.cpp b/Subsystems/Pnuematics.cpp new file mode 100644 index 0000000..d2840a2 --- /dev/null +++ b/Subsystems/Pnuematics.cpp @@ -0,0 +1,19 @@ +#include "Pnuematics.h" +#include "../RobotMap.h" + +Pnuematics::Pnuematics() : Subsystem("Pnuematics"){ + solenoid1 = new Solenoid(BINELEVATOR_SOLDENOID_ONE); + solenoid2 = new Solenoid(BINELEVATOR_SOLDENOID_TWO); +} +void Pnuematics::InitDefaultCommand(){ +} +void Pnuematics::SetOpen(bool k){ + if(k){ + solenoid1->Set(true); + solenoid2->Set(false); + }else{ + solenoid1->Set(false); + solenoid2->Set(true); + } +} +// vim: ts=2:sw=2:et diff --git a/Subsystems/Pnuematics.h b/Subsystems/Pnuematics.h new file mode 100644 index 0000000..cbc0152 --- /dev/null +++ b/Subsystems/Pnuematics.h @@ -0,0 +1,15 @@ +#ifndef PNUEMATICS_H +#define PNUEMATICS_H + +#include "WPILib.h" +class Pnuematics: public Subsystem +{ + private: + Solenoid *solenoid1, *solenoid2; + public: + Pnuematics(); + void InitDefaultCommand(); + void SetOpen(bool); +}; +#endif +// vim: ts=2:sw=2:et From 0a15d9259891d30a9eb88ec5d60d5549da5c64f1 Mon Sep 17 00:00:00 2001 From: Adam Long Date: Fri, 20 Feb 2015 16:34:30 +0000 Subject: [PATCH 10/40] Actually committing the new RobotMap.h file this time --- RobotMap.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/RobotMap.h b/RobotMap.h index d17b0b0..13a443d 100644 --- a/RobotMap.h +++ b/RobotMap.h @@ -20,6 +20,8 @@ #define BINELEVATOR_TOP_DIO 8 #define BINELEVATOR_ENCODERA 10 #define BINELEVATOR_ENCODERB 11 +#define BINELEVATOR_SOLDENOID_ONE 1 +#define BINELEVATOR_SOLDENOID_TWO 1 // Drivetrain #define DRIVE_FRONT_LEFT_CAN 2 From d515a11cd68d5e1ca689680ecf68e526434b327e Mon Sep 17 00:00:00 2001 From: Adam Long Date: Fri, 20 Feb 2015 20:54:41 +0000 Subject: [PATCH 11/40] Added BinClose and BinOpen commands --- CommandBase.cpp | 3 +++ CommandBase.h | 2 ++ Commands/BinElevator/BinCloseArms.cpp | 21 +++++++++++++++++++ Commands/BinElevator/BinCloseArms.h | 18 ++++++++++++++++ Commands/BinElevator/BinOpenArms.cpp | 21 +++++++++++++++++++ Commands/BinElevator/BinOpenArms.h | 18 ++++++++++++++++ DentRobot.cpp | 2 ++ DentRobot.h | 2 ++ RobotMap.h | 2 +- Subsystems/{Pnuematics.cpp => Pneumatics.cpp} | 8 +++---- Subsystems/{Pnuematics.h => Pneumatics.h} | 8 +++---- 11 files changed, 96 insertions(+), 9 deletions(-) create mode 100644 Commands/BinElevator/BinCloseArms.cpp create mode 100644 Commands/BinElevator/BinCloseArms.h create mode 100644 Commands/BinElevator/BinOpenArms.cpp create mode 100644 Commands/BinElevator/BinOpenArms.h rename Subsystems/{Pnuematics.cpp => Pneumatics.cpp} (66%) rename Subsystems/{Pnuematics.h => Pneumatics.h} (63%) diff --git a/CommandBase.cpp b/CommandBase.cpp index c4defc3..ef64dae 100644 --- a/CommandBase.cpp +++ b/CommandBase.cpp @@ -3,10 +3,12 @@ #include "Subsystems/Collector.h" #include "Subsystems/Elevator.h" #include "Subsystems/BinElevator.h" +#include "Subsystems/Pneumatics.h" Drivetrain* CommandBase::drivetrain = NULL; Collector* CommandBase::collector = NULL; Elevator* CommandBase::elevator = NULL; BinElevator* CommandBase::binElevator = NULL; +Pneumatics* CommandBase::pneumatics=NULL; OI* CommandBase::oi = NULL; CommandBase::CommandBase(char const *name) : Command(name) { } @@ -17,6 +19,7 @@ void CommandBase::init(){ collector = new Collector(); elevator = new Elevator(); binElevator = new BinElevator(); + pneumatics = new Pneumatics(); oi = new OI(); } // vim: ts=2:sw=2:et diff --git a/CommandBase.h b/CommandBase.h index 7443ebd..cb7453b 100644 --- a/CommandBase.h +++ b/CommandBase.h @@ -6,6 +6,7 @@ #include "Subsystems/Collector.h" #include "Subsystems/Elevator.h" #include "Subsystems/BinElevator.h" +#include "Subsystems/Pneumatics.h" #include "OI.h" #include "WPILib.h" @@ -18,6 +19,7 @@ class CommandBase: public Command { static Collector *collector; static Elevator *elevator; static BinElevator *binElevator; + static Pneumatics *pneumatics; static OI *oi; }; #endif diff --git a/Commands/BinElevator/BinCloseArms.cpp b/Commands/BinElevator/BinCloseArms.cpp new file mode 100644 index 0000000..1cb292f --- /dev/null +++ b/Commands/BinElevator/BinCloseArms.cpp @@ -0,0 +1,21 @@ +#include "BinCloseArms.h" +#include "../../DentRobot.h" +#include "../../OI.h" +BinCloseArms::BinCloseArms() : Command("BinCloseArms"){ +} +void BinCloseArms::Initialize(){ + //Should never need to use this + SetTimeout(0.5); +} +void BinCloseArms::Execute(){ + DentRobot::pneumatics->SetOpen(true); +} +bool BinCloseArms::IsFinished(){ + return true; +} +void BinCloseArms::End(){ +} +void BinCloseArms::Interrupted(){ + End(); +} +// vim: ts=2:sw=2:et diff --git a/Commands/BinElevator/BinCloseArms.h b/Commands/BinElevator/BinCloseArms.h new file mode 100644 index 0000000..b6322b9 --- /dev/null +++ b/Commands/BinElevator/BinCloseArms.h @@ -0,0 +1,18 @@ +#ifndef BINCLOSEARMS_H +#define BINCLOSEARMS_H + +#include "Commands/Command.h" +#include "WPILib.h" + +class BinCloseArms: public Command{ + public: + BinCloseArms(); + void Initialize(); + void Execute(); + bool IsFinished(); + void End(); + void Interrupted(); +}; + +#endif +// vim: ts=2:sw=2:et diff --git a/Commands/BinElevator/BinOpenArms.cpp b/Commands/BinElevator/BinOpenArms.cpp new file mode 100644 index 0000000..c8936a4 --- /dev/null +++ b/Commands/BinElevator/BinOpenArms.cpp @@ -0,0 +1,21 @@ +#include "BinOpenArms.h" +#include "../../DentRobot.h" +#include "../../OI.h" +BinOpenArms::BinOpenArms() : Command("BinOpenArms"){ +} +void BinOpenArms::Initialize(){ + //Should never need to use this + SetTimeout(0.5); +} +void BinOpenArms::Execute(){ + DentRobot::pneumatics->SetOpen(true); +} +bool BinOpenArms::IsFinished(){ + return true; +} +void BinOpenArms::End(){ +} +void BinOpenArms::Interrupted(){ + End(); +} +// vim: ts=2:sw=2:et diff --git a/Commands/BinElevator/BinOpenArms.h b/Commands/BinElevator/BinOpenArms.h new file mode 100644 index 0000000..533d71c --- /dev/null +++ b/Commands/BinElevator/BinOpenArms.h @@ -0,0 +1,18 @@ +#ifndef BINOPENARMS_H +#define BINOPENARMS_H + +#include "Commands/Command.h" +#include "WPILib.h" + +class BinOpenArms: public Command{ + public: + BinOpenArms(); + void Initialize(); + void Execute(); + bool IsFinished(); + void End(); + void Interrupted(); +}; + +#endif +// vim: ts=2:sw=2:et diff --git a/DentRobot.cpp b/DentRobot.cpp index 0eb8ffc..1b2d642 100644 --- a/DentRobot.cpp +++ b/DentRobot.cpp @@ -8,12 +8,14 @@ Drivetrain* DentRobot::drivetrain=NULL; Elevator* DentRobot::elevator=NULL; BinElevator* DentRobot::binElevator=NULL; CommandGroup* DentRobot::aut=NULL; +Pneumatics* DentRobot::pneumatics=NULL; DentRobot::DentRobot(){ oi=new OI(); collector=new Collector(); drivetrain=new Drivetrain(); elevator=new Elevator(); binElevator=new BinElevator(); + pneumatics=new Pneumatics(); aut=new Autonomous(0); CameraServer::GetInstance()->SetQuality(25); CameraServer::GetInstance()->StartAutomaticCapture("cam0"); diff --git a/DentRobot.h b/DentRobot.h index 68b17ba..59658f2 100644 --- a/DentRobot.h +++ b/DentRobot.h @@ -6,6 +6,7 @@ #include "Subsystems/BinElevator.h" #include "Subsystems/Drivetrain.h" #include "Subsystems/Collector.h" +#include "Subsystems/Pneumatics.h" #include "Commands/Autonomous/Autonomous.h" class DentRobot: public IterativeRobot { private: @@ -17,6 +18,7 @@ class DentRobot: public IterativeRobot { static Drivetrain* drivetrain; static Elevator* elevator; static BinElevator* binElevator; + static Pneumatics* pneumatics; static CommandGroup* aut; void RobotInit(); void DisabledPeriodic(); diff --git a/RobotMap.h b/RobotMap.h index 13a443d..bb163e7 100644 --- a/RobotMap.h +++ b/RobotMap.h @@ -21,7 +21,7 @@ #define BINELEVATOR_ENCODERA 10 #define BINELEVATOR_ENCODERB 11 #define BINELEVATOR_SOLDENOID_ONE 1 -#define BINELEVATOR_SOLDENOID_TWO 1 +#define BINELEVATOR_SOLDENOID_TWO 2 // Drivetrain #define DRIVE_FRONT_LEFT_CAN 2 diff --git a/Subsystems/Pnuematics.cpp b/Subsystems/Pneumatics.cpp similarity index 66% rename from Subsystems/Pnuematics.cpp rename to Subsystems/Pneumatics.cpp index d2840a2..8ae164d 100644 --- a/Subsystems/Pnuematics.cpp +++ b/Subsystems/Pneumatics.cpp @@ -1,13 +1,13 @@ -#include "Pnuematics.h" +#include "Pneumatics.h" #include "../RobotMap.h" -Pnuematics::Pnuematics() : Subsystem("Pnuematics"){ +Pneumatics::Pneumatics() : Subsystem("Pneumatics"){ solenoid1 = new Solenoid(BINELEVATOR_SOLDENOID_ONE); solenoid2 = new Solenoid(BINELEVATOR_SOLDENOID_TWO); } -void Pnuematics::InitDefaultCommand(){ +void Pneumatics::InitDefaultCommand(){ } -void Pnuematics::SetOpen(bool k){ +void Pneumatics::SetOpen(bool k){ if(k){ solenoid1->Set(true); solenoid2->Set(false); diff --git a/Subsystems/Pnuematics.h b/Subsystems/Pneumatics.h similarity index 63% rename from Subsystems/Pnuematics.h rename to Subsystems/Pneumatics.h index cbc0152..9f57b72 100644 --- a/Subsystems/Pnuematics.h +++ b/Subsystems/Pneumatics.h @@ -1,13 +1,13 @@ -#ifndef PNUEMATICS_H -#define PNUEMATICS_H +#ifndef PNEUMATICS_H +#define PNEUMATICS_H #include "WPILib.h" -class Pnuematics: public Subsystem +class Pneumatics: public Subsystem { private: Solenoid *solenoid1, *solenoid2; public: - Pnuematics(); + Pneumatics(); void InitDefaultCommand(); void SetOpen(bool); }; From d9c010aed85c3ffe47bebe233a033bf710808ee9 Mon Sep 17 00:00:00 2001 From: Adam Long Date: Sat, 21 Feb 2015 13:43:19 +0000 Subject: [PATCH 12/40] Made auto more modular --- Commands/Autonomous/AutoDrive.cpp | 16 +++------------- Commands/Autonomous/Autonomous.cpp | 13 +++++-------- Commands/Autonomous/Turn.cpp | 3 ++- Commands/Autonomous/Turn.h | 4 +++- Commands/Collector/CollectTote.cpp | 2 +- Commands/Collector/RollIn.cpp | 6 +++--- Commands/Collector/RollIn.h | 4 +++- OI.cpp | 8 +++++++- 8 files changed, 27 insertions(+), 29 deletions(-) diff --git a/Commands/Autonomous/AutoDrive.cpp b/Commands/Autonomous/AutoDrive.cpp index 24fce24..9a46f5c 100644 --- a/Commands/Autonomous/AutoDrive.cpp +++ b/Commands/Autonomous/AutoDrive.cpp @@ -1,26 +1,16 @@ #include "AutoDrive.h" #include "../../DentRobot.h" // Drive for a short while then stop. Just for testing -AutoDrive::AutoDrive(double wait) : Command("AutoDrive"){ +AutoDrive::AutoDrive(double duration, double p=-0.75) : Command("AutoDrive"){ Requires(DentRobot::drivetrain); - SetTimeout(wait); - power=5; -} -AutoDrive::AutoDrive(double wait, double p) : Command("AutoDrive"){ - Requires(DentRobot::drivetrain); - SetTimeout(wait); + SetTimeout(duration); power=p; } void AutoDrive::Initialize(){ } void AutoDrive::Execute(){ //X axis, Y axis, Z axis, sensitivity, speed threshold (usually throttle), gyro - //if(power==NULL){ - if(power==5){ - DentRobot::drivetrain->DriveMecanum(0.0,-.75,0.0,0.9,0.0); - }else{ - DentRobot::drivetrain->DriveMecanum(0.0,power,0.0,0.9,0.0); - } + DentRobot::drivetrain->DriveMecanum(0.0,power,0.0,0.9,0.0); } bool AutoDrive::IsFinished(){ return IsTimedOut(); diff --git a/Commands/Autonomous/Autonomous.cpp b/Commands/Autonomous/Autonomous.cpp index 236a6b8..32ac0f2 100644 --- a/Commands/Autonomous/Autonomous.cpp +++ b/Commands/Autonomous/Autonomous.cpp @@ -12,7 +12,7 @@ Autonomous::Autonomous(int seq){ case 0: // Just for testing AddSequential(new CollectTote()); - AddSequential(new Turn()); + AddSequential(new Turn(90)); //AddSequential(new Raise()); //AddSequential(new Lower()); //AddSequential(new Turn()); @@ -23,21 +23,18 @@ Autonomous::Autonomous(int seq){ case 1: // Drive forward a bit, turn around, collect tote then bin AddSequential(new AutoDrive(0.5)); - AddSequential(new Turn()); - AddSequential(new Turn()); - AddSequential(new RollIn()); + AddSequential(new Turn(180)); + AddSequential(new RollIn(1.0)); AddSequential(new Raise()); break; case 2: // Drive forward a bit, turn around, collect tote then bin AddParallel(new Raise()); AddParallel(new AutoDrive(0.5)); - AddSequential(new Turn()); - AddSequential(new Turn()); - AddSequential(new RollIn()); + AddSequential(new Turn(180)); + AddSequential(new RollIn(1.0)); break; case 3: - // Wait a desigated value, drive to Auto Zone (TM) //Wait(SmartDashboard::GetNumber("Auto Wait Time")); AddSequential(new AutoDrive(2.0)); break; diff --git a/Commands/Autonomous/Turn.cpp b/Commands/Autonomous/Turn.cpp index eea1450..27b9e93 100644 --- a/Commands/Autonomous/Turn.cpp +++ b/Commands/Autonomous/Turn.cpp @@ -1,8 +1,9 @@ #include "Turn.h" #include "../../DentRobot.h" // Drive for a short while then stop. Just for testing -Turn::Turn() : Command("Turn"){ +Turn::Turn(int k) : Command("Turn"){ Requires(DentRobot::drivetrain); + degrees=k; SetTimeout(0.85); } void Turn::Initialize(){ diff --git a/Commands/Autonomous/Turn.h b/Commands/Autonomous/Turn.h index 2adc701..b128c20 100644 --- a/Commands/Autonomous/Turn.h +++ b/Commands/Autonomous/Turn.h @@ -7,8 +7,10 @@ #include "WPILib.h" class Turn: public Command{ + private: + int degrees; public: - Turn(); + Turn(int); void Initialize(); void Execute(); bool IsFinished(); diff --git a/Commands/Collector/CollectTote.cpp b/Commands/Collector/CollectTote.cpp index 6b728f3..b7255cd 100644 --- a/Commands/Collector/CollectTote.cpp +++ b/Commands/Collector/CollectTote.cpp @@ -4,6 +4,6 @@ #include "RollIn.h" CollectTote::CollectTote(){ AddParallel(new AutoDrive(1.0, -0.75)); - AddSequential(new RollIn()); + AddSequential(new RollIn(1.0)); } // vim: ts=2:sw=2:et diff --git a/Commands/Collector/RollIn.cpp b/Commands/Collector/RollIn.cpp index e4384f2..1388c69 100644 --- a/Commands/Collector/RollIn.cpp +++ b/Commands/Collector/RollIn.cpp @@ -1,13 +1,13 @@ #include "RollIn.h" -RollIn::RollIn() : Command("RollIn"){ +RollIn::RollIn(double k) : Command("RollIn"){ + rawSpeed=k; } void RollIn::Initialize(){ printf("Initialized RollIn\n"); SetTimeout(2.0); } void RollIn::Execute(){ - double throttle=DentRobot::oi->GetLeftThrottle(); - double cvt=throttle*DentRobot::collector->GetSonarDistance()/0.4; + double cvt=(rawSpeed)*DentRobot::collector->GetSonarDistance()/0.4; if(cvt>=1.0){ DentRobot::collector->MoveRollers(1.0); }else{ diff --git a/Commands/Collector/RollIn.h b/Commands/Collector/RollIn.h index 8a222aa..25e4924 100644 --- a/Commands/Collector/RollIn.h +++ b/Commands/Collector/RollIn.h @@ -7,8 +7,10 @@ #include "WPILib.h" class RollIn: public Command{ + private: + double rawSpeed; public: - RollIn(); + RollIn(double); void Initialize(); void Execute(); bool IsFinished(); diff --git a/OI.cpp b/OI.cpp index b39da72..80e465a 100644 --- a/OI.cpp +++ b/OI.cpp @@ -5,6 +5,8 @@ #include "Commands/Collector/RollOut.h" #include "Commands/BinElevator/BinLower.h" #include "Commands/BinElevator/BinRaise.h" +#include "Commands/BinElevator/BinCloseArms.h" +#include "Commands/BinElevator/BinOpenArms.h" OI::OI() { // Joysticks @@ -13,7 +15,7 @@ OI::OI() { // Collector JoystickButton *left1=new JoystickButton(leftStick, 1); JoystickButton *left2=new JoystickButton(leftStick, 2); - left1->WhileHeld(new RollIn()); + left1->WhileHeld(new RollIn(GetLeftThrottle())); left2->WhileHeld(new RollOut()); // Elevator raise=new Raise(); @@ -27,12 +29,16 @@ OI::OI() { // BinElevator JoystickButton *right3=new JoystickButton(rightStick, 3); JoystickButton *right5=new JoystickButton(rightStick, 5); + JoystickButton *right7=new JoystickButton(rightStick, 7); + JoystickButton *right8=new JoystickButton(rightStick, 8); binRaise=new BinRaise(); binLower=new BinLower(); right3->WhenPressed(binLower); right3->CancelWhenPressed(binRaise); right5->WhenPressed(binRaise); right5->CancelWhenPressed(binLower); + right7->WhenPressed(new BinOpenArms()); + right8->WhenPressed(new BinCloseArms()); // Cancel JoystickButton *right12=new JoystickButton(rightStick, 12); right12->CancelWhenPressed(raise); From 016f6cd609f1e7785d7d2ba156b343d9c02920b1 Mon Sep 17 00:00:00 2001 From: Adam Long Date: Sat, 21 Feb 2015 13:53:25 +0000 Subject: [PATCH 13/40] Fixed build error --- Commands/Autonomous/Autonomous.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Commands/Autonomous/Autonomous.cpp b/Commands/Autonomous/Autonomous.cpp index 32ac0f2..e222357 100644 --- a/Commands/Autonomous/Autonomous.cpp +++ b/Commands/Autonomous/Autonomous.cpp @@ -22,7 +22,7 @@ Autonomous::Autonomous(int seq){ break; case 1: // Drive forward a bit, turn around, collect tote then bin - AddSequential(new AutoDrive(0.5)); + AddSequential(new AutoDrive(1.0,-0.75)); AddSequential(new Turn(180)); AddSequential(new RollIn(1.0)); AddSequential(new Raise()); @@ -30,13 +30,13 @@ Autonomous::Autonomous(int seq){ case 2: // Drive forward a bit, turn around, collect tote then bin AddParallel(new Raise()); - AddParallel(new AutoDrive(0.5)); + AddSequential(new AutoDrive(1.0,-0.75)); AddSequential(new Turn(180)); AddSequential(new RollIn(1.0)); break; case 3: //Wait(SmartDashboard::GetNumber("Auto Wait Time")); - AddSequential(new AutoDrive(2.0)); + AddSequential(new AutoDrive(1.0,-0.75)); break; default: printf("Invalid seq: %d\n", seq); From d5c8c3299885c2990678189d90136ec746259b23 Mon Sep 17 00:00:00 2001 From: Christian Colglazier Date: Tue, 24 Feb 2015 09:05:20 -0500 Subject: [PATCH 14/40] Added a short description of the robot --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d7019d8..41189c2 100644 --- a/README.md +++ b/README.md @@ -1 +1,5 @@ -2015 FRC Robot +# Dent + +Dent was designed to have a fast mecanum drivetrain with ground clearance to traverse the scoring platforms with ease -- all while carrying a stack of totes. He has a main internal elevator that lifts totes up to six high within the robot, allowing us to move quickly to anywhere on the field without tipping. His intake system features a ramp leading to the floor with an active roller pulling the totes up to two collector wheels on either side of the robot, both pulling the totes in, and centering them simultaneously. But Dent doesn’t stop there. A taller elevator on the back of the robot allows us to lift either recycle containers or totes to a greater height. With this, we can create stacks both internally and externally, with each system providing a backup of the other in the case of a breakage on the field. + +### Controls \ No newline at end of file From 342159ae0458a9fd0fff87ad9d793d6f7dbc8ab9 Mon Sep 17 00:00:00 2001 From: Christian Colglazier Date: Tue, 24 Feb 2015 09:19:47 -0500 Subject: [PATCH 15/40] Added control list for driver joystick --- README.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 41189c2..de76f00 100644 --- a/README.md +++ b/README.md @@ -2,4 +2,13 @@ Dent was designed to have a fast mecanum drivetrain with ground clearance to traverse the scoring platforms with ease -- all while carrying a stack of totes. He has a main internal elevator that lifts totes up to six high within the robot, allowing us to move quickly to anywhere on the field without tipping. His intake system features a ramp leading to the floor with an active roller pulling the totes up to two collector wheels on either side of the robot, both pulling the totes in, and centering them simultaneously. But Dent doesn’t stop there. A taller elevator on the back of the robot allows us to lift either recycle containers or totes to a greater height. With this, we can create stacks both internally and externally, with each system providing a backup of the other in the case of a breakage on the field. -### Controls \ No newline at end of file +### Controls +#####Driver Main Joystick (USB 0) +- X-Axis - Drive forwards and backwards +- Y-Axis - Strafes left and right +- Z-Axis - Turns left and right +- Button 1 - Collects totes +- Button 2 - Dispenses totes +- Button 7 - Enable robot test + +#####Driver Secondary Joystick (USB 1) \ No newline at end of file From 790f0eec17fb8cfea4444b3f693e1bda06e16399 Mon Sep 17 00:00:00 2001 From: Christian Colglazier Date: Tue, 24 Feb 2015 09:28:28 -0500 Subject: [PATCH 16/40] Added controls for secondary drive joystick and updated control list for driver joystick --- README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index de76f00..a13a741 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,16 @@ Dent was designed to have a fast mecanum drivetrain with ground clearance to tra - X-Axis - Drive forwards and backwards - Y-Axis - Strafes left and right - Z-Axis - Turns left and right +- Throttle-Axis - Adjusts collector speed - Button 1 - Collects totes - Button 2 - Dispenses totes - Button 7 - Enable robot test -#####Driver Secondary Joystick (USB 1) \ No newline at end of file +#####Driver Secondary Joystick (USB 1) +- Button 3 - Lowers bin elevator +- Button 4 - Lowers tote elevator +- Button 5 - Raises bin elevator +- Button 6 - Raises tote elevator +- Button 7 - Opens bin arms +- Button 8 - Closes bin arms +- Button 12 - Universal cancel button \ No newline at end of file From e35325d64ab2ec6f3e9de8b205e5811c0ce5f444 Mon Sep 17 00:00:00 2001 From: Carl Colglazier Date: Tue, 24 Feb 2015 09:50:57 -0500 Subject: [PATCH 17/40] Add inline links to README. --- README.md | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a13a741..f7b8d0f 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,16 @@ # Dent -Dent was designed to have a fast mecanum drivetrain with ground clearance to traverse the scoring platforms with ease -- all while carrying a stack of totes. He has a main internal elevator that lifts totes up to six high within the robot, allowing us to move quickly to anywhere on the field without tipping. His intake system features a ramp leading to the floor with an active roller pulling the totes up to two collector wheels on either side of the robot, both pulling the totes in, and centering them simultaneously. But Dent doesn’t stop there. A taller elevator on the back of the robot allows us to lift either recycle containers or totes to a greater height. With this, we can create stacks both internally and externally, with each system providing a backup of the other in the case of a breakage on the field. +Dent was designed to have a fast mecanum [drivetrain](Subsystems/Drivetrain.cpp) with ground clearance to traverse the scoring platforms with ease—all while carrying a stack of totes. A main [internal elevator](Subsystems/Elevator.cpp) lifts totes up to six high within the robot, allowing us to move quickly to anywhere on the field without tipping. The [intake system](Subsystems/Collector.cpp) features a ramp leading to the floor with an active roller pulling the totes up to two collector wheels on either side of the robot, both pulling the totes in, and centering them simultaneously. + +But Dent does not stop there; a [taller elevator](Subsystems/BinElevator.cpp) on the back of the robot allows us to lift either recycle containers or totes to a greater height. With this, we can create stacks both internally and externally, with each system providing a backup of the other in case anything breaks. + +Dent is programmed in C++ and uses many sensors to determine what to do. An [ultrasonic sensor](Subsystems/Collector.cpp#L9) mounted on the back of the robot looking forward automatically slows down the collector wheels as the totes fly into the internal elevator. Homemade [hall effect sensors](Subsystems/Elevator.cpp#L6-L8) line the elevator shafts of both elevators, allowing the driver to raise totes and containers to pre-programmed heights. + +All aspects of Dent’s design come together to produce a robot ready to rank in qualifications, and still provide a fast and capable design for elimination rounds. With all parts made an code written for Dent in-house, this truly is a robot designed by, built by, and programmed by the students on Team 2059, [The Hitchhikers](http://team2059.org/). + ### Controls -#####Driver Main Joystick (USB 0) +##### Driver Main Joystick (USB 0) - X-Axis - Drive forwards and backwards - Y-Axis - Strafes left and right - Z-Axis - Turns left and right @@ -12,7 +19,7 @@ Dent was designed to have a fast mecanum drivetrain with ground clearance to tra - Button 2 - Dispenses totes - Button 7 - Enable robot test -#####Driver Secondary Joystick (USB 1) +##### Driver Secondary Joystick (USB 1) - Button 3 - Lowers bin elevator - Button 4 - Lowers tote elevator - Button 5 - Raises bin elevator From e6e616b08dd51025856dbd4e69b830deee10988c Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Tue, 24 Feb 2015 12:02:30 -0500 Subject: [PATCH 18/40] New SmartDashboard values for autonomous, elevator sensors --- Commands/Autonomous/Autonomous.cpp | 41 ++++++++++--------- .../{Collector => Autonomous}/CollectTote.cpp | 4 +- .../{Collector => Autonomous}/CollectTote.h | 0 .../{Collector => Autonomous}/ReleaseTote.cpp | 4 +- .../{Collector => Autonomous}/ReleaseTote.h | 0 DentRobot.cpp | 20 ++++++++- OI.cpp | 4 +- Subsystems/BinElevator.cpp | 2 + Subsystems/Elevator.cpp | 2 + 9 files changed, 51 insertions(+), 26 deletions(-) rename Commands/{Collector => Autonomous}/CollectTote.cpp (76%) rename Commands/{Collector => Autonomous}/CollectTote.h (100%) rename Commands/{Collector => Autonomous}/ReleaseTote.cpp (75%) rename Commands/{Collector => Autonomous}/ReleaseTote.h (100%) diff --git a/Commands/Autonomous/Autonomous.cpp b/Commands/Autonomous/Autonomous.cpp index 1b02985..4dd8981 100644 --- a/Commands/Autonomous/Autonomous.cpp +++ b/Commands/Autonomous/Autonomous.cpp @@ -6,7 +6,7 @@ #include "AutoDrive.h" #include "Turn.h" #include "../Collector/RollIn.h" -#include "../Collector/CollectTote.h" +#include "CollectTote.h" Autonomous::Autonomous(int seq){ //SmartDashboard::GetNumber("Auto Wait Time"); switch(seq){ @@ -14,30 +14,33 @@ Autonomous::Autonomous(int seq){ // Just for testing AddSequential(new CollectTote()); AddSequential(new Turn(90)); - //AddSequential(new Raise()); - //AddSequential(new Lower()); - //AddSequential(new Turn()); - //AddParallel(new AutoDrive(0.5)); - //AddSequential(new RollIn()); - //AddSequential(new Turn()); break; case 1: - // Drive forward a bit, turn around, collect tote then bin - AddSequential(new AutoDrive(1.0,-0.75)); - AddSequential(new Turn(180)); - AddSequential(new RollIn(1.0)); - AddSequential(new Raise()); + // Wait a desigated value, drive to Auto Zone (TM) + Wait(SmartDashboard::GetNumber("Auto Wait Time")); + AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Zone Distance"), -0.75)); break; case 2: - // Drive forward a bit, turn around, collect tote then bin - AddParallel(new Raise()); - AddSequential(new AutoDrive(1.0,-0.75)); - AddSequential(new Turn(180)); - AddSequential(new RollIn(1.0)); + // Get one tote and go to auto + AddSequential(new CollectTote()); + AddSequential(new Turn(90)); break; case 3: - //Wait(SmartDashboard::GetNumber("Auto Wait Time")); - AddSequential(new AutoDrive(1.0,-0.75)); + // Collect three totes, drive to Auto Zone (TM) + printf("Waiting: %f\n",SmartDashboard::GetNumber("Auto Wait Time")); + Wait(SmartDashboard::GetNumber("Auto Wait Time")); + printf("Done"); + AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Tote Distance"), -0.75)); + AddSequential(new CollectTote()); + AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Tote Distance"), -0.75)); + AddSequential(new CollectTote()); + printf("Three totes?: %d\n",SmartDashboard::GetBoolean("Three totes")); + if(SmartDashboard::GetBoolean("Three totes")){ + AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Tote Distance"), -0.75)); + AddSequential(new CollectTote()); + } + AddSequential(new Turn(90)); + AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Zone Distance"), -0.75)); break; default: printf("Invalid seq: %d\n", seq); diff --git a/Commands/Collector/CollectTote.cpp b/Commands/Autonomous/CollectTote.cpp similarity index 76% rename from Commands/Collector/CollectTote.cpp rename to Commands/Autonomous/CollectTote.cpp index b7255cd..f596853 100644 --- a/Commands/Collector/CollectTote.cpp +++ b/Commands/Autonomous/CollectTote.cpp @@ -1,7 +1,7 @@ #include "CollectTote.h" #include "../../DentRobot.h" -#include "../Autonomous/AutoDrive.h" -#include "RollIn.h" +#include "AutoDrive.h" +#include "../Collector/RollIn.h" CollectTote::CollectTote(){ AddParallel(new AutoDrive(1.0, -0.75)); AddSequential(new RollIn(1.0)); diff --git a/Commands/Collector/CollectTote.h b/Commands/Autonomous/CollectTote.h similarity index 100% rename from Commands/Collector/CollectTote.h rename to Commands/Autonomous/CollectTote.h diff --git a/Commands/Collector/ReleaseTote.cpp b/Commands/Autonomous/ReleaseTote.cpp similarity index 75% rename from Commands/Collector/ReleaseTote.cpp rename to Commands/Autonomous/ReleaseTote.cpp index c10ddd2..6672dd1 100644 --- a/Commands/Collector/ReleaseTote.cpp +++ b/Commands/Autonomous/ReleaseTote.cpp @@ -1,7 +1,7 @@ #include "ReleaseTote.h" #include "../../DentRobot.h" -#include "RollOut.h" -#include "../Autonomous/AutoDrive.h" +#include "AutoDrive.h" +#include "../Collector/RollOut.h" ReleaseTote::ReleaseTote(){ AddParallel(new RollOut()); AddParallel(new AutoDrive(0.5, 0.75)); diff --git a/Commands/Collector/ReleaseTote.h b/Commands/Autonomous/ReleaseTote.h similarity index 100% rename from Commands/Collector/ReleaseTote.h rename to Commands/Autonomous/ReleaseTote.h diff --git a/DentRobot.cpp b/DentRobot.cpp index 1b2d642..89d9c16 100644 --- a/DentRobot.cpp +++ b/DentRobot.cpp @@ -16,7 +16,6 @@ DentRobot::DentRobot(){ elevator=new Elevator(); binElevator=new BinElevator(); pneumatics=new Pneumatics(); - aut=new Autonomous(0); CameraServer::GetInstance()->SetQuality(25); CameraServer::GetInstance()->StartAutomaticCapture("cam0"); //SmartDashboard::PutNumber("Auto Wait Time", 1.0); @@ -25,11 +24,30 @@ DentRobot::DentRobot(){ } void DentRobot::RobotInit(){ SmartDashboard::PutNumber("CodeVersion",CODE_VERSION); + // Autonomous + // Sequence of autonomous command + SmartDashboard::PutNumber("Auto Sequence",1.0); + SmartDashboard::PutNumber("Auto Wait Time",1.0); + // If the robot will be picking up three totes in sequence 3 + SmartDashboard::PutBoolean("Three totes", true); + // TODO: Calibrate the following two values + // Distance (in time) to auto zone + SmartDashboard::PutNumber("Auto Zone Distance", 1.0); + // Distance (in time) to auto tote (used in sequence 3) + SmartDashboard::PutNumber("Auto Tote Distance", 0.5); + + // Elevators + SmartDashboard::PutBoolean("Bin Elevator Bottom", false); + SmartDashboard::PutBoolean("Bin Elevator Top", false); + SmartDashboard::PutBoolean("Elevator Bottom", false); + SmartDashboard::PutBoolean("Elevator Top", false); } void DentRobot::DisabledPeriodic(){ Scheduler::GetInstance()->Run(); } void DentRobot::AutonomousInit(){ + aut=new Autonomous(SmartDashboard::GetNumber("Auto Sequence")); + printf("Enabling Auto Sequence %f\n",SmartDashboard::GetNumber("Auto Sequence")); if(aut != NULL){ aut->Start(); } diff --git a/OI.cpp b/OI.cpp index 7193ef0..db50c7c 100644 --- a/OI.cpp +++ b/OI.cpp @@ -7,8 +7,8 @@ #include "Commands/BinElevator/BinRaise.h" #include "Commands/BinElevator/BinCloseArms.h" #include "Commands/BinElevator/BinOpenArms.h" -#include "Commands/Collector/CollectTote.h" -#include "Commands/Collector/ReleaseTote.h" +#include "Commands/Autonomous/CollectTote.h" +#include "Commands/Autonomous/ReleaseTote.h" #include "Commands/Test/CheckRobot.h" OI::OI() { // Joysticks diff --git a/Subsystems/BinElevator.cpp b/Subsystems/BinElevator.cpp index daff79b..22f3c74 100644 --- a/Subsystems/BinElevator.cpp +++ b/Subsystems/BinElevator.cpp @@ -18,9 +18,11 @@ double BinElevator::GetHeight(){ return elevatorEncoder->Get(); } bool BinElevator::GetElevatorBottom(){ + SmartDashboard::PutBoolean("Bin Elevator Bottom", elevatorBottom->Get()); return elevatorBottom->Get(); } bool BinElevator::GetElevatorTop(){ + SmartDashboard::PutBoolean("Bin Elevator Top", elevatorTop->Get()); return elevatorTop->Get(); } // vim: ts=2:sw=2:et diff --git a/Subsystems/Elevator.cpp b/Subsystems/Elevator.cpp index 0649a44..1cfe13e 100644 --- a/Subsystems/Elevator.cpp +++ b/Subsystems/Elevator.cpp @@ -26,12 +26,14 @@ double Elevator::GetHeight(){ return elevatorEncoder->Get(); } bool Elevator::GetElevatorBottom(){ + SmartDashboard::PutBoolean("Elevator Bottom", elevatorBottom->Get()); return elevatorBottom->Get(); } bool Elevator::GetElevatorMiddle(){ return elevatorMiddle->Get(); } bool Elevator::GetElevatorTop(){ + SmartDashboard::PutBoolean("Elevator Top", elevatorTop->Get()); return elevatorTop->Get(); } void Elevator::SetUseEncoder(bool param){ From 3ec24179bc8d631b7941cfa6b7f8ed7edf0d17da Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Tue, 24 Feb 2015 15:03:59 -0500 Subject: [PATCH 19/40] Updated autonomous --- Commands/Autonomous/Autonomous.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Commands/Autonomous/Autonomous.cpp b/Commands/Autonomous/Autonomous.cpp index 4dd8981..e99d474 100644 --- a/Commands/Autonomous/Autonomous.cpp +++ b/Commands/Autonomous/Autonomous.cpp @@ -7,6 +7,7 @@ #include "Turn.h" #include "../Collector/RollIn.h" #include "CollectTote.h" +#include "ReleaseTote.h" Autonomous::Autonomous(int seq){ //SmartDashboard::GetNumber("Auto Wait Time"); switch(seq){ @@ -21,9 +22,10 @@ Autonomous::Autonomous(int seq){ AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Zone Distance"), -0.75)); break; case 2: - // Get one tote and go to auto + // Get one tote and go to Auto Zone (TM) AddSequential(new CollectTote()); AddSequential(new Turn(90)); + AddSequential(new ReleaseTote()); break; case 3: // Collect three totes, drive to Auto Zone (TM) @@ -41,6 +43,7 @@ Autonomous::Autonomous(int seq){ } AddSequential(new Turn(90)); AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Zone Distance"), -0.75)); + AddSequential(new ReleaseTote()); break; default: printf("Invalid seq: %d\n", seq); From 57ef72d4039070daa05a4d7797afbc702646a708 Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Thu, 26 Feb 2015 09:03:12 -0500 Subject: [PATCH 20/40] Variable name change --- Subsystems/Pneumatics.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Subsystems/Pneumatics.cpp b/Subsystems/Pneumatics.cpp index 8ae164d..93dab86 100644 --- a/Subsystems/Pneumatics.cpp +++ b/Subsystems/Pneumatics.cpp @@ -7,8 +7,8 @@ Pneumatics::Pneumatics() : Subsystem("Pneumatics"){ } void Pneumatics::InitDefaultCommand(){ } -void Pneumatics::SetOpen(bool k){ - if(k){ +void Pneumatics::SetOpen(bool state){ + if(state){ solenoid1->Set(true); solenoid2->Set(false); }else{ From c3e5b0cc5b96999f971ef9092adcb066099ffd83 Mon Sep 17 00:00:00 2001 From: Adam Long Date: Thu, 26 Feb 2015 12:45:35 +0000 Subject: [PATCH 21/40] Tuning autonomous --- Commands/Autonomous/Autonomous.cpp | 5 +++++ Commands/Elevator/Lower.cpp | 2 +- Commands/Elevator/Raise.cpp | 2 +- RobotMap.h | 4 ++-- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Commands/Autonomous/Autonomous.cpp b/Commands/Autonomous/Autonomous.cpp index e99d474..f12ace6 100644 --- a/Commands/Autonomous/Autonomous.cpp +++ b/Commands/Autonomous/Autonomous.cpp @@ -34,12 +34,17 @@ Autonomous::Autonomous(int seq){ printf("Done"); AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Tote Distance"), -0.75)); AddSequential(new CollectTote()); + AddSequential(new Raise()); AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Tote Distance"), -0.75)); AddSequential(new CollectTote()); + AddSequential(new Lower()); + AddSequential(new Raise()); printf("Three totes?: %d\n",SmartDashboard::GetBoolean("Three totes")); if(SmartDashboard::GetBoolean("Three totes")){ AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Tote Distance"), -0.75)); AddSequential(new CollectTote()); + AddSequential(new Lower()); + AddSequential(new Raise()); } AddSequential(new Turn(90)); AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Zone Distance"), -0.75)); diff --git a/Commands/Elevator/Lower.cpp b/Commands/Elevator/Lower.cpp index 378156d..637a88b 100644 --- a/Commands/Elevator/Lower.cpp +++ b/Commands/Elevator/Lower.cpp @@ -4,7 +4,7 @@ Lower::Lower() : Command("Lower"){ } void Lower::Initialize(){ - SetTimeout(2.5); + SetTimeout(3.0); } void Lower::Execute(){ DentRobot::elevator->Run(-1.0); diff --git a/Commands/Elevator/Raise.cpp b/Commands/Elevator/Raise.cpp index 817ed4d..ce42ab8 100644 --- a/Commands/Elevator/Raise.cpp +++ b/Commands/Elevator/Raise.cpp @@ -4,7 +4,7 @@ Raise::Raise() : Command("Raise"){ } void Raise::Initialize(){ - SetTimeout(3.0); + SetTimeout(3.5); } void Raise::Execute(){ DentRobot::elevator->Run(1.0); diff --git a/RobotMap.h b/RobotMap.h index bb163e7..d92e4f1 100644 --- a/RobotMap.h +++ b/RobotMap.h @@ -20,8 +20,8 @@ #define BINELEVATOR_TOP_DIO 8 #define BINELEVATOR_ENCODERA 10 #define BINELEVATOR_ENCODERB 11 -#define BINELEVATOR_SOLDENOID_ONE 1 -#define BINELEVATOR_SOLDENOID_TWO 2 +#define BINELEVATOR_SOLDENOID_ONE 6 +#define BINELEVATOR_SOLDENOID_TWO 7 // Drivetrain #define DRIVE_FRONT_LEFT_CAN 2 From 0e949063e8ca8d78e0d53b230f9cc4d448d827cb Mon Sep 17 00:00:00 2001 From: Adam Long Date: Thu, 26 Feb 2015 13:01:05 +0000 Subject: [PATCH 22/40] Removed pneumatics (for now) --- OI.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/OI.cpp b/OI.cpp index db50c7c..916216b 100644 --- a/OI.cpp +++ b/OI.cpp @@ -31,16 +31,16 @@ OI::OI() { // BinElevator JoystickButton *right3=new JoystickButton(rightStick, 3); JoystickButton *right5=new JoystickButton(rightStick, 5); - JoystickButton *right7=new JoystickButton(rightStick, 7); - JoystickButton *right8=new JoystickButton(rightStick, 8); + //JoystickButton *right7=new JoystickButton(rightStick, 7); + //JoystickButton *right8=new JoystickButton(rightStick, 8); + //right7->WhenPressed(new BinOpenArms()); + //right8->WhenPressed(new BinCloseArms()); binRaise=new BinRaise(); binLower=new BinLower(); right3->WhenPressed(binLower); right3->CancelWhenPressed(binRaise); right5->WhenPressed(binRaise); right5->CancelWhenPressed(binLower); - right7->WhenPressed(new BinOpenArms()); - right8->WhenPressed(new BinCloseArms()); // Cancel JoystickButton *right12=new JoystickButton(rightStick, 12); right12->CancelWhenPressed(raise); From aa42984de15583048ddf138525dd85ee312832c5 Mon Sep 17 00:00:00 2001 From: Adam Long Date: Thu, 26 Feb 2015 15:08:08 +0000 Subject: [PATCH 23/40] Changed DIO ports --- RobotMap.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/RobotMap.h b/RobotMap.h index d92e4f1..2f25d55 100644 --- a/RobotMap.h +++ b/RobotMap.h @@ -14,25 +14,25 @@ #define ELEVATOR_ENCODERB 9 // BinElevator -#define BINELEVATOR_CAN 11 +#define BINELEVATOR_CAN 10 #define BINELEVATOR_BOTTOM_DIO 6 #define BINELEVATOR_COLELCT_BIN_DIO 7 -#define BINELEVATOR_TOP_DIO 8 +#define BINELEVATOR_TOP_DIO 12 #define BINELEVATOR_ENCODERA 10 #define BINELEVATOR_ENCODERB 11 #define BINELEVATOR_SOLDENOID_ONE 6 #define BINELEVATOR_SOLDENOID_TWO 7 // Drivetrain -#define DRIVE_FRONT_LEFT_CAN 2 +#define DRIVE_FRONT_LEFT_CAN 8 #define DRIVE_BACK_LEFT_CAN 3 #define DRIVE_FRONT_RIGHT_CAN 4 #define DRIVE_BACK_RIGHT_CAN 5 // Collector #define COLLECTOR_RAMP_CAN 7 -#define COLLECTOR_LEFT_CAN 8 -#define COLLECTOR_BOTTOM_CAN 10 +#define COLLECTOR_LEFT_CAN 2 +#define COLLECTOR_BOTTOM_CAN 11 #define COLLECTOR_RIGHT_CAN 9 #define COLLECTOR_SONAR_ANALOG 3 From d2c4205bbcdd6e6b053b33524726699ba6373965 Mon Sep 17 00:00:00 2001 From: Adam Long Date: Thu, 26 Feb 2015 17:18:23 +0000 Subject: [PATCH 24/40] Disabled camera, changed values --- Commands/Collector/RollOut.cpp | 2 +- DentRobot.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Commands/Collector/RollOut.cpp b/Commands/Collector/RollOut.cpp index bc9ec90..d4d78d5 100644 --- a/Commands/Collector/RollOut.cpp +++ b/Commands/Collector/RollOut.cpp @@ -8,7 +8,7 @@ void RollOut::Initialize(){ void RollOut::Execute(){ //TODO check this value to move the motors in the right direction // Devide by 2 twice because this speed should be half the collector speed - DentRobot::collector->MoveRollers(-DentRobot::oi->GetLeftThrottle()); + DentRobot::collector->MoveRollers(-DentRobot::oi->GetLeftThrottle()*.5); } bool RollOut::IsFinished(){ return IsTimedOut(); diff --git a/DentRobot.cpp b/DentRobot.cpp index 89d9c16..00b1f7d 100644 --- a/DentRobot.cpp +++ b/DentRobot.cpp @@ -16,8 +16,8 @@ DentRobot::DentRobot(){ elevator=new Elevator(); binElevator=new BinElevator(); pneumatics=new Pneumatics(); - CameraServer::GetInstance()->SetQuality(25); - CameraServer::GetInstance()->StartAutomaticCapture("cam0"); + //CameraServer::GetInstance()->SetQuality(25); + //CameraServer::GetInstance()->StartAutomaticCapture("cam0"); //SmartDashboard::PutNumber("Auto Wait Time", 1.0); //SmartDashboard::PutNumber("Auto Sequence", 0); printf("The robot is on\n"); @@ -48,9 +48,9 @@ void DentRobot::DisabledPeriodic(){ void DentRobot::AutonomousInit(){ aut=new Autonomous(SmartDashboard::GetNumber("Auto Sequence")); printf("Enabling Auto Sequence %f\n",SmartDashboard::GetNumber("Auto Sequence")); - if(aut != NULL){ - aut->Start(); - } + //if(aut != NULL){ + // aut->Start(); + //} } void DentRobot::AutonomousPeriodic(){ printf("Running auto.\n"); From 5d1b61a109346b1c3b3269074ae63f025ecaea86 Mon Sep 17 00:00:00 2001 From: Adam Long Date: Thu, 26 Feb 2015 18:59:01 +0000 Subject: [PATCH 25/40] potential auto fixes maybe idk rlly --- Commands/Autonomous/AutoDrive.cpp | 7 ++++--- Commands/Autonomous/AutoDrive.h | 4 ++-- Commands/Autonomous/Autonomous.cpp | 13 ++++++------- Commands/Autonomous/CollectTote.cpp | 2 +- Commands/Autonomous/ReleaseTote.cpp | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Commands/Autonomous/AutoDrive.cpp b/Commands/Autonomous/AutoDrive.cpp index 9a46f5c..937ede2 100644 --- a/Commands/Autonomous/AutoDrive.cpp +++ b/Commands/Autonomous/AutoDrive.cpp @@ -1,16 +1,17 @@ #include "AutoDrive.h" #include "../../DentRobot.h" // Drive for a short while then stop. Just for testing -AutoDrive::AutoDrive(double duration, double p=-0.75) : Command("AutoDrive"){ +AutoDrive::AutoDrive(double duration, double xtmp=-0.75, double ytmp=0) : Command("AutoDrive"){ Requires(DentRobot::drivetrain); SetTimeout(duration); - power=p; + speed=xtmp; + strafe=ytmp; } void AutoDrive::Initialize(){ } void AutoDrive::Execute(){ //X axis, Y axis, Z axis, sensitivity, speed threshold (usually throttle), gyro - DentRobot::drivetrain->DriveMecanum(0.0,power,0.0,0.9,0.0); + DentRobot::drivetrain->DriveMecanum(strafe,speed,0.0,0.9,0.0); } bool AutoDrive::IsFinished(){ return IsTimedOut(); diff --git a/Commands/Autonomous/AutoDrive.h b/Commands/Autonomous/AutoDrive.h index f2d4785..03ce3b1 100644 --- a/Commands/Autonomous/AutoDrive.h +++ b/Commands/Autonomous/AutoDrive.h @@ -8,10 +8,10 @@ class AutoDrive: public Command{ private: - double power; + double speed, strafe; public: AutoDrive(double); - AutoDrive(double, double); + AutoDrive(double, double,double); void Initialize(); void Execute(); bool IsFinished(); diff --git a/Commands/Autonomous/Autonomous.cpp b/Commands/Autonomous/Autonomous.cpp index f12ace6..a5bbe2d 100644 --- a/Commands/Autonomous/Autonomous.cpp +++ b/Commands/Autonomous/Autonomous.cpp @@ -13,13 +13,12 @@ Autonomous::Autonomous(int seq){ switch(seq){ case 0: // Just for testing - AddSequential(new CollectTote()); - AddSequential(new Turn(90)); + AddSequential(new AutoDrive(.5,0,.25)); break; case 1: // Wait a desigated value, drive to Auto Zone (TM) Wait(SmartDashboard::GetNumber("Auto Wait Time")); - AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Zone Distance"), -0.75)); + AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Zone Distance"), -0.75,0)); break; case 2: // Get one tote and go to Auto Zone (TM) @@ -32,22 +31,22 @@ Autonomous::Autonomous(int seq){ printf("Waiting: %f\n",SmartDashboard::GetNumber("Auto Wait Time")); Wait(SmartDashboard::GetNumber("Auto Wait Time")); printf("Done"); - AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Tote Distance"), -0.75)); + AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Tote Distance"), -0.75,0)); AddSequential(new CollectTote()); AddSequential(new Raise()); - AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Tote Distance"), -0.75)); + AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Tote Distance"), -0.75,0)); AddSequential(new CollectTote()); AddSequential(new Lower()); AddSequential(new Raise()); printf("Three totes?: %d\n",SmartDashboard::GetBoolean("Three totes")); if(SmartDashboard::GetBoolean("Three totes")){ - AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Tote Distance"), -0.75)); + AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Tote Distance"), -0.75,0)); AddSequential(new CollectTote()); AddSequential(new Lower()); AddSequential(new Raise()); } AddSequential(new Turn(90)); - AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Zone Distance"), -0.75)); + AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Zone Distance"), -0.75,0)); AddSequential(new ReleaseTote()); break; default: diff --git a/Commands/Autonomous/CollectTote.cpp b/Commands/Autonomous/CollectTote.cpp index f596853..7f89be3 100644 --- a/Commands/Autonomous/CollectTote.cpp +++ b/Commands/Autonomous/CollectTote.cpp @@ -3,7 +3,7 @@ #include "AutoDrive.h" #include "../Collector/RollIn.h" CollectTote::CollectTote(){ - AddParallel(new AutoDrive(1.0, -0.75)); + AddParallel(new AutoDrive(1.0, -0.75,0)); AddSequential(new RollIn(1.0)); } // vim: ts=2:sw=2:et diff --git a/Commands/Autonomous/ReleaseTote.cpp b/Commands/Autonomous/ReleaseTote.cpp index 6672dd1..846985d 100644 --- a/Commands/Autonomous/ReleaseTote.cpp +++ b/Commands/Autonomous/ReleaseTote.cpp @@ -4,6 +4,6 @@ #include "../Collector/RollOut.h" ReleaseTote::ReleaseTote(){ AddParallel(new RollOut()); - AddParallel(new AutoDrive(0.5, 0.75)); + AddParallel(new AutoDrive(0.5, 0.75,0)); } // vim: ts=2:sw=2:et From 69f7b07f5ca8a4ce2f89feeda75e1491b6603a6b Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Thu, 26 Feb 2015 21:23:07 -0500 Subject: [PATCH 26/40] Fixed auto sequence 2 --- Commands/Autonomous/Autonomous.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Commands/Autonomous/Autonomous.cpp b/Commands/Autonomous/Autonomous.cpp index a5bbe2d..8c4229d 100644 --- a/Commands/Autonomous/Autonomous.cpp +++ b/Commands/Autonomous/Autonomous.cpp @@ -24,7 +24,9 @@ Autonomous::Autonomous(int seq){ // Get one tote and go to Auto Zone (TM) AddSequential(new CollectTote()); AddSequential(new Turn(90)); + AddSequential(new AutoDrive(2.0, 1.0, 0.0)); AddSequential(new ReleaseTote()); + AddSequential(new AutoDrive(0.5, -1.0, 0.0)); break; case 3: // Collect three totes, drive to Auto Zone (TM) From 8b27cf39f137c81f5b80a44cb887880a538e36b3 Mon Sep 17 00:00:00 2001 From: Adam Long Date: Fri, 27 Feb 2015 08:32:21 +0000 Subject: [PATCH 27/40] enabled auto --- DentRobot.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/DentRobot.cpp b/DentRobot.cpp index 00b1f7d..7795d1e 100644 --- a/DentRobot.cpp +++ b/DentRobot.cpp @@ -48,9 +48,9 @@ void DentRobot::DisabledPeriodic(){ void DentRobot::AutonomousInit(){ aut=new Autonomous(SmartDashboard::GetNumber("Auto Sequence")); printf("Enabling Auto Sequence %f\n",SmartDashboard::GetNumber("Auto Sequence")); - //if(aut != NULL){ - // aut->Start(); - //} + if(aut != NULL){ + aut->Start(); + } } void DentRobot::AutonomousPeriodic(){ printf("Running auto.\n"); From bbc4f699322d4f7845bc36aeb449cabc7380a09b Mon Sep 17 00:00:00 2001 From: Adam Long Date: Fri, 27 Feb 2015 09:30:32 +0000 Subject: [PATCH 28/40] increased roller outake speed --- Commands/Collector/RollOut.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Commands/Collector/RollOut.cpp b/Commands/Collector/RollOut.cpp index d4d78d5..7e06aab 100644 --- a/Commands/Collector/RollOut.cpp +++ b/Commands/Collector/RollOut.cpp @@ -8,7 +8,7 @@ void RollOut::Initialize(){ void RollOut::Execute(){ //TODO check this value to move the motors in the right direction // Devide by 2 twice because this speed should be half the collector speed - DentRobot::collector->MoveRollers(-DentRobot::oi->GetLeftThrottle()*.5); + DentRobot::collector->MoveRollers(-DentRobot::oi->GetLeftThrottle()*.8); } bool RollOut::IsFinished(){ return IsTimedOut(); From 0296bf783166107826349a91cb5a7d7b46fe6c96 Mon Sep 17 00:00:00 2001 From: Adam Long Date: Fri, 27 Feb 2015 11:47:10 +0000 Subject: [PATCH 29/40] added bin collecting, super strafing autogd --- Commands/Autonomous/Autonomous.cpp | 16 +++++++++------- Commands/BinElevator/BinLower.cpp | 5 +++-- Commands/BinElevator/BinLower.h | 4 +++- Commands/BinElevator/BinRaise.cpp | 5 +++-- Commands/BinElevator/BinRaise.h | 4 +++- DentRobot.cpp | 2 +- OI.cpp | 4 ++-- 7 files changed, 24 insertions(+), 16 deletions(-) diff --git a/Commands/Autonomous/Autonomous.cpp b/Commands/Autonomous/Autonomous.cpp index 8c4229d..db2a725 100644 --- a/Commands/Autonomous/Autonomous.cpp +++ b/Commands/Autonomous/Autonomous.cpp @@ -3,6 +3,8 @@ #include "../../DentRobot.h" #include "../Elevator/Raise.h" #include "../Elevator/Lower.h" +#include "../BinElevator/BinRaise.h" +#include "../BinElevator/BinLower.h" #include "AutoDrive.h" #include "Turn.h" #include "../Collector/RollIn.h" @@ -18,15 +20,15 @@ Autonomous::Autonomous(int seq){ case 1: // Wait a desigated value, drive to Auto Zone (TM) Wait(SmartDashboard::GetNumber("Auto Wait Time")); - AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Zone Distance"), -0.75,0)); + AddSequential(new BinRaise(1.2)); + AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Zone Distance"), 0,1)); + AddSequential(new BinLower(.9)); + //AddSequential(new AutoDrive(1.2, -0.75,0)); break; case 2: - // Get one tote and go to Auto Zone (TM) - AddSequential(new CollectTote()); - AddSequential(new Turn(90)); - AddSequential(new AutoDrive(2.0, 1.0, 0.0)); - AddSequential(new ReleaseTote()); - AddSequential(new AutoDrive(0.5, -1.0, 0.0)); + // Wait a desigated value, drive to Auto Zone (TM) + Wait(SmartDashboard::GetNumber("Auto Wait Time")); + AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Zone Distance"), 0,1)); break; case 3: // Collect three totes, drive to Auto Zone (TM) diff --git a/Commands/BinElevator/BinLower.cpp b/Commands/BinElevator/BinLower.cpp index b4001d8..ee2bc43 100644 --- a/Commands/BinElevator/BinLower.cpp +++ b/Commands/BinElevator/BinLower.cpp @@ -1,10 +1,11 @@ #include "BinLower.h" #include "../../DentRobot.h" #include "../../OI.h" -BinLower::BinLower() : Command("BinLower"){ +BinLower::BinLower(float t) : Command("BinLower"){ + timeout=t; } void BinLower::Initialize(){ - SetTimeout(2.5); + SetTimeout(timeout); } void BinLower::Execute(){ DentRobot::binElevator->Run(-1.0); diff --git a/Commands/BinElevator/BinLower.h b/Commands/BinElevator/BinLower.h index a3504b4..49813b0 100644 --- a/Commands/BinElevator/BinLower.h +++ b/Commands/BinElevator/BinLower.h @@ -5,8 +5,10 @@ #include "WPILib.h" class BinLower: public Command{ + private: + float timeout; public: - BinLower(); + BinLower(float); void Initialize(); void Execute(); bool IsFinished(); diff --git a/Commands/BinElevator/BinRaise.cpp b/Commands/BinElevator/BinRaise.cpp index 1fe0148..21f46f7 100644 --- a/Commands/BinElevator/BinRaise.cpp +++ b/Commands/BinElevator/BinRaise.cpp @@ -1,10 +1,11 @@ #include "BinRaise.h" #include "../../DentRobot.h" #include "../../OI.h" -BinRaise::BinRaise() : Command("BinRaise"){ +BinRaise::BinRaise(float t) : Command("BinRaise"){ + timeout=t; } void BinRaise::Initialize(){ - SetTimeout(3.0); + SetTimeout(timeout); } void BinRaise::Execute(){ DentRobot::binElevator->Run(1.0); diff --git a/Commands/BinElevator/BinRaise.h b/Commands/BinElevator/BinRaise.h index ea73454..d173430 100644 --- a/Commands/BinElevator/BinRaise.h +++ b/Commands/BinElevator/BinRaise.h @@ -5,8 +5,10 @@ #include "WPILib.h" class BinRaise: public Command{ + private: + float timeout; public: - BinRaise(); + BinRaise(float); void Initialize(); void Execute(); bool IsFinished(); diff --git a/DentRobot.cpp b/DentRobot.cpp index 7795d1e..d9465db 100644 --- a/DentRobot.cpp +++ b/DentRobot.cpp @@ -32,7 +32,7 @@ void DentRobot::RobotInit(){ SmartDashboard::PutBoolean("Three totes", true); // TODO: Calibrate the following two values // Distance (in time) to auto zone - SmartDashboard::PutNumber("Auto Zone Distance", 1.0); + SmartDashboard::PutNumber("Auto Zone Distance", 5.7); // Distance (in time) to auto tote (used in sequence 3) SmartDashboard::PutNumber("Auto Tote Distance", 0.5); diff --git a/OI.cpp b/OI.cpp index 916216b..3dcfaa2 100644 --- a/OI.cpp +++ b/OI.cpp @@ -35,8 +35,8 @@ OI::OI() { //JoystickButton *right8=new JoystickButton(rightStick, 8); //right7->WhenPressed(new BinOpenArms()); //right8->WhenPressed(new BinCloseArms()); - binRaise=new BinRaise(); - binLower=new BinLower(); + binRaise=new BinRaise(3.0); + binLower=new BinLower(2.0); right3->WhenPressed(binLower); right3->CancelWhenPressed(binRaise); right5->WhenPressed(binRaise); From aa812e33320a9f2f1d9a6991f41e1121221fdd20 Mon Sep 17 00:00:00 2001 From: Adam Long Date: Fri, 27 Feb 2015 12:10:46 +0000 Subject: [PATCH 30/40] Changed auto timeout and speed --- Commands/Autonomous/Autonomous.cpp | 2 +- DentRobot.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Commands/Autonomous/Autonomous.cpp b/Commands/Autonomous/Autonomous.cpp index db2a725..4a557f6 100644 --- a/Commands/Autonomous/Autonomous.cpp +++ b/Commands/Autonomous/Autonomous.cpp @@ -28,7 +28,7 @@ Autonomous::Autonomous(int seq){ case 2: // Wait a desigated value, drive to Auto Zone (TM) Wait(SmartDashboard::GetNumber("Auto Wait Time")); - AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Zone Distance"), 0,1)); + AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Zone Distance"), -.8,0)); break; case 3: // Collect three totes, drive to Auto Zone (TM) diff --git a/DentRobot.cpp b/DentRobot.cpp index d9465db..960383d 100644 --- a/DentRobot.cpp +++ b/DentRobot.cpp @@ -32,7 +32,7 @@ void DentRobot::RobotInit(){ SmartDashboard::PutBoolean("Three totes", true); // TODO: Calibrate the following two values // Distance (in time) to auto zone - SmartDashboard::PutNumber("Auto Zone Distance", 5.7); + SmartDashboard::PutNumber("Auto Zone Distance", 4.2); // Distance (in time) to auto tote (used in sequence 3) SmartDashboard::PutNumber("Auto Tote Distance", 0.5); From 55bbfcd44fb8bb84b1b6fbfde43c3934c261735e Mon Sep 17 00:00:00 2001 From: Adam Long Date: Fri, 27 Feb 2015 12:46:14 +0000 Subject: [PATCH 31/40] swapped auto sequences --- Commands/Autonomous/Autonomous.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Commands/Autonomous/Autonomous.cpp b/Commands/Autonomous/Autonomous.cpp index 4a557f6..5d50896 100644 --- a/Commands/Autonomous/Autonomous.cpp +++ b/Commands/Autonomous/Autonomous.cpp @@ -20,15 +20,15 @@ Autonomous::Autonomous(int seq){ case 1: // Wait a desigated value, drive to Auto Zone (TM) Wait(SmartDashboard::GetNumber("Auto Wait Time")); - AddSequential(new BinRaise(1.2)); - AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Zone Distance"), 0,1)); - AddSequential(new BinLower(.9)); - //AddSequential(new AutoDrive(1.2, -0.75,0)); + AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Zone Distance"), -.8,0)); break; case 2: // Wait a desigated value, drive to Auto Zone (TM) Wait(SmartDashboard::GetNumber("Auto Wait Time")); - AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Zone Distance"), -.8,0)); + AddSequential(new BinRaise(1.2)); + AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Zone Distance"), 0,1)); + AddSequential(new BinLower(.9)); + //AddSequential(new AutoDrive(1.2, -0.75,0)); break; case 3: // Collect three totes, drive to Auto Zone (TM) From 0035a736f492e7de42b86ee0de060ebef7114048 Mon Sep 17 00:00:00 2001 From: Adam Long Date: Fri, 27 Feb 2015 14:51:02 +0000 Subject: [PATCH 32/40] optimized auto values for the betterment of mankind --- Commands/Autonomous/Autonomous.cpp | 9 +++++---- Commands/Autonomous/Turn.cpp | 5 ++--- DentRobot.cpp | 7 ++++--- Subsystems/Elevator.cpp | 4 ++-- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Commands/Autonomous/Autonomous.cpp b/Commands/Autonomous/Autonomous.cpp index 5d50896..5eed551 100644 --- a/Commands/Autonomous/Autonomous.cpp +++ b/Commands/Autonomous/Autonomous.cpp @@ -20,15 +20,16 @@ Autonomous::Autonomous(int seq){ case 1: // Wait a desigated value, drive to Auto Zone (TM) Wait(SmartDashboard::GetNumber("Auto Wait Time")); - AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Zone Distance"), -.8,0)); + AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Zone Distance"), 0.8,0.0)); break; case 2: // Wait a desigated value, drive to Auto Zone (TM) Wait(SmartDashboard::GetNumber("Auto Wait Time")); + AddSequential(new Turn(SmartDashboard::GetNumber("TurnAmount"))); AddSequential(new BinRaise(1.2)); - AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Zone Distance"), 0,1)); - AddSequential(new BinLower(.9)); - //AddSequential(new AutoDrive(1.2, -0.75,0)); + AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Zone Distance"),0.75,0.0)); + //AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Zone Distance"), 0.0,-1.0)); + AddSequential(new BinLower(1.0)); break; case 3: // Collect three totes, drive to Auto Zone (TM) diff --git a/Commands/Autonomous/Turn.cpp b/Commands/Autonomous/Turn.cpp index 27b9e93..508eb1e 100644 --- a/Commands/Autonomous/Turn.cpp +++ b/Commands/Autonomous/Turn.cpp @@ -3,14 +3,13 @@ // Drive for a short while then stop. Just for testing Turn::Turn(int k) : Command("Turn"){ Requires(DentRobot::drivetrain); - degrees=k; - SetTimeout(0.85); + SetTimeout(k); } void Turn::Initialize(){ } void Turn::Execute(){ //X axis, Y axis, Z axis, sensitivity, speed threshold (usually throttle), gyro - DentRobot::drivetrain->DriveMecanum(0.0,0.0,1.0,0.9,0.0); + DentRobot::drivetrain->DriveMecanum(0.0,0.0,0.65,0.9,0.0); } bool Turn::IsFinished(){ return IsTimedOut(); diff --git a/DentRobot.cpp b/DentRobot.cpp index 960383d..47fc043 100644 --- a/DentRobot.cpp +++ b/DentRobot.cpp @@ -26,15 +26,16 @@ void DentRobot::RobotInit(){ SmartDashboard::PutNumber("CodeVersion",CODE_VERSION); // Autonomous // Sequence of autonomous command - SmartDashboard::PutNumber("Auto Sequence",1.0); - SmartDashboard::PutNumber("Auto Wait Time",1.0); + SmartDashboard::PutNumber("Auto Sequence",2.0); + SmartDashboard::PutNumber("Auto Wait Time",3.0); // If the robot will be picking up three totes in sequence 3 SmartDashboard::PutBoolean("Three totes", true); // TODO: Calibrate the following two values // Distance (in time) to auto zone - SmartDashboard::PutNumber("Auto Zone Distance", 4.2); + SmartDashboard::PutNumber("Auto Zone Distance", 3.0); // Distance (in time) to auto tote (used in sequence 3) SmartDashboard::PutNumber("Auto Tote Distance", 0.5); + SmartDashboard::PutNumber("TurnAmount",1.6); // Elevators SmartDashboard::PutBoolean("Bin Elevator Bottom", false); diff --git a/Subsystems/Elevator.cpp b/Subsystems/Elevator.cpp index 1cfe13e..bb26991 100644 --- a/Subsystems/Elevator.cpp +++ b/Subsystems/Elevator.cpp @@ -26,14 +26,14 @@ double Elevator::GetHeight(){ return elevatorEncoder->Get(); } bool Elevator::GetElevatorBottom(){ - SmartDashboard::PutBoolean("Elevator Bottom", elevatorBottom->Get()); + SmartDashboard::PutBoolean("Elevator Bottom", !elevatorBottom->Get()); return elevatorBottom->Get(); } bool Elevator::GetElevatorMiddle(){ return elevatorMiddle->Get(); } bool Elevator::GetElevatorTop(){ - SmartDashboard::PutBoolean("Elevator Top", elevatorTop->Get()); + SmartDashboard::PutBoolean("Elevator Top", !elevatorTop->Get()); return elevatorTop->Get(); } void Elevator::SetUseEncoder(bool param){ From 8fa8d3ba4242ecc25fcb42326498050153af8e84 Mon Sep 17 00:00:00 2001 From: Adam Long Date: Fri, 27 Feb 2015 14:52:57 +0000 Subject: [PATCH 33/40] increased default rotation amount --- DentRobot.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DentRobot.cpp b/DentRobot.cpp index 47fc043..5798f12 100644 --- a/DentRobot.cpp +++ b/DentRobot.cpp @@ -35,7 +35,7 @@ void DentRobot::RobotInit(){ SmartDashboard::PutNumber("Auto Zone Distance", 3.0); // Distance (in time) to auto tote (used in sequence 3) SmartDashboard::PutNumber("Auto Tote Distance", 0.5); - SmartDashboard::PutNumber("TurnAmount",1.6); + SmartDashboard::PutNumber("TurnAmount",1.9); // Elevators SmartDashboard::PutBoolean("Bin Elevator Bottom", false); From 2a3ddd6041b8d07a3158302b1cb13965e4c01096 Mon Sep 17 00:00:00 2001 From: Adam Long Date: Fri, 27 Feb 2015 15:56:29 +0000 Subject: [PATCH 34/40] Updated auto sequence 2 --- Commands/Autonomous/Autonomous.cpp | 1 + Commands/Autonomous/Turn.cpp | 2 +- DentRobot.cpp | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Commands/Autonomous/Autonomous.cpp b/Commands/Autonomous/Autonomous.cpp index 5eed551..b076a0b 100644 --- a/Commands/Autonomous/Autonomous.cpp +++ b/Commands/Autonomous/Autonomous.cpp @@ -30,6 +30,7 @@ Autonomous::Autonomous(int seq){ AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Zone Distance"),0.75,0.0)); //AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Zone Distance"), 0.0,-1.0)); AddSequential(new BinLower(1.0)); + AddSequential(new Turn(SmartDashboard::GetNumber("TurnAmount"))); break; case 3: // Collect three totes, drive to Auto Zone (TM) diff --git a/Commands/Autonomous/Turn.cpp b/Commands/Autonomous/Turn.cpp index 508eb1e..8af955b 100644 --- a/Commands/Autonomous/Turn.cpp +++ b/Commands/Autonomous/Turn.cpp @@ -9,7 +9,7 @@ void Turn::Initialize(){ } void Turn::Execute(){ //X axis, Y axis, Z axis, sensitivity, speed threshold (usually throttle), gyro - DentRobot::drivetrain->DriveMecanum(0.0,0.0,0.65,0.9,0.0); + DentRobot::drivetrain->DriveMecanum(0.0,0.0,0.6,0.9,0.0); } bool Turn::IsFinished(){ return IsTimedOut(); diff --git a/DentRobot.cpp b/DentRobot.cpp index 5798f12..e7d15bc 100644 --- a/DentRobot.cpp +++ b/DentRobot.cpp @@ -32,10 +32,10 @@ void DentRobot::RobotInit(){ SmartDashboard::PutBoolean("Three totes", true); // TODO: Calibrate the following two values // Distance (in time) to auto zone - SmartDashboard::PutNumber("Auto Zone Distance", 3.0); + SmartDashboard::PutNumber("Auto Zone Distance", 2.8); // Distance (in time) to auto tote (used in sequence 3) SmartDashboard::PutNumber("Auto Tote Distance", 0.5); - SmartDashboard::PutNumber("TurnAmount",1.9); + SmartDashboard::PutNumber("TurnAmount",2); // Elevators SmartDashboard::PutBoolean("Bin Elevator Bottom", false); From 1494fdceba7ffe00f03e5e28ea43f61a398ba24d Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Fri, 27 Feb 2015 15:44:18 -0500 Subject: [PATCH 35/40] Formatted commas, swapped AutoDrive x and y (untested) --- Commands/Autonomous/AutoDrive.cpp | 10 +++++----- Commands/Autonomous/AutoDrive.h | 4 ++-- Commands/Autonomous/Autonomous.cpp | 24 ++++++++++++------------ Commands/Autonomous/CollectTote.cpp | 2 +- Commands/Autonomous/ReleaseTote.cpp | 2 +- Commands/Autonomous/Turn.cpp | 4 ++-- Commands/Collector/RollOut.cpp | 2 +- Commands/Drivetrain/Drive.cpp | 6 +++--- Commands/Test/CheckDrive.cpp | 8 ++++---- DentRobot.cpp | 10 +++++----- Subsystems/BinElevator.cpp | 2 +- Subsystems/Collector.cpp | 2 +- Subsystems/Drivetrain.cpp | 6 +++--- Subsystems/Drivetrain.h | 4 ++-- Subsystems/Elevator.cpp | 2 +- 15 files changed, 44 insertions(+), 44 deletions(-) diff --git a/Commands/Autonomous/AutoDrive.cpp b/Commands/Autonomous/AutoDrive.cpp index 937ede2..ba14f03 100644 --- a/Commands/Autonomous/AutoDrive.cpp +++ b/Commands/Autonomous/AutoDrive.cpp @@ -1,23 +1,23 @@ #include "AutoDrive.h" #include "../../DentRobot.h" // Drive for a short while then stop. Just for testing -AutoDrive::AutoDrive(double duration, double xtmp=-0.75, double ytmp=0) : Command("AutoDrive"){ +AutoDrive::AutoDrive(double duration, double xtmp=0, double ytmp=-0.75) : Command("AutoDrive"){ Requires(DentRobot::drivetrain); SetTimeout(duration); - speed=xtmp; - strafe=ytmp; + x=xtmp; + y=ytmp; } void AutoDrive::Initialize(){ } void AutoDrive::Execute(){ //X axis, Y axis, Z axis, sensitivity, speed threshold (usually throttle), gyro - DentRobot::drivetrain->DriveMecanum(strafe,speed,0.0,0.9,0.0); + DentRobot::drivetrain->DriveMecanum(x, y, 0.0, 0.9, 0.0); } bool AutoDrive::IsFinished(){ return IsTimedOut(); } void AutoDrive::End(){ - DentRobot::drivetrain->DriveMecanum(0.0,0.0,0.0,0.9,0.0); + DentRobot::drivetrain->DriveMecanum(0.0, 0.0, 0.0, 0.9, 0.0); } void AutoDrive::Interrupted(){ End(); diff --git a/Commands/Autonomous/AutoDrive.h b/Commands/Autonomous/AutoDrive.h index 03ce3b1..6fa66ef 100644 --- a/Commands/Autonomous/AutoDrive.h +++ b/Commands/Autonomous/AutoDrive.h @@ -8,10 +8,10 @@ class AutoDrive: public Command{ private: - double speed, strafe; + double x, y; public: AutoDrive(double); - AutoDrive(double, double,double); + AutoDrive(double, double, double); void Initialize(); void Execute(); bool IsFinished(); diff --git a/Commands/Autonomous/Autonomous.cpp b/Commands/Autonomous/Autonomous.cpp index b076a0b..99ea7bf 100644 --- a/Commands/Autonomous/Autonomous.cpp +++ b/Commands/Autonomous/Autonomous.cpp @@ -15,44 +15,44 @@ Autonomous::Autonomous(int seq){ switch(seq){ case 0: // Just for testing - AddSequential(new AutoDrive(.5,0,.25)); + // Strafe at .25 power + AddSequential(new AutoDrive(0.5, 0.25, 0.0)); break; case 1: - // Wait a desigated value, drive to Auto Zone (TM) + // Drive to Auto Zone (TM) Wait(SmartDashboard::GetNumber("Auto Wait Time")); - AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Zone Distance"), 0.8,0.0)); + AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Zone Distance"), 0.0, 0.8)); break; case 2: - // Wait a desigated value, drive to Auto Zone (TM) + // Collect a tote, turn, drive to Auto Zone (TM) Wait(SmartDashboard::GetNumber("Auto Wait Time")); AddSequential(new Turn(SmartDashboard::GetNumber("TurnAmount"))); AddSequential(new BinRaise(1.2)); - AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Zone Distance"),0.75,0.0)); - //AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Zone Distance"), 0.0,-1.0)); + AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Zone Distance"), 0.0, 0.75)); AddSequential(new BinLower(1.0)); AddSequential(new Turn(SmartDashboard::GetNumber("TurnAmount"))); break; case 3: // Collect three totes, drive to Auto Zone (TM) - printf("Waiting: %f\n",SmartDashboard::GetNumber("Auto Wait Time")); + printf("Waiting: %f\n", SmartDashboard::GetNumber("Auto Wait Time")); Wait(SmartDashboard::GetNumber("Auto Wait Time")); printf("Done"); - AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Tote Distance"), -0.75,0)); + AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Tote Distance"), 0, -0.75)); AddSequential(new CollectTote()); AddSequential(new Raise()); - AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Tote Distance"), -0.75,0)); + AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Tote Distance"), 0, -0.75)); AddSequential(new CollectTote()); AddSequential(new Lower()); AddSequential(new Raise()); - printf("Three totes?: %d\n",SmartDashboard::GetBoolean("Three totes")); + printf("Three totes?: %d\n", SmartDashboard::GetBoolean("Three totes")); if(SmartDashboard::GetBoolean("Three totes")){ - AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Tote Distance"), -0.75,0)); + AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Tote Distance"), 0, -0.75)); AddSequential(new CollectTote()); AddSequential(new Lower()); AddSequential(new Raise()); } AddSequential(new Turn(90)); - AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Zone Distance"), -0.75,0)); + AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Zone Distance"), 0, -0.75)); AddSequential(new ReleaseTote()); break; default: diff --git a/Commands/Autonomous/CollectTote.cpp b/Commands/Autonomous/CollectTote.cpp index 7f89be3..5ee7deb 100644 --- a/Commands/Autonomous/CollectTote.cpp +++ b/Commands/Autonomous/CollectTote.cpp @@ -3,7 +3,7 @@ #include "AutoDrive.h" #include "../Collector/RollIn.h" CollectTote::CollectTote(){ - AddParallel(new AutoDrive(1.0, -0.75,0)); + AddParallel(new AutoDrive(1.0, -0.75, 0.0)); AddSequential(new RollIn(1.0)); } // vim: ts=2:sw=2:et diff --git a/Commands/Autonomous/ReleaseTote.cpp b/Commands/Autonomous/ReleaseTote.cpp index 846985d..8d01114 100644 --- a/Commands/Autonomous/ReleaseTote.cpp +++ b/Commands/Autonomous/ReleaseTote.cpp @@ -4,6 +4,6 @@ #include "../Collector/RollOut.h" ReleaseTote::ReleaseTote(){ AddParallel(new RollOut()); - AddParallel(new AutoDrive(0.5, 0.75,0)); + AddParallel(new AutoDrive(0.5, 0, 0.75)); } // vim: ts=2:sw=2:et diff --git a/Commands/Autonomous/Turn.cpp b/Commands/Autonomous/Turn.cpp index 8af955b..11a51d9 100644 --- a/Commands/Autonomous/Turn.cpp +++ b/Commands/Autonomous/Turn.cpp @@ -9,14 +9,14 @@ void Turn::Initialize(){ } void Turn::Execute(){ //X axis, Y axis, Z axis, sensitivity, speed threshold (usually throttle), gyro - DentRobot::drivetrain->DriveMecanum(0.0,0.0,0.6,0.9,0.0); + DentRobot::drivetrain->DriveMecanum(0.0, 0.0, 0.6, 0.9, 0.0); } bool Turn::IsFinished(){ return IsTimedOut(); } void Turn::End(){ // Stop driving - DentRobot::drivetrain->DriveMecanum(0.0,0.0,0.0,0.9,0.0); + DentRobot::drivetrain->DriveMecanum(0.0, 0.0, 0.0, 0.9, 0.0); } void Turn::Interrupted(){ End(); diff --git a/Commands/Collector/RollOut.cpp b/Commands/Collector/RollOut.cpp index 7e06aab..d3f5150 100644 --- a/Commands/Collector/RollOut.cpp +++ b/Commands/Collector/RollOut.cpp @@ -8,7 +8,7 @@ void RollOut::Initialize(){ void RollOut::Execute(){ //TODO check this value to move the motors in the right direction // Devide by 2 twice because this speed should be half the collector speed - DentRobot::collector->MoveRollers(-DentRobot::oi->GetLeftThrottle()*.8); + DentRobot::collector->MoveRollers(-DentRobot::oi->GetLeftThrottle() * 0.8); } bool RollOut::IsFinished(){ return IsTimedOut(); diff --git a/Commands/Drivetrain/Drive.cpp b/Commands/Drivetrain/Drive.cpp index a8c1241..4b79176 100644 --- a/Commands/Drivetrain/Drive.cpp +++ b/Commands/Drivetrain/Drive.cpp @@ -6,11 +6,11 @@ Drive::Drive() : Command("Drive"){ void Drive::Initialize(){ } void Drive::Execute(){ - double x,y,z; - //Code to lock the x axis when not holding button 1 + double x, y, z; x = DentRobot::oi->GetLeftStick()->GetRawAxis(0); z = DentRobot::oi->GetLeftStick()->GetRawAxis(2); y = DentRobot::oi->GetLeftStick()->GetRawAxis(1); + //Code to lock the x axis when not holding button 1 //if (DentRobot::oi->GetLeftStick()->GetRawButton(1)){ // x=0; //} @@ -18,7 +18,7 @@ void Drive::Execute(){ // y=0; //} //X axis, Y axis, Z axis, sensitivity, speed threshold (usually throttle), gyro - DentRobot::drivetrain->DriveMecanum(x,y,z,0.9,0); + DentRobot::drivetrain->DriveMecanum(x, y, z, 0.9, 0.0); } bool Drive::IsFinished(){ return IsTimedOut(); diff --git a/Commands/Test/CheckDrive.cpp b/Commands/Test/CheckDrive.cpp index d51d658..8ce3b65 100644 --- a/Commands/Test/CheckDrive.cpp +++ b/Commands/Test/CheckDrive.cpp @@ -13,16 +13,16 @@ void CheckDrive::Initialize(){ void CheckDrive::Execute(){ switch(motor){ case DRIVE_FRONT_LEFT_CAN: - DentRobot::drivetrain->TestMotor(DentRobot::drivetrain->FRONTLEFT,1); + DentRobot::drivetrain->TestMotor(DentRobot::drivetrain->FRONTLEFT, 1); break; case DRIVE_FRONT_RIGHT_CAN: - DentRobot::drivetrain->TestMotor(DentRobot::drivetrain->FRONTRIGHT,1); + DentRobot::drivetrain->TestMotor(DentRobot::drivetrain->FRONTRIGHT, 1); break; case DRIVE_BACK_LEFT_CAN: - DentRobot::drivetrain->TestMotor(DentRobot::drivetrain->BACKLEFT,1); + DentRobot::drivetrain->TestMotor(DentRobot::drivetrain->BACKLEFT, 1); break; case DRIVE_BACK_RIGHT_CAN: - DentRobot::drivetrain->TestMotor(DentRobot::drivetrain->BACKRIGHT,1); + DentRobot::drivetrain->TestMotor(DentRobot::drivetrain->BACKRIGHT, 1); break; default: break; diff --git a/DentRobot.cpp b/DentRobot.cpp index e7d15bc..5818977 100644 --- a/DentRobot.cpp +++ b/DentRobot.cpp @@ -23,11 +23,11 @@ DentRobot::DentRobot(){ printf("The robot is on\n"); } void DentRobot::RobotInit(){ - SmartDashboard::PutNumber("CodeVersion",CODE_VERSION); + SmartDashboard::PutNumber("CodeVersion", CODE_VERSION); // Autonomous // Sequence of autonomous command - SmartDashboard::PutNumber("Auto Sequence",2.0); - SmartDashboard::PutNumber("Auto Wait Time",3.0); + SmartDashboard::PutNumber("Auto Sequence", 2.0); + SmartDashboard::PutNumber("Auto Wait Time", 3.0); // If the robot will be picking up three totes in sequence 3 SmartDashboard::PutBoolean("Three totes", true); // TODO: Calibrate the following two values @@ -35,7 +35,7 @@ void DentRobot::RobotInit(){ SmartDashboard::PutNumber("Auto Zone Distance", 2.8); // Distance (in time) to auto tote (used in sequence 3) SmartDashboard::PutNumber("Auto Tote Distance", 0.5); - SmartDashboard::PutNumber("TurnAmount",2); + SmartDashboard::PutNumber("TurnAmount", 2); // Elevators SmartDashboard::PutBoolean("Bin Elevator Bottom", false); @@ -48,7 +48,7 @@ void DentRobot::DisabledPeriodic(){ } void DentRobot::AutonomousInit(){ aut=new Autonomous(SmartDashboard::GetNumber("Auto Sequence")); - printf("Enabling Auto Sequence %f\n",SmartDashboard::GetNumber("Auto Sequence")); + printf("Enabling Auto Sequence %f\n", SmartDashboard::GetNumber("Auto Sequence")); if(aut != NULL){ aut->Start(); } diff --git a/Subsystems/BinElevator.cpp b/Subsystems/BinElevator.cpp index 22f3c74..ffc79ee 100644 --- a/Subsystems/BinElevator.cpp +++ b/Subsystems/BinElevator.cpp @@ -2,7 +2,7 @@ #include "../RobotMap.h" BinElevator::BinElevator(){ motor=new CANTalon(BINELEVATOR_CAN); - elevatorEncoder=new Encoder(BINELEVATOR_ENCODERA,BINELEVATOR_ENCODERB,false); + elevatorEncoder=new Encoder(BINELEVATOR_ENCODERA, BINELEVATOR_ENCODERB, false); elevatorBottom=new DigitalInput(BINELEVATOR_BOTTOM_DIO); elevatorTop=new DigitalInput(BINELEVATOR_TOP_DIO); } diff --git a/Subsystems/Collector.cpp b/Subsystems/Collector.cpp index f9b1f17..7e5296a 100644 --- a/Subsystems/Collector.cpp +++ b/Subsystems/Collector.cpp @@ -15,7 +15,7 @@ void Collector::MoveRollers(double a){ collectorMotorBottom->Set(-a); collectorMotorRamp->Set(a); collectorMotorRight->Set(-a); - printf("Roller power: %f\n",a); + printf("Roller power: %f\n", a); } double Collector::GetSonarDistance(){ return sonarAnalog->GetAverageVoltage(); diff --git a/Subsystems/Drivetrain.cpp b/Subsystems/Drivetrain.cpp index 0e4970f..d6bd2d3 100644 --- a/Subsystems/Drivetrain.cpp +++ b/Subsystems/Drivetrain.cpp @@ -12,9 +12,9 @@ void Drivetrain::InitDefaultCommand(){ SetDefaultCommand(new Drive()); } void Drivetrain::DriveMecanum(float x, float y, float z, float sensitivity, float gyro){ - double correctY = (sensitivity*(pow(y,3))+(1-sensitivity)*y); - double correctX = -(sensitivity*(pow(x,3))+(1-sensitivity)*x); - double correctZ = -z *.5; + double correctY = (sensitivity*(pow(y, 3))+(1-sensitivity)*y); + double correctX = -(sensitivity*(pow(x, 3))+(1-sensitivity)*x); + double correctZ = -z * 0.5; rightFront->Set((-correctX + correctY - correctZ)); leftFront->Set((correctX + correctY + correctZ)*-1); rightRear->Set((correctX + correctY - correctZ)); diff --git a/Subsystems/Drivetrain.h b/Subsystems/Drivetrain.h index 15b9d61..4550de8 100644 --- a/Subsystems/Drivetrain.h +++ b/Subsystems/Drivetrain.h @@ -15,9 +15,9 @@ class Drivetrain: public Subsystem{ BACKLEFT }; void InitDefaultCommand(); - void DriveMecanum(float,float,float,float,float); + void DriveMecanum(float, float, float, float, float); void DriveArcade(float, float); - void TestMotor(e_motors,float); + void TestMotor(e_motors, float); }; #endif // vim: ts=2:sw=2:et diff --git a/Subsystems/Elevator.cpp b/Subsystems/Elevator.cpp index bb26991..af1e32a 100644 --- a/Subsystems/Elevator.cpp +++ b/Subsystems/Elevator.cpp @@ -2,7 +2,7 @@ #include "../RobotMap.h" Elevator::Elevator(){ motor=new CANTalon(ELEVATOR_CAN); - elevatorEncoder=new Encoder(ELEVATOR_ENCODERA,ELEVATOR_ENCODERB,false); + elevatorEncoder=new Encoder(ELEVATOR_ENCODERA, ELEVATOR_ENCODERB, false); elevatorBottom=new DigitalInput(ELEVATOR_BOTTOM_DIO); elevatorMiddle=new DigitalInput(ELEVATOR_MIDDLE_DIO); elevatorTop=new DigitalInput(ELEVATOR_TOP_DIO); From 90155811fbd35c741098f1a0535868d543d09b0d Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Fri, 27 Feb 2015 16:42:11 -0500 Subject: [PATCH 36/40] Negated drive y value (untested) --- Commands/Autonomous/Autonomous.cpp | 12 ++++++------ Commands/Drivetrain/Drive.cpp | 2 +- DentRobot.cpp | 4 +--- Subsystems/Drivetrain.cpp | 2 +- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/Commands/Autonomous/Autonomous.cpp b/Commands/Autonomous/Autonomous.cpp index 99ea7bf..cecbb2a 100644 --- a/Commands/Autonomous/Autonomous.cpp +++ b/Commands/Autonomous/Autonomous.cpp @@ -21,14 +21,14 @@ Autonomous::Autonomous(int seq){ case 1: // Drive to Auto Zone (TM) Wait(SmartDashboard::GetNumber("Auto Wait Time")); - AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Zone Distance"), 0.0, 0.8)); + AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Zone Distance"), 0.0, -0.8)); break; case 2: // Collect a tote, turn, drive to Auto Zone (TM) Wait(SmartDashboard::GetNumber("Auto Wait Time")); AddSequential(new Turn(SmartDashboard::GetNumber("TurnAmount"))); AddSequential(new BinRaise(1.2)); - AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Zone Distance"), 0.0, 0.75)); + AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Zone Distance"), 0.0, -0.75)); AddSequential(new BinLower(1.0)); AddSequential(new Turn(SmartDashboard::GetNumber("TurnAmount"))); break; @@ -37,22 +37,22 @@ Autonomous::Autonomous(int seq){ printf("Waiting: %f\n", SmartDashboard::GetNumber("Auto Wait Time")); Wait(SmartDashboard::GetNumber("Auto Wait Time")); printf("Done"); - AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Tote Distance"), 0, -0.75)); + AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Tote Distance"), 0, 0.75)); AddSequential(new CollectTote()); AddSequential(new Raise()); - AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Tote Distance"), 0, -0.75)); + AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Tote Distance"), 0, 0.75)); AddSequential(new CollectTote()); AddSequential(new Lower()); AddSequential(new Raise()); printf("Three totes?: %d\n", SmartDashboard::GetBoolean("Three totes")); if(SmartDashboard::GetBoolean("Three totes")){ - AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Tote Distance"), 0, -0.75)); + AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Tote Distance"), 0, 0.75)); AddSequential(new CollectTote()); AddSequential(new Lower()); AddSequential(new Raise()); } AddSequential(new Turn(90)); - AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Zone Distance"), 0, -0.75)); + AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Zone Distance"), 0, 0.75)); AddSequential(new ReleaseTote()); break; default: diff --git a/Commands/Drivetrain/Drive.cpp b/Commands/Drivetrain/Drive.cpp index 4b79176..553302f 100644 --- a/Commands/Drivetrain/Drive.cpp +++ b/Commands/Drivetrain/Drive.cpp @@ -8,8 +8,8 @@ void Drive::Initialize(){ void Drive::Execute(){ double x, y, z; x = DentRobot::oi->GetLeftStick()->GetRawAxis(0); + y = -DentRobot::oi->GetLeftStick()->GetRawAxis(1); z = DentRobot::oi->GetLeftStick()->GetRawAxis(2); - y = DentRobot::oi->GetLeftStick()->GetRawAxis(1); //Code to lock the x axis when not holding button 1 //if (DentRobot::oi->GetLeftStick()->GetRawButton(1)){ // x=0; diff --git a/DentRobot.cpp b/DentRobot.cpp index 5818977..ab77d22 100644 --- a/DentRobot.cpp +++ b/DentRobot.cpp @@ -18,8 +18,6 @@ DentRobot::DentRobot(){ pneumatics=new Pneumatics(); //CameraServer::GetInstance()->SetQuality(25); //CameraServer::GetInstance()->StartAutomaticCapture("cam0"); - //SmartDashboard::PutNumber("Auto Wait Time", 1.0); - //SmartDashboard::PutNumber("Auto Sequence", 0); printf("The robot is on\n"); } void DentRobot::RobotInit(){ @@ -35,7 +33,7 @@ void DentRobot::RobotInit(){ SmartDashboard::PutNumber("Auto Zone Distance", 2.8); // Distance (in time) to auto tote (used in sequence 3) SmartDashboard::PutNumber("Auto Tote Distance", 0.5); - SmartDashboard::PutNumber("TurnAmount", 2); + SmartDashboard::PutNumber("TurnAmount", 2.0); // Elevators SmartDashboard::PutBoolean("Bin Elevator Bottom", false); diff --git a/Subsystems/Drivetrain.cpp b/Subsystems/Drivetrain.cpp index d6bd2d3..78c3480 100644 --- a/Subsystems/Drivetrain.cpp +++ b/Subsystems/Drivetrain.cpp @@ -12,8 +12,8 @@ void Drivetrain::InitDefaultCommand(){ SetDefaultCommand(new Drive()); } void Drivetrain::DriveMecanum(float x, float y, float z, float sensitivity, float gyro){ - double correctY = (sensitivity*(pow(y, 3))+(1-sensitivity)*y); double correctX = -(sensitivity*(pow(x, 3))+(1-sensitivity)*x); + double correctY = -(sensitivity*(pow(y, 3))+(1-sensitivity)*y); double correctZ = -z * 0.5; rightFront->Set((-correctX + correctY - correctZ)); leftFront->Set((correctX + correctY + correctZ)*-1); From 05d755f87bede64a1b7997df389ac7b5caf53db5 Mon Sep 17 00:00:00 2001 From: Adam Long Date: Sat, 28 Feb 2015 07:22:43 +0000 Subject: [PATCH 37/40] added half speed and increased collector speed --- Commands/Collector/RollIn.cpp | 2 +- DentRobot.cpp | 2 ++ Subsystems/Drivetrain.cpp | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Commands/Collector/RollIn.cpp b/Commands/Collector/RollIn.cpp index 1388c69..4d3e7c3 100644 --- a/Commands/Collector/RollIn.cpp +++ b/Commands/Collector/RollIn.cpp @@ -11,7 +11,7 @@ void RollIn::Execute(){ if(cvt>=1.0){ DentRobot::collector->MoveRollers(1.0); }else{ - DentRobot::collector->MoveRollers(cvt); + DentRobot::collector->MoveRollers(cvt*1.5); } } bool RollIn::IsFinished(){ diff --git a/DentRobot.cpp b/DentRobot.cpp index e7d15bc..7f2174a 100644 --- a/DentRobot.cpp +++ b/DentRobot.cpp @@ -42,6 +42,8 @@ void DentRobot::RobotInit(){ SmartDashboard::PutBoolean("Bin Elevator Top", false); SmartDashboard::PutBoolean("Elevator Bottom", false); SmartDashboard::PutBoolean("Elevator Top", false); + //Drive speed + SmartDashboard::PutNumber("DriveSpeedReductionThresh",2); } void DentRobot::DisabledPeriodic(){ Scheduler::GetInstance()->Run(); diff --git a/Subsystems/Drivetrain.cpp b/Subsystems/Drivetrain.cpp index 0e4970f..c8528ee 100644 --- a/Subsystems/Drivetrain.cpp +++ b/Subsystems/Drivetrain.cpp @@ -15,6 +15,9 @@ void Drivetrain::DriveMecanum(float x, float y, float z, float sensitivity, floa double correctY = (sensitivity*(pow(y,3))+(1-sensitivity)*y); double correctX = -(sensitivity*(pow(x,3))+(1-sensitivity)*x); double correctZ = -z *.5; + if (DentRobot::oi->GetRightStick()->GetRawButton(9)){ + correctY /= SmartDashboard::GetNumber("DriveSpeedReductionThresh"); + } rightFront->Set((-correctX + correctY - correctZ)); leftFront->Set((correctX + correctY + correctZ)*-1); rightRear->Set((correctX + correctY - correctZ)); From 0278354e19e1d575594db7a5fbb56cba6608c77e Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Sat, 28 Feb 2015 07:14:59 -0500 Subject: [PATCH 38/40] Ignore vision files --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index ebc65cf..741abc9 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,7 @@ Debug bin wpilib +CMakeCache.txt +CMakeFiles +cmake_install.cmake +vision From d9b34cd02af3d7011e5b60c72b8a9a1c948fe4ba Mon Sep 17 00:00:00 2001 From: Adam Long Date: Sat, 28 Feb 2015 08:13:26 +0000 Subject: [PATCH 39/40] fixed joystick button for slow speed --- Subsystems/Drivetrain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Subsystems/Drivetrain.cpp b/Subsystems/Drivetrain.cpp index c8528ee..488fa49 100644 --- a/Subsystems/Drivetrain.cpp +++ b/Subsystems/Drivetrain.cpp @@ -15,7 +15,7 @@ void Drivetrain::DriveMecanum(float x, float y, float z, float sensitivity, floa double correctY = (sensitivity*(pow(y,3))+(1-sensitivity)*y); double correctX = -(sensitivity*(pow(x,3))+(1-sensitivity)*x); double correctZ = -z *.5; - if (DentRobot::oi->GetRightStick()->GetRawButton(9)){ + if (DentRobot::oi->GetLeftStick()->GetRawButton(9)){ correctY /= SmartDashboard::GetNumber("DriveSpeedReductionThresh"); } rightFront->Set((-correctX + correctY - correctZ)); From 2416da26b19dd31e3c267be46fc0b1f1161abdc4 Mon Sep 17 00:00:00 2001 From: Adam Long Date: Sat, 28 Feb 2015 08:23:54 +0000 Subject: [PATCH 40/40] Fixed auto sequence 3 --- Commands/Autonomous/Autonomous.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Commands/Autonomous/Autonomous.cpp b/Commands/Autonomous/Autonomous.cpp index cecbb2a..d3339a1 100644 --- a/Commands/Autonomous/Autonomous.cpp +++ b/Commands/Autonomous/Autonomous.cpp @@ -51,7 +51,7 @@ Autonomous::Autonomous(int seq){ AddSequential(new Lower()); AddSequential(new Raise()); } - AddSequential(new Turn(90)); + AddSequential(new Turn(SmartDashboard::GetNumber("TurnAmount"))); AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Zone Distance"), 0, 0.75)); AddSequential(new ReleaseTote()); break;