From d515a11cd68d5e1ca689680ecf68e526434b327e Mon Sep 17 00:00:00 2001 From: Adam Long Date: Fri, 20 Feb 2015 20:54:41 +0000 Subject: [PATCH] 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); };