From e68dc00c21cc7ccb5e2281498b712ba3a688ca20 Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Sat, 7 Feb 2015 12:32:46 -0500 Subject: [PATCH 1/9] Continued working on auto --- Commands/Autonomous/Autonomous.cpp | 16 +--------------- Commands/Autonomous/Autonomous.h | 7 +------ DentRobot.cpp | 11 ++++++++++- DentRobot.h | 4 +++- 4 files changed, 15 insertions(+), 23 deletions(-) diff --git a/Commands/Autonomous/Autonomous.cpp b/Commands/Autonomous/Autonomous.cpp index c3e2e3b..57848c5 100644 --- a/Commands/Autonomous/Autonomous.cpp +++ b/Commands/Autonomous/Autonomous.cpp @@ -1,20 +1,6 @@ #include "Autonomous.h" #include "AutoDrive.h" -#include -#include "Commands/CommandGroup.h" #include "../../DentRobot.h" -Autonomous::Autonomous() : CommandGroup("Autonomous"){ +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/Autonomous/Autonomous.h b/Commands/Autonomous/Autonomous.h index e584b17..52161e0 100644 --- a/Commands/Autonomous/Autonomous.h +++ b/Commands/Autonomous/Autonomous.h @@ -1,7 +1,7 @@ #ifndef AUTONOMOUS_H #define AUTONOMOUS_H -#include "Commands/Command.h" +#include "Commands/CommandGroup.h" #include "../../CommandBase.h" #include "../../DentRobot.h" #include "WPILib.h" @@ -9,10 +9,5 @@ class Autonomous: public CommandGroup{ public: Autonomous(); - void Initialize(); - void Execute(); - bool IsFinished(); - void End(); - void Interrupted(); }; #endif diff --git a/DentRobot.cpp b/DentRobot.cpp index 819efba..0489d39 100644 --- a/DentRobot.cpp +++ b/DentRobot.cpp @@ -1,10 +1,12 @@ #include "DentRobot.h" +#include "Commands/Autonomous/Autonomous.h" OI* DentRobot::oi=NULL; Collector* DentRobot::collector=NULL; Drivetrain* DentRobot::drivetrain=NULL; Elevator* DentRobot::elevator=NULL; DIO* DentRobot::dio = NULL; -AirCompressor * DentRobot::airCompressor=NULL; +AirCompressor* DentRobot::airCompressor=NULL; +Autonomous* DentRobot::aut=NULL; DentRobot::DentRobot(){ oi=new OI(); collector=new Collector(); @@ -12,6 +14,7 @@ DentRobot::DentRobot(){ elevator=new Elevator(); dio = new DIO(); airCompressor=new AirCompressor(); + aut=new Autonomous(); printf("Initialized"); } void DentRobot::RobotInit(){ @@ -21,11 +24,17 @@ void DentRobot::DisabledPeriodic(){ Scheduler::GetInstance()->Run(); } void DentRobot::AutonomousInit(){ + if(aut != NULL){ + aut->Start(); + } } void DentRobot::AutonomousPeriodic(){ Scheduler::GetInstance()->Run(); } void DentRobot::TeleopInit(){ + //if (aut != NULL){ + // aut->Cancel(); + //} } void DentRobot::TeleopPeriodic(){ Scheduler::GetInstance()->Run(); diff --git a/DentRobot.h b/DentRobot.h index 653114a..eb23f1a 100644 --- a/DentRobot.h +++ b/DentRobot.h @@ -7,17 +7,19 @@ #include "Subsystems/Drivetrain.h" #include "Subsystems/Collector.h" #include "Subsystems/AirCompressor.h" +#include "Commands/Autonomous/Autonomous.h" class DentRobot: public IterativeRobot { private: Command *driveCommand = NULL; public: + DentRobot(); static OI* oi; static Collector* collector; static Drivetrain* drivetrain; static Elevator* elevator; static DIO* dio; static AirCompressor* airCompressor; - DentRobot(); + static Autonomous* aut; void RobotInit(); void DisabledPeriodic(); void AutonomousInit(); From b26a63bcc13e7581b07f6f8885885a8b73fec516 Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Sat, 7 Feb 2015 12:50:36 -0500 Subject: [PATCH 2/9] Minor fixes --- .env | 4 ++-- Commands/Autonomous/Autonomous.cpp | 1 + Commands/Elevator/Lower.cpp | 6 +++--- Commands/Elevator/Raise.cpp | 6 +++--- DentRobot.cpp | 2 +- DentRobot.h | 2 +- 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.env b/.env index f4bc334..7bcd405 100644 --- a/.env +++ b/.env @@ -2,7 +2,7 @@ function mb(){ vagrant ssh -c "cd /vagrant/src;make clean 2>&1 >/dev/null;make" } function mc(){ - vagrant ssh -c "cd /vagrant/src;make clean" + vagrant ssh -c "cd /vagrant/src;make clean 2>&1 >/dev/null" } function mk(){ vagrant ssh -c "cd /vagrant/src;make" @@ -11,5 +11,5 @@ function md(){ vagrant ssh -c "cd /vagrant/src;make deploy" } function ma(){ - vagrant ssh -c "cd /vagrant/src;make clean;make;make deploy" + vagrant ssh -c "cd /vagrant/src;make clean 2>&1 >/dev/null;make;make deploy" } diff --git a/Commands/Autonomous/Autonomous.cpp b/Commands/Autonomous/Autonomous.cpp index 57848c5..12be62e 100644 --- a/Commands/Autonomous/Autonomous.cpp +++ b/Commands/Autonomous/Autonomous.cpp @@ -1,6 +1,7 @@ #include "Autonomous.h" #include "AutoDrive.h" #include "../../DentRobot.h" +#include "../Elevator/Raise.h" Autonomous::Autonomous(){ AddSequential(new AutoDrive()); } diff --git a/Commands/Elevator/Lower.cpp b/Commands/Elevator/Lower.cpp index 8d75a74..1e4e658 100644 --- a/Commands/Elevator/Lower.cpp +++ b/Commands/Elevator/Lower.cpp @@ -4,16 +4,16 @@ Lower::Lower() : Command("Lower"){ } void Lower::Initialize(){ - SetTimeout(2.0); + SetTimeout(2.0); } void Lower::Execute(){ DentRobot::elevator->Run((-DentRobot::oi->GetLeftStick()->GetRawAxis(3)+1.0)/2); } bool Lower::IsFinished(){ if (!DentRobot::dio->Get(DentRobot::dio->ELEVATORBOTTOM) || IsTimedOut()){ - return true; + return true; }else{ - return false; + return false; } } void Lower::End(){ diff --git a/Commands/Elevator/Raise.cpp b/Commands/Elevator/Raise.cpp index 35372ea..385ec52 100644 --- a/Commands/Elevator/Raise.cpp +++ b/Commands/Elevator/Raise.cpp @@ -4,16 +4,16 @@ Raise::Raise() : Command("Raise"){ } void Raise::Initialize(){ - SetTimeout(2.0); + SetTimeout(2.0); } void Raise::Execute(){ DentRobot::elevator->Run(-(-DentRobot::oi->GetLeftStick()->GetRawAxis(3)+1.0)/2); } bool Raise::IsFinished(){ if (!DentRobot::dio->Get(DentRobot::dio->ELEVATORBOTTOM) || IsTimedOut()){ - return true; + return true; }else{ - return false; + return false; } } void Raise::End(){ diff --git a/DentRobot.cpp b/DentRobot.cpp index 0489d39..26365f7 100644 --- a/DentRobot.cpp +++ b/DentRobot.cpp @@ -6,7 +6,7 @@ Drivetrain* DentRobot::drivetrain=NULL; Elevator* DentRobot::elevator=NULL; DIO* DentRobot::dio = NULL; AirCompressor* DentRobot::airCompressor=NULL; -Autonomous* DentRobot::aut=NULL; +CommandGroup* DentRobot::aut=NULL; DentRobot::DentRobot(){ oi=new OI(); collector=new Collector(); diff --git a/DentRobot.h b/DentRobot.h index eb23f1a..1f72a33 100644 --- a/DentRobot.h +++ b/DentRobot.h @@ -19,7 +19,7 @@ class DentRobot: public IterativeRobot { static Elevator* elevator; static DIO* dio; static AirCompressor* airCompressor; - static Autonomous* aut; + static CommandGroup* aut; void RobotInit(); void DisabledPeriodic(); void AutonomousInit(); From 113f81a0b0eacdfd43251fae236474341ac676cd Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Sat, 7 Feb 2015 13:03:00 -0500 Subject: [PATCH 3/9] Moved DIOs into individual classes (untested) --- CommandBase.cpp | 3 --- CommandBase.h | 2 -- Commands/Elevator/Calibrate.cpp | 2 +- Commands/Elevator/Lower.cpp | 2 +- Commands/Elevator/Raise.cpp | 2 +- DentRobot.cpp | 2 -- DentRobot.h | 2 -- RobotMap.h | 3 ++- Subsystems/Collector.cpp | 1 - Subsystems/Collector.h | 1 - Subsystems/DIO.cpp | 21 --------------------- Subsystems/DIO.h | 17 ----------------- Subsystems/Elevator.cpp | 8 ++++++++ Subsystems/Elevator.h | 3 +++ 14 files changed, 16 insertions(+), 53 deletions(-) delete mode 100644 Subsystems/DIO.cpp delete mode 100644 Subsystems/DIO.h diff --git a/CommandBase.cpp b/CommandBase.cpp index c68ce0e..dfd3a78 100644 --- a/CommandBase.cpp +++ b/CommandBase.cpp @@ -2,12 +2,10 @@ #include "Subsystems/Drivetrain.h" #include "Subsystems/Collector.h" #include "Subsystems/Elevator.h" -#include "Subsystems/DIO.h" #include "Subsystems/AirCompressor.h" Drivetrain* CommandBase::drivetrain = NULL; Collector* CommandBase::collector = NULL; Elevator* CommandBase::elevator = NULL; -DIO* CommandBase::dio = NULL; AirCompressor* CommandBase::airCompressor = NULL; OI* CommandBase::oi = NULL; CommandBase::CommandBase(char const *name) : Command(name) { @@ -18,7 +16,6 @@ void CommandBase::init(){ drivetrain = new Drivetrain(); collector = new Collector(); elevator = new Elevator(); - dio = new DIO(); airCompressor = new AirCompressor(); oi = new OI(); } diff --git a/CommandBase.h b/CommandBase.h index 18f90d0..e6891d1 100644 --- a/CommandBase.h +++ b/CommandBase.h @@ -5,7 +5,6 @@ #include "Subsystems/Drivetrain.h" #include "Subsystems/Collector.h" #include "Subsystems/Elevator.h" -#include "Subsystems/DIO.h" #include "Subsystems/AirCompressor.h" #include "OI.h" #include "WPILib.h" @@ -18,7 +17,6 @@ class CommandBase: public Command { static Drivetrain *drivetrain; static Collector *collector; static Elevator *elevator; - static DIO* dio; static AirCompressor *airCompressor; static OI *oi; }; diff --git a/Commands/Elevator/Calibrate.cpp b/Commands/Elevator/Calibrate.cpp index 2132127..55ff8b0 100644 --- a/Commands/Elevator/Calibrate.cpp +++ b/Commands/Elevator/Calibrate.cpp @@ -10,7 +10,7 @@ void Calibrate::Execute(){ DentRobot::elevator->Run(-0.4f); } bool Calibrate::IsFinished(){ - if(DentRobot::dio->Get(DIO::ELEVATORBOTTOM)){ + if(DentRobot::elevator->GetElevatorBottom()){ DentRobot::elevator->ResetEncoder(); DentRobot::elevator->SetOffset(0.99); return true; diff --git a/Commands/Elevator/Lower.cpp b/Commands/Elevator/Lower.cpp index 1e4e658..03cf6eb 100644 --- a/Commands/Elevator/Lower.cpp +++ b/Commands/Elevator/Lower.cpp @@ -10,7 +10,7 @@ void Lower::Execute(){ DentRobot::elevator->Run((-DentRobot::oi->GetLeftStick()->GetRawAxis(3)+1.0)/2); } bool Lower::IsFinished(){ - if (!DentRobot::dio->Get(DentRobot::dio->ELEVATORBOTTOM) || IsTimedOut()){ + if (DentRobot::elevator->GetElevatorBottom()||IsTimedOut()){ return true; }else{ return false; diff --git a/Commands/Elevator/Raise.cpp b/Commands/Elevator/Raise.cpp index 385ec52..1bbccba 100644 --- a/Commands/Elevator/Raise.cpp +++ b/Commands/Elevator/Raise.cpp @@ -10,7 +10,7 @@ void Raise::Execute(){ DentRobot::elevator->Run(-(-DentRobot::oi->GetLeftStick()->GetRawAxis(3)+1.0)/2); } bool Raise::IsFinished(){ - if (!DentRobot::dio->Get(DentRobot::dio->ELEVATORBOTTOM) || IsTimedOut()){ + if (DentRobot::elevator->GetElevatorTop()||IsTimedOut()){ return true; }else{ return false; diff --git a/DentRobot.cpp b/DentRobot.cpp index 26365f7..96b8fd2 100644 --- a/DentRobot.cpp +++ b/DentRobot.cpp @@ -4,7 +4,6 @@ OI* DentRobot::oi=NULL; Collector* DentRobot::collector=NULL; Drivetrain* DentRobot::drivetrain=NULL; Elevator* DentRobot::elevator=NULL; -DIO* DentRobot::dio = NULL; AirCompressor* DentRobot::airCompressor=NULL; CommandGroup* DentRobot::aut=NULL; DentRobot::DentRobot(){ @@ -12,7 +11,6 @@ DentRobot::DentRobot(){ collector=new Collector(); drivetrain=new Drivetrain(); elevator=new Elevator(); - dio = new DIO(); airCompressor=new AirCompressor(); aut=new Autonomous(); printf("Initialized"); diff --git a/DentRobot.h b/DentRobot.h index 1f72a33..9e30708 100644 --- a/DentRobot.h +++ b/DentRobot.h @@ -3,7 +3,6 @@ #include "WPILib.h" #include "OI.h" #include "Subsystems/Elevator.h" -#include "Subsystems/DIO.h" #include "Subsystems/Drivetrain.h" #include "Subsystems/Collector.h" #include "Subsystems/AirCompressor.h" @@ -17,7 +16,6 @@ class DentRobot: public IterativeRobot { static Collector* collector; static Drivetrain* drivetrain; static Elevator* elevator; - static DIO* dio; static AirCompressor* airCompressor; static CommandGroup* aut; void RobotInit(); diff --git a/RobotMap.h b/RobotMap.h index 90b38e1..1bf5363 100644 --- a/RobotMap.h +++ b/RobotMap.h @@ -5,6 +5,8 @@ // Elevator #define ELEVATOR_CAN 1 +#define ELEVATOR_BOTTOM_DIO 0 +#define ELEVATOR_TOP_DIO 1 // Drivetrain #define DRIVE_FRONT_LEFT_CAN 2 @@ -17,7 +19,6 @@ #define COLLECTOR_WINDOW_RIGHT_CAN 7 #define COLLECTOR_LEFT_CAN 8 #define COLLECTOR_RIGHT_CAN 9 -#define COLLECTOR_CALIBRATOR_DIO 0 // Compressor #define COMPRESSOR_CAN 10 diff --git a/Subsystems/Collector.cpp b/Subsystems/Collector.cpp index a1fdee7..e039511 100644 --- a/Subsystems/Collector.cpp +++ b/Subsystems/Collector.cpp @@ -6,7 +6,6 @@ Collector::Collector() : Subsystem("Collector") { windowMotorRight=new CANTalon(COLLECTOR_WINDOW_RIGHT_CAN); collectorMotorLeft=new CANTalon(COLLECTOR_LEFT_CAN); collectorMotorRight=new CANTalon(COLLECTOR_RIGHT_CAN); - boxSwitch=new DigitalInput(COLLECTOR_CALIBRATOR_DIO); } void Collector::InitDefaultCommand() { } diff --git a/Subsystems/Collector.h b/Subsystems/Collector.h index 931744f..cf6b23c 100644 --- a/Subsystems/Collector.h +++ b/Subsystems/Collector.h @@ -6,7 +6,6 @@ class Collector: public Subsystem { private: CANTalon *windowMotorLeft, *windowMotorRight, *collectorMotorLeft, *collectorMotorRight; - DigitalInput *boxSwitch; public: Collector(); void InitDefaultCommand(); diff --git a/Subsystems/DIO.cpp b/Subsystems/DIO.cpp deleted file mode 100644 index 470bf3a..0000000 --- a/Subsystems/DIO.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "DIO.h" -#include "../RobotMap.h" -DIO::DIO(){ - elevatorTop=new DigitalInput(0); - elevatorBottom=new DigitalInput(1); -} -void DIO::InitDefaultCommand(){ -} -bool DIO::Get(e_dioSig dioSig){ - switch (dioSig){ - case ELEVATORTOP: - return elevatorTop->Get(); - break; - case ELEVATORBOTTOM: - return elevatorBottom->Get(); - break; - default: - return false; - break; - } -} diff --git a/Subsystems/DIO.h b/Subsystems/DIO.h deleted file mode 100644 index 8862850..0000000 --- a/Subsystems/DIO.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef DIO_H -#define DIO_H - -#include "WPILib.h" -class DIO{ - private: - DigitalInput *elevatorTop, *elevatorBottom; - public: - DIO(); - enum e_dioSig{ - ELEVATORTOP, - ELEVATORBOTTOM - }; - void InitDefaultCommand(); - bool Get(e_dioSig); -}; -#endif diff --git a/Subsystems/Elevator.cpp b/Subsystems/Elevator.cpp index 2df51dc..1e18c3e 100644 --- a/Subsystems/Elevator.cpp +++ b/Subsystems/Elevator.cpp @@ -5,6 +5,8 @@ Elevator::Elevator()/* : PIDSubsystem("Elevator", kP_real, kI_real, 0.0)*/{ elevatorEncoder=new Encoder(0,1,false); offset=0; height=0; + elevatorBottom=new DigitalInput(ELEVATOR_BOTTOM_DIO); + elevatorTop=new DigitalInput(ELEVATOR_TOP_DIO); //SetAbsoluteTolerance(0.004); } void Elevator::InitDefaultCommand(){ @@ -22,3 +24,9 @@ void Elevator::ResetEncoder(){ double Elevator::GetHeight(){ return elevatorEncoder->Get()+offset; } +bool Elevator::GetElevatorBottom(){ + return elevatorBottom->Get(); +} +bool Elevator::GetElevatorTop(){ + return elevatorTop->Get(); +} diff --git a/Subsystems/Elevator.h b/Subsystems/Elevator.h index 26902d8..072f8e3 100644 --- a/Subsystems/Elevator.h +++ b/Subsystems/Elevator.h @@ -9,6 +9,7 @@ class Elevator/*: public PIDSubsystem*/{ Encoder *elevatorEncoder; static constexpr double kP_real=4, kI_real=.0f, kP_simulation=18, kI_simulation=.2; double offset, height; + DigitalInput *elevatorBottom, *elevatorTop; public: Elevator(); void InitDefaultCommand(); @@ -16,5 +17,7 @@ class Elevator/*: public PIDSubsystem*/{ void SetOffset(double); void ResetEncoder(); double GetHeight(); + bool GetElevatorTop(); + bool GetElevatorBottom(); }; #endif From aed1db3981f776a581bfa93905cd562c00978cdd Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Sat, 7 Feb 2015 13:08:24 -0500 Subject: [PATCH 4/9] Added extra elevator DIOs --- RobotMap.h | 6 +++++- Subsystems/Elevator.cpp | 2 +- Subsystems/Elevator.h | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/RobotMap.h b/RobotMap.h index 1bf5363..da8ce10 100644 --- a/RobotMap.h +++ b/RobotMap.h @@ -6,7 +6,11 @@ // Elevator #define ELEVATOR_CAN 1 #define ELEVATOR_BOTTOM_DIO 0 -#define ELEVATOR_TOP_DIO 1 +#define ELEVATOR_COLELCT_TOTE_DIO 1 +#define ELEVATOR_READY_TOTE_DIO 2 +#define ELEVATOR_COLELCT_CAN_DIO 3 +#define ELEVATOR_READY_CAN_DIO 4 +#define ELEVATOR_TOP_DIO 5 // Drivetrain #define DRIVE_FRONT_LEFT_CAN 2 diff --git a/Subsystems/Elevator.cpp b/Subsystems/Elevator.cpp index 1e18c3e..1616321 100644 --- a/Subsystems/Elevator.cpp +++ b/Subsystems/Elevator.cpp @@ -1,6 +1,6 @@ #include "Elevator.h" #include "../RobotMap.h" -Elevator::Elevator()/* : PIDSubsystem("Elevator", kP_real, kI_real, 0.0)*/{ +Elevator::Elevator(){ motor=new CANTalon(ELEVATOR_CAN); elevatorEncoder=new Encoder(0,1,false); offset=0; diff --git a/Subsystems/Elevator.h b/Subsystems/Elevator.h index 072f8e3..1d8a771 100644 --- a/Subsystems/Elevator.h +++ b/Subsystems/Elevator.h @@ -3,7 +3,7 @@ #include "WPILib.h" #include "Commands/PIDSubsystem.h" -class Elevator/*: public PIDSubsystem*/{ +class Elevator{ private: CANTalon *motor; Encoder *elevatorEncoder; From 1f6f1cf239a8713e48ac81bab3e6c45001b410cf Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Sat, 7 Feb 2015 13:17:22 -0500 Subject: [PATCH 5/9] Removed compressor --- CommandBase.cpp | 3 --- CommandBase.h | 2 -- Commands/Autonomous/Autonomous.cpp | 1 + Commands/Compressor/StartCompressing.cpp | 18 ------------------ Commands/Compressor/StartCompressing.h | 18 ------------------ Commands/Compressor/StopCompressing.cpp | 18 ------------------ Commands/Compressor/StopCompressing.h | 18 ------------------ DentRobot.cpp | 2 -- DentRobot.h | 2 -- OI.cpp | 1 - RobotMap.h | 3 --- Subsystems/AirCompressor.cpp | 20 -------------------- Subsystems/AirCompressor.h | 15 --------------- TODO.txt | 2 -- 14 files changed, 1 insertion(+), 122 deletions(-) delete mode 100644 Commands/Compressor/StartCompressing.cpp delete mode 100644 Commands/Compressor/StartCompressing.h delete mode 100644 Commands/Compressor/StopCompressing.cpp delete mode 100644 Commands/Compressor/StopCompressing.h delete mode 100644 Subsystems/AirCompressor.cpp delete mode 100644 Subsystems/AirCompressor.h diff --git a/CommandBase.cpp b/CommandBase.cpp index dfd3a78..c09ffd6 100644 --- a/CommandBase.cpp +++ b/CommandBase.cpp @@ -2,11 +2,9 @@ #include "Subsystems/Drivetrain.h" #include "Subsystems/Collector.h" #include "Subsystems/Elevator.h" -#include "Subsystems/AirCompressor.h" Drivetrain* CommandBase::drivetrain = NULL; Collector* CommandBase::collector = NULL; Elevator* CommandBase::elevator = NULL; -AirCompressor* CommandBase::airCompressor = NULL; OI* CommandBase::oi = NULL; CommandBase::CommandBase(char const *name) : Command(name) { } @@ -16,6 +14,5 @@ void CommandBase::init(){ drivetrain = new Drivetrain(); collector = new Collector(); elevator = new Elevator(); - airCompressor = new AirCompressor(); oi = new OI(); } diff --git a/CommandBase.h b/CommandBase.h index e6891d1..a0e5d05 100644 --- a/CommandBase.h +++ b/CommandBase.h @@ -5,7 +5,6 @@ #include "Subsystems/Drivetrain.h" #include "Subsystems/Collector.h" #include "Subsystems/Elevator.h" -#include "Subsystems/AirCompressor.h" #include "OI.h" #include "WPILib.h" @@ -17,7 +16,6 @@ class CommandBase: public Command { static Drivetrain *drivetrain; static Collector *collector; static Elevator *elevator; - static AirCompressor *airCompressor; static OI *oi; }; #endif diff --git a/Commands/Autonomous/Autonomous.cpp b/Commands/Autonomous/Autonomous.cpp index 12be62e..a57859a 100644 --- a/Commands/Autonomous/Autonomous.cpp +++ b/Commands/Autonomous/Autonomous.cpp @@ -4,4 +4,5 @@ #include "../Elevator/Raise.h" Autonomous::Autonomous(){ AddSequential(new AutoDrive()); + AddSequential(new Raise()); } diff --git a/Commands/Compressor/StartCompressing.cpp b/Commands/Compressor/StartCompressing.cpp deleted file mode 100644 index 50425b5..0000000 --- a/Commands/Compressor/StartCompressing.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "StartCompressing.h" -#include "../../DentRobot.h" -StartCompressing::StartCompressing() : Command("StartCompressing"){ - Requires(DentRobot::airCompressor); -} -void StartCompressing::Initialize(){ -} -void StartCompressing::Execute(){ - DentRobot::airCompressor->StartCompressing(); -} -bool StartCompressing::IsFinished(){ - return false; -} -void StartCompressing::End(){ -} -void StartCompressing::Interrupted(){ - End(); -} diff --git a/Commands/Compressor/StartCompressing.h b/Commands/Compressor/StartCompressing.h deleted file mode 100644 index a681bd0..0000000 --- a/Commands/Compressor/StartCompressing.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef STARTCOMPRESSING_H -#define STARTCOMPRESSING_H - -#include "../../CommandBase.h" -#include "../../DentRobot.h" -#include "Commands/Command.h" -#include "WPILib.h" - -class StartCompressing: public Command{ - public: - StartCompressing(); - void Initialize(); - void Execute(); - bool IsFinished(); - void End(); - void Interrupted(); -}; -#endif diff --git a/Commands/Compressor/StopCompressing.cpp b/Commands/Compressor/StopCompressing.cpp deleted file mode 100644 index 4ef05fb..0000000 --- a/Commands/Compressor/StopCompressing.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "StopCompressing.h" -#include "../../DentRobot.h" -StopCompressing::StopCompressing() : Command("StopCompressing"){ - Requires(DentRobot::airCompressor); -} -void StopCompressing::Initialize(){ -} -void StopCompressing::Execute(){ - DentRobot::airCompressor->StopCompressing(); -} -bool StopCompressing::IsFinished(){ - return false; -} -void StopCompressing::End(){ -} -void StopCompressing::Interrupted(){ - End(); -} diff --git a/Commands/Compressor/StopCompressing.h b/Commands/Compressor/StopCompressing.h deleted file mode 100644 index c723098..0000000 --- a/Commands/Compressor/StopCompressing.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef STOPCOMPRESSING_H -#define STOPCOMPRESSING_H - -#include "../../CommandBase.h" -#include "../../DentRobot.h" -#include "Commands/Command.h" -#include "WPILib.h" - -class StopCompressing: public Command{ - public: - StopCompressing(); - void Initialize(); - void Execute(); - bool IsFinished(); - void End(); - void Interrupted(); -}; -#endif diff --git a/DentRobot.cpp b/DentRobot.cpp index 96b8fd2..14cf442 100644 --- a/DentRobot.cpp +++ b/DentRobot.cpp @@ -4,14 +4,12 @@ OI* DentRobot::oi=NULL; Collector* DentRobot::collector=NULL; Drivetrain* DentRobot::drivetrain=NULL; Elevator* DentRobot::elevator=NULL; -AirCompressor* DentRobot::airCompressor=NULL; CommandGroup* DentRobot::aut=NULL; DentRobot::DentRobot(){ oi=new OI(); collector=new Collector(); drivetrain=new Drivetrain(); elevator=new Elevator(); - airCompressor=new AirCompressor(); aut=new Autonomous(); printf("Initialized"); } diff --git a/DentRobot.h b/DentRobot.h index 9e30708..e089405 100644 --- a/DentRobot.h +++ b/DentRobot.h @@ -5,7 +5,6 @@ #include "Subsystems/Elevator.h" #include "Subsystems/Drivetrain.h" #include "Subsystems/Collector.h" -#include "Subsystems/AirCompressor.h" #include "Commands/Autonomous/Autonomous.h" class DentRobot: public IterativeRobot { private: @@ -16,7 +15,6 @@ class DentRobot: public IterativeRobot { static Collector* collector; static Drivetrain* drivetrain; static Elevator* elevator; - static AirCompressor* airCompressor; static CommandGroup* aut; void RobotInit(); void DisabledPeriodic(); diff --git a/OI.cpp b/OI.cpp index 47a0a66..e5576c9 100644 --- a/OI.cpp +++ b/OI.cpp @@ -5,7 +5,6 @@ #include "Commands/Collector/CloseCollector.h" #include "Commands/Collector/CollectTote.h" #include "Commands/Collector/ReleaseTote.h" -#include "Commands/Compressor/StartCompressing.h" OI::OI() { leftStick=new Joystick(0); diff --git a/RobotMap.h b/RobotMap.h index da8ce10..eb0a2c7 100644 --- a/RobotMap.h +++ b/RobotMap.h @@ -24,7 +24,4 @@ #define COLLECTOR_LEFT_CAN 8 #define COLLECTOR_RIGHT_CAN 9 -// Compressor -#define COMPRESSOR_CAN 10 - #endif diff --git a/Subsystems/AirCompressor.cpp b/Subsystems/AirCompressor.cpp deleted file mode 100644 index b63ff8b..0000000 --- a/Subsystems/AirCompressor.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "AirCompressor.h" -#include "../RobotMap.h" - -AirCompressor::AirCompressor() : Subsystem("AirCompressor") { - compressor = new Compressor(COMPRESSOR_CAN); -} -void AirCompressor::InitDefaultCommand() { -} -void AirCompressor::StartCompressing() { - if(compressor->Enabled()){ - printf("Starting compressor\n"); - compressor->Start(); - } -} -void AirCompressor::StopCompressing() { - if(compressor->Enabled()){ - printf("Stopping compressor\n"); - compressor->Stop(); - } -} diff --git a/Subsystems/AirCompressor.h b/Subsystems/AirCompressor.h deleted file mode 100644 index df9ec00..0000000 --- a/Subsystems/AirCompressor.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef AIRCOMPRESSOR_H -#define AIRCOMPRESSOR_H - -#include "WPILib.h" -class AirCompressor: public Subsystem -{ - private: - Compressor *compressor; - public: - AirCompressor(); - void InitDefaultCommand(); - void StartCompressing(); - void StopCompressing(); -}; -#endif diff --git a/TODO.txt b/TODO.txt index 0f710ce..e69de29 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,2 +0,0 @@ -Compressor isn't in use - (dos compressor on compressor start or stop)? From a82607256ee2bbced7674c1d0eb694c748a5fa36 Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Sat, 7 Feb 2015 13:28:08 -0500 Subject: [PATCH 6/9] Added vim modelines --- CommandBase.cpp | 1 + CommandBase.h | 1 + Commands/Autonomous/AutoDrive.cpp | 1 + Commands/Autonomous/AutoDrive.h | 1 + Commands/Autonomous/Autonomous.cpp | 1 + Commands/Autonomous/Autonomous.h | 1 + Commands/Collector/CloseCollector.cpp | 1 + Commands/Collector/CloseCollector.h | 1 + Commands/Collector/CollectTote.cpp | 1 + Commands/Collector/CollectTote.h | 1 + Commands/Collector/OpenCollector.cpp | 1 + Commands/Collector/OpenCollector.h | 1 + Commands/Collector/ReleaseTote.cpp | 1 + Commands/Collector/ReleaseTote.h | 1 + Commands/Drivetrain/Drive.cpp | 1 + Commands/Drivetrain/Drive.h | 1 + Commands/Elevator/Calibrate.cpp | 1 + Commands/Elevator/Calibrate.h | 1 + Commands/Elevator/Lower.cpp | 1 + Commands/Elevator/Lower.h | 1 + Commands/Elevator/Raise.cpp | 1 + Commands/Elevator/Raise.h | 1 + DentRobot.cpp | 3 ++- OI.cpp | 1 + OI.h | 1 + RobotMap.h | 1 + Subsystems/Collector.cpp | 1 + Subsystems/Collector.h | 1 + Subsystems/Drivetrain.cpp | 1 + Subsystems/Drivetrain.h | 1 + Subsystems/Elevator.cpp | 1 + Subsystems/Elevator.h | 1 + 32 files changed, 33 insertions(+), 1 deletion(-) diff --git a/CommandBase.cpp b/CommandBase.cpp index c09ffd6..90e3d27 100644 --- a/CommandBase.cpp +++ b/CommandBase.cpp @@ -16,3 +16,4 @@ void CommandBase::init(){ elevator = new Elevator(); oi = new OI(); } +// vim: ts2:sw=2:et diff --git a/CommandBase.h b/CommandBase.h index a0e5d05..c1cb716 100644 --- a/CommandBase.h +++ b/CommandBase.h @@ -19,3 +19,4 @@ class CommandBase: public Command { static OI *oi; }; #endif +// vim: ts2:sw=2:et diff --git a/Commands/Autonomous/AutoDrive.cpp b/Commands/Autonomous/AutoDrive.cpp index 0eb43d6..511039f 100644 --- a/Commands/Autonomous/AutoDrive.cpp +++ b/Commands/Autonomous/AutoDrive.cpp @@ -20,3 +20,4 @@ void AutoDrive::End(){ void AutoDrive::Interrupted(){ End(); } +// vim: ts2:sw=2:et diff --git a/Commands/Autonomous/AutoDrive.h b/Commands/Autonomous/AutoDrive.h index f7538b2..eaab4a2 100644 --- a/Commands/Autonomous/AutoDrive.h +++ b/Commands/Autonomous/AutoDrive.h @@ -16,3 +16,4 @@ class AutoDrive: public Command{ void Interrupted(); }; #endif +// vim: ts2:sw=2:et diff --git a/Commands/Autonomous/Autonomous.cpp b/Commands/Autonomous/Autonomous.cpp index a57859a..93aced5 100644 --- a/Commands/Autonomous/Autonomous.cpp +++ b/Commands/Autonomous/Autonomous.cpp @@ -6,3 +6,4 @@ Autonomous::Autonomous(){ AddSequential(new AutoDrive()); AddSequential(new Raise()); } +// vim: ts2:sw=2:et diff --git a/Commands/Autonomous/Autonomous.h b/Commands/Autonomous/Autonomous.h index 52161e0..88cf308 100644 --- a/Commands/Autonomous/Autonomous.h +++ b/Commands/Autonomous/Autonomous.h @@ -11,3 +11,4 @@ class Autonomous: public CommandGroup{ Autonomous(); }; #endif +// vim: ts2:sw=2:et diff --git a/Commands/Collector/CloseCollector.cpp b/Commands/Collector/CloseCollector.cpp index ffebfb3..3b7a866 100644 --- a/Commands/Collector/CloseCollector.cpp +++ b/Commands/Collector/CloseCollector.cpp @@ -17,3 +17,4 @@ void CloseCollector::End(){ void CloseCollector::Interrupted(){ End(); } +// vim: ts2:sw=2:et diff --git a/Commands/Collector/CloseCollector.h b/Commands/Collector/CloseCollector.h index 3042699..6be493a 100644 --- a/Commands/Collector/CloseCollector.h +++ b/Commands/Collector/CloseCollector.h @@ -17,3 +17,4 @@ class CloseCollector: public Command{ }; #endif +// vim: ts2:sw=2:et diff --git a/Commands/Collector/CollectTote.cpp b/Commands/Collector/CollectTote.cpp index e7fad0f..cbd5923 100644 --- a/Commands/Collector/CollectTote.cpp +++ b/Commands/Collector/CollectTote.cpp @@ -19,3 +19,4 @@ void CollectTote::End(){ void CollectTote::Interrupted(){ End(); } +// vim: ts2:sw=2:et diff --git a/Commands/Collector/CollectTote.h b/Commands/Collector/CollectTote.h index c06fac3..de2d7db 100644 --- a/Commands/Collector/CollectTote.h +++ b/Commands/Collector/CollectTote.h @@ -17,3 +17,4 @@ class CollectTote: public Command{ }; #endif +// vim: ts2:sw=2:et diff --git a/Commands/Collector/OpenCollector.cpp b/Commands/Collector/OpenCollector.cpp index 27e94ed..1ec498e 100644 --- a/Commands/Collector/OpenCollector.cpp +++ b/Commands/Collector/OpenCollector.cpp @@ -18,3 +18,4 @@ void OpenCollector::End(){ void OpenCollector::Interrupted(){ End(); } +// vim: ts2:sw=2:et diff --git a/Commands/Collector/OpenCollector.h b/Commands/Collector/OpenCollector.h index c75b20b..47ae5f5 100644 --- a/Commands/Collector/OpenCollector.h +++ b/Commands/Collector/OpenCollector.h @@ -17,3 +17,4 @@ class OpenCollector: public Command{ }; #endif +// vim: ts2:sw=2:et diff --git a/Commands/Collector/ReleaseTote.cpp b/Commands/Collector/ReleaseTote.cpp index 0ee9ce1..222cfe7 100644 --- a/Commands/Collector/ReleaseTote.cpp +++ b/Commands/Collector/ReleaseTote.cpp @@ -20,3 +20,4 @@ void ReleaseTote::End(){ void ReleaseTote::Interrupted(){ End(); } +// vim: ts2:sw=2:et diff --git a/Commands/Collector/ReleaseTote.h b/Commands/Collector/ReleaseTote.h index deacad9..521b7da 100644 --- a/Commands/Collector/ReleaseTote.h +++ b/Commands/Collector/ReleaseTote.h @@ -17,3 +17,4 @@ class ReleaseTote: public Command{ }; #endif +// vim: ts2:sw=2:et diff --git a/Commands/Drivetrain/Drive.cpp b/Commands/Drivetrain/Drive.cpp index 6d39788..b6bb601 100644 --- a/Commands/Drivetrain/Drive.cpp +++ b/Commands/Drivetrain/Drive.cpp @@ -33,3 +33,4 @@ void Drive::End(){ void Drive::Interrupted(){ End(); } +// vim: ts2:sw=2:et diff --git a/Commands/Drivetrain/Drive.h b/Commands/Drivetrain/Drive.h index 4ecc4eb..17583fa 100644 --- a/Commands/Drivetrain/Drive.h +++ b/Commands/Drivetrain/Drive.h @@ -16,3 +16,4 @@ class Drive: public Command{ void Interrupted(); }; #endif +// vim: ts2:sw=2:et diff --git a/Commands/Elevator/Calibrate.cpp b/Commands/Elevator/Calibrate.cpp index 55ff8b0..87f2c25 100644 --- a/Commands/Elevator/Calibrate.cpp +++ b/Commands/Elevator/Calibrate.cpp @@ -23,3 +23,4 @@ void Calibrate::End(){ void Calibrate::Interrupted(){ End(); } +// vim: ts2:sw=2:et diff --git a/Commands/Elevator/Calibrate.h b/Commands/Elevator/Calibrate.h index 72fdbed..5d70334 100644 --- a/Commands/Elevator/Calibrate.h +++ b/Commands/Elevator/Calibrate.h @@ -14,3 +14,4 @@ class Calibrate: public Command{ void Interrupted(); }; #endif +// vim: ts2:sw=2:et diff --git a/Commands/Elevator/Lower.cpp b/Commands/Elevator/Lower.cpp index 03cf6eb..ca38e6a 100644 --- a/Commands/Elevator/Lower.cpp +++ b/Commands/Elevator/Lower.cpp @@ -22,3 +22,4 @@ void Lower::End(){ void Lower::Interrupted(){ End(); } +// vim: ts2:sw=2:et diff --git a/Commands/Elevator/Lower.h b/Commands/Elevator/Lower.h index 1f39059..3a83b57 100644 --- a/Commands/Elevator/Lower.h +++ b/Commands/Elevator/Lower.h @@ -14,3 +14,4 @@ class Lower: public Command{ void Interrupted(); }; #endif +// vim: ts2:sw=2:et diff --git a/Commands/Elevator/Raise.cpp b/Commands/Elevator/Raise.cpp index 1bbccba..ab41f45 100644 --- a/Commands/Elevator/Raise.cpp +++ b/Commands/Elevator/Raise.cpp @@ -22,3 +22,4 @@ void Raise::End(){ void Raise::Interrupted(){ End(); } +// vim: ts2:sw=2:et diff --git a/Commands/Elevator/Raise.h b/Commands/Elevator/Raise.h index 8960dd8..abc519b 100644 --- a/Commands/Elevator/Raise.h +++ b/Commands/Elevator/Raise.h @@ -15,3 +15,4 @@ class Raise: public Command{ }; #endif +// vim: ts2:sw=2:et diff --git a/DentRobot.cpp b/DentRobot.cpp index 14cf442..77c6a8f 100644 --- a/DentRobot.cpp +++ b/DentRobot.cpp @@ -14,7 +14,7 @@ DentRobot::DentRobot(){ printf("Initialized"); } void DentRobot::RobotInit(){ - SmartDashboard::PutNumber("CodeVersion",0.001); + SmartDashboard::PutNumber("CodeVersion",0.001); } void DentRobot::DisabledPeriodic(){ Scheduler::GetInstance()->Run(); @@ -38,3 +38,4 @@ void DentRobot::TeleopPeriodic(){ void DentRobot::TestPeriodic(){ } START_ROBOT_CLASS(DentRobot); +// vim: ts2:sw=2:et diff --git a/OI.cpp b/OI.cpp index e5576c9..876143d 100644 --- a/OI.cpp +++ b/OI.cpp @@ -29,3 +29,4 @@ Joystick* OI::GetRightStick(){ Joystick* OI::GetLeftStick(){ return leftStick; } +// vim: ts2:sw=2:et diff --git a/OI.h b/OI.h index e89ec0a..6bdbe19 100644 --- a/OI.h +++ b/OI.h @@ -13,3 +13,4 @@ class OI Joystick* GetLeftStick(); }; #endif +// vim: ts2:sw=2:et diff --git a/RobotMap.h b/RobotMap.h index eb0a2c7..3e866a5 100644 --- a/RobotMap.h +++ b/RobotMap.h @@ -25,3 +25,4 @@ #define COLLECTOR_RIGHT_CAN 9 #endif +// vim: ts2:sw=2:et diff --git a/Subsystems/Collector.cpp b/Subsystems/Collector.cpp index e039511..fbcca5d 100644 --- a/Subsystems/Collector.cpp +++ b/Subsystems/Collector.cpp @@ -26,3 +26,4 @@ bool Collector::BoxCollected(){ return false; //return boxSwitch->Get(); } +// vim: ts2:sw=2:et diff --git a/Subsystems/Collector.h b/Subsystems/Collector.h index cf6b23c..24dcc1d 100644 --- a/Subsystems/Collector.h +++ b/Subsystems/Collector.h @@ -15,3 +15,4 @@ class Collector: public Subsystem bool BoxCollected(); }; #endif +// vim: ts2:sw=2:et diff --git a/Subsystems/Drivetrain.cpp b/Subsystems/Drivetrain.cpp index 80df4e7..7db8487 100644 --- a/Subsystems/Drivetrain.cpp +++ b/Subsystems/Drivetrain.cpp @@ -20,3 +20,4 @@ void Drivetrain::DriveMecanum(float x, float y, float z, float sensitivity, floa rightRear->Set((correctX + correctY - correctZ)); leftRear->Set((-correctX + correctY + correctZ)*-1); } +// vim: ts2:sw=2:et diff --git a/Subsystems/Drivetrain.h b/Subsystems/Drivetrain.h index 81a5168..b4114b4 100644 --- a/Subsystems/Drivetrain.h +++ b/Subsystems/Drivetrain.h @@ -13,3 +13,4 @@ class Drivetrain: public Subsystem{ void DriveArcade(float, float); }; #endif +// vim: ts2:sw=2:et diff --git a/Subsystems/Elevator.cpp b/Subsystems/Elevator.cpp index 1616321..281fb5e 100644 --- a/Subsystems/Elevator.cpp +++ b/Subsystems/Elevator.cpp @@ -30,3 +30,4 @@ bool Elevator::GetElevatorBottom(){ bool Elevator::GetElevatorTop(){ return elevatorTop->Get(); } +// vim: ts2:sw=2:et diff --git a/Subsystems/Elevator.h b/Subsystems/Elevator.h index 1d8a771..44c57de 100644 --- a/Subsystems/Elevator.h +++ b/Subsystems/Elevator.h @@ -21,3 +21,4 @@ class Elevator{ bool GetElevatorBottom(); }; #endif +// vim: ts2:sw=2:et From f8da6b1d2293fdb1f7cf128833c85be31517579c Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Sat, 7 Feb 2015 14:41:30 -0500 Subject: [PATCH 7/9] Used rightStick to control buttons --- OI.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/OI.cpp b/OI.cpp index 876143d..838c7a9 100644 --- a/OI.cpp +++ b/OI.cpp @@ -10,18 +10,18 @@ OI::OI() { leftStick=new Joystick(0); rightStick=new Joystick(1); //TODO name these buttons to their functions rather to their number - JoystickButton *left1=new JoystickButton(leftStick, 1); - JoystickButton *left2=new JoystickButton(leftStick, 2); - JoystickButton *left3=new JoystickButton(leftStick, 3); - JoystickButton *left4=new JoystickButton(leftStick, 4); - JoystickButton *left5=new JoystickButton(leftStick, 5); - JoystickButton *left6=new JoystickButton(leftStick, 6); - left1->WhileHeld(new OpenCollector()); - left2->WhileHeld(new CloseCollector()); - left3->WhileHeld(new CollectTote()); - left4->WhileHeld(new ReleaseTote()); - left5->WhenPressed(new Raise()); - left6->WhenPressed(new Lower()); + JoystickButton *right1=new JoystickButton(rightStick, 1); + JoystickButton *right2=new JoystickButton(rightStick, 2); + JoystickButton *right3=new JoystickButton(rightStick, 3); + JoystickButton *right4=new JoystickButton(rightStick, 4); + JoystickButton *right5=new JoystickButton(rightStick, 5); + JoystickButton *right6=new JoystickButton(rightStick, 6); + right1->WhileHeld(new OpenCollector()); + right2->WhileHeld(new CloseCollector()); + right3->WhileHeld(new CollectTote()); + right4->WhileHeld(new ReleaseTote()); + right5->WhenPressed(new Raise()); + right6->WhenPressed(new Lower()); } Joystick* OI::GetRightStick(){ return rightStick; From 4c6e75969e9145e03343ba48f01554b8cc319a9c Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Sat, 7 Feb 2015 17:04:16 -0500 Subject: [PATCH 8/9] Robot fully works --- .env | 2 +- Commands/Autonomous/AutoDrive.cpp | 2 +- Commands/Drivetrain/Drive.cpp | 4 ---- Commands/Elevator/Lower.cpp | 7 ++++--- Commands/Elevator/Raise.cpp | 7 ++++--- OI.cpp | 19 +++++++++++++------ 6 files changed, 23 insertions(+), 18 deletions(-) diff --git a/.env b/.env index 7bcd405..fe3ac67 100644 --- a/.env +++ b/.env @@ -7,7 +7,7 @@ function mc(){ function mk(){ vagrant ssh -c "cd /vagrant/src;make" } -function md(){ +function me(){ vagrant ssh -c "cd /vagrant/src;make deploy" } function ma(){ diff --git a/Commands/Autonomous/AutoDrive.cpp b/Commands/Autonomous/AutoDrive.cpp index 511039f..e7f85fc 100644 --- a/Commands/Autonomous/AutoDrive.cpp +++ b/Commands/Autonomous/AutoDrive.cpp @@ -13,7 +13,7 @@ void AutoDrive::Execute(){ DentRobot::drivetrain->DriveMecanum(0.5,0,0,0.9,0); } bool AutoDrive::IsFinished(){ - return false; + return IsTimedOut(); } void AutoDrive::End(){ } diff --git a/Commands/Drivetrain/Drive.cpp b/Commands/Drivetrain/Drive.cpp index b6bb601..dfa803b 100644 --- a/Commands/Drivetrain/Drive.cpp +++ b/Commands/Drivetrain/Drive.cpp @@ -18,10 +18,6 @@ void Drive::Execute(){ if (DentRobot::oi->GetLeftStick()->GetRawButton(2)){ y=0; } - if (DentRobot::oi->GetLeftStick()->GetRawAxis(3)<=0.5){ - y /= 2; - z /= 2; - } //X axis, Y axis, Z axis, sensitivity, speed threshold (usually throttle), gyro DentRobot::drivetrain->DriveMecanum(x,y,z,0.9,0); } diff --git a/Commands/Elevator/Lower.cpp b/Commands/Elevator/Lower.cpp index ca38e6a..35d2159 100644 --- a/Commands/Elevator/Lower.cpp +++ b/Commands/Elevator/Lower.cpp @@ -4,13 +4,14 @@ Lower::Lower() : Command("Lower"){ } void Lower::Initialize(){ - SetTimeout(2.0); + SetTimeout(1.0); } void Lower::Execute(){ - DentRobot::elevator->Run((-DentRobot::oi->GetLeftStick()->GetRawAxis(3)+1.0)/2); + DentRobot::elevator->Run(-1.0); } bool Lower::IsFinished(){ - if (DentRobot::elevator->GetElevatorBottom()||IsTimedOut()){ + if (!DentRobot::elevator->GetElevatorBottom()||IsTimedOut()){ + printf("Robot stoped lowering. Sensor based? %d\n", !DentRobot::elevator->GetElevatorBottom()); return true; }else{ return false; diff --git a/Commands/Elevator/Raise.cpp b/Commands/Elevator/Raise.cpp index ab41f45..050b571 100644 --- a/Commands/Elevator/Raise.cpp +++ b/Commands/Elevator/Raise.cpp @@ -4,13 +4,14 @@ Raise::Raise() : Command("Raise"){ } void Raise::Initialize(){ - SetTimeout(2.0); + SetTimeout(2.5); } void Raise::Execute(){ - DentRobot::elevator->Run(-(-DentRobot::oi->GetLeftStick()->GetRawAxis(3)+1.0)/2); + DentRobot::elevator->Run(1.0); } bool Raise::IsFinished(){ - if (DentRobot::elevator->GetElevatorTop()||IsTimedOut()){ + if (!DentRobot::elevator->GetElevatorTop()||IsTimedOut()){ + printf("Robot stoped raising. Sensor based? %d\n", !DentRobot::elevator->GetElevatorTop()); return true; }else{ return false; diff --git a/OI.cpp b/OI.cpp index 838c7a9..f3a6d28 100644 --- a/OI.cpp +++ b/OI.cpp @@ -7,21 +7,28 @@ #include "Commands/Collector/ReleaseTote.h" OI::OI() { + // Joysticks leftStick=new Joystick(0); rightStick=new Joystick(1); - //TODO name these buttons to their functions rather to their number + + // Collector JoystickButton *right1=new JoystickButton(rightStick, 1); JoystickButton *right2=new JoystickButton(rightStick, 2); + JoystickButton *left3=new JoystickButton(leftStick, 3); + JoystickButton *left4=new JoystickButton(leftStick, 4); + right1->WhileHeld(new OpenCollector()); + right2->WhileHeld(new CloseCollector()); + left3->WhileHeld(new CollectTote()); + left4->WhileHeld(new ReleaseTote()); + // Elevator JoystickButton *right3=new JoystickButton(rightStick, 3); JoystickButton *right4=new JoystickButton(rightStick, 4); JoystickButton *right5=new JoystickButton(rightStick, 5); JoystickButton *right6=new JoystickButton(rightStick, 6); - right1->WhileHeld(new OpenCollector()); - right2->WhileHeld(new CloseCollector()); - right3->WhileHeld(new CollectTote()); - right4->WhileHeld(new ReleaseTote()); + right3->WhenPressed(new Lower()); + right4->WhenPressed(new Lower()); right5->WhenPressed(new Raise()); - right6->WhenPressed(new Lower()); + right6->WhenPressed(new Raise()); } Joystick* OI::GetRightStick(){ return rightStick; From 1ebb5661b04ffff9a9b82deb00439bec0b5c55af Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Sat, 7 Feb 2015 17:34:44 -0500 Subject: [PATCH 9/9] Stop elevator with button 12 and when inverse button is pressed --- Commands/Collector/CollectTote.cpp | 1 - Commands/Collector/ReleaseTote.cpp | 1 - OI.cpp | 19 ++++++++++++++----- Subsystems/Collector.cpp | 1 - Subsystems/Elevator.cpp | 1 - 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/Commands/Collector/CollectTote.cpp b/Commands/Collector/CollectTote.cpp index cbd5923..eca5210 100644 --- a/Commands/Collector/CollectTote.cpp +++ b/Commands/Collector/CollectTote.cpp @@ -7,7 +7,6 @@ void CollectTote::Initialize(){ } void CollectTote::Execute(){ //TODO check this value to move the motors in the right direction - printf("collecting tote\n"); DentRobot::collector->MoveRollers(-(-DentRobot::oi->GetLeftStick()->GetRawAxis(3)+1.0)/2); } bool CollectTote::IsFinished(){ diff --git a/Commands/Collector/ReleaseTote.cpp b/Commands/Collector/ReleaseTote.cpp index 222cfe7..e751c35 100644 --- a/Commands/Collector/ReleaseTote.cpp +++ b/Commands/Collector/ReleaseTote.cpp @@ -7,7 +7,6 @@ void ReleaseTote::Initialize(){ } void ReleaseTote::Execute(){ //TODO check this value to move the motors in the right direction - printf("releasing tote\n"); // Devide by 2 twice because this speed should be half the collector speed DentRobot::collector->MoveRollers((-DentRobot::oi->GetLeftStick()->GetRawAxis(3)+1.0)/2/2); } diff --git a/OI.cpp b/OI.cpp index f3a6d28..1a81fab 100644 --- a/OI.cpp +++ b/OI.cpp @@ -10,7 +10,6 @@ OI::OI() { // Joysticks leftStick=new Joystick(0); rightStick=new Joystick(1); - // Collector JoystickButton *right1=new JoystickButton(rightStick, 1); JoystickButton *right2=new JoystickButton(rightStick, 2); @@ -21,14 +20,24 @@ OI::OI() { left3->WhileHeld(new CollectTote()); left4->WhileHeld(new ReleaseTote()); // Elevator + Raise* raise=new Raise(); + Lower* lower=new Lower(); JoystickButton *right3=new JoystickButton(rightStick, 3); JoystickButton *right4=new JoystickButton(rightStick, 4); JoystickButton *right5=new JoystickButton(rightStick, 5); JoystickButton *right6=new JoystickButton(rightStick, 6); - right3->WhenPressed(new Lower()); - right4->WhenPressed(new Lower()); - right5->WhenPressed(new Raise()); - right6->WhenPressed(new Raise()); + right3->WhenPressed(lower); + right4->WhenPressed(lower); + right3->CancelWhenPressed(raise); + right4->CancelWhenPressed(raise); + right5->WhenPressed(raise); + right6->WhenPressed(raise); + right5->CancelWhenPressed(lower); + right6->CancelWhenPressed(lower); + // Cancel + JoystickButton *right12=new JoystickButton(rightStick, 12); + right12->CancelWhenPressed(raise); + right12->CancelWhenPressed(lower); } Joystick* OI::GetRightStick(){ return rightStick; diff --git a/Subsystems/Collector.cpp b/Subsystems/Collector.cpp index fbcca5d..365809b 100644 --- a/Subsystems/Collector.cpp +++ b/Subsystems/Collector.cpp @@ -14,7 +14,6 @@ void Collector::MoveArms(double a){ windowMotorRight->Set(-a); } void Collector::MoveRollers(double a){ - printf("Collector: %f\n", a); collectorMotorLeft->Set(a); collectorMotorRight->Set(-a); } diff --git a/Subsystems/Elevator.cpp b/Subsystems/Elevator.cpp index 281fb5e..f0ff41e 100644 --- a/Subsystems/Elevator.cpp +++ b/Subsystems/Elevator.cpp @@ -12,7 +12,6 @@ Elevator::Elevator(){ void Elevator::InitDefaultCommand(){ } void Elevator::Run(double power){ - printf("Elevator Power: %f\n",power); motor->Set(power); } void Elevator::SetOffset(double ht){