From 79b635d5542d4094747082eb4ed5dd6eb57a2b93 Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Fri, 13 Feb 2015 21:41:38 -0500 Subject: [PATCH] Added BinElevator commands --- Commands/Autonomous/AutoDrive.cpp | 12 +++++++++++- Commands/Autonomous/AutoDrive.h | 3 +++ Commands/Collector/CollectTote.cpp | 11 +++++++++++ Commands/Collector/CollectTote.h | 14 ++++++++++++++ Commands/Collector/ReleaseTote.cpp | 11 +++++++++++ Commands/Collector/ReleaseTote.h | 14 ++++++++++++++ OI.cpp | 13 +++++++++++++ OI.h | 2 +- RobotMap.h | 8 ++++---- 9 files changed, 82 insertions(+), 6 deletions(-) create mode 100644 Commands/Collector/CollectTote.cpp create mode 100644 Commands/Collector/CollectTote.h create mode 100644 Commands/Collector/ReleaseTote.cpp create mode 100644 Commands/Collector/ReleaseTote.h diff --git a/Commands/Autonomous/AutoDrive.cpp b/Commands/Autonomous/AutoDrive.cpp index df147d7..f279f03 100644 --- a/Commands/Autonomous/AutoDrive.cpp +++ b/Commands/Autonomous/AutoDrive.cpp @@ -4,12 +4,22 @@ AutoDrive::AutoDrive(double wait) : Command("AutoDrive"){ Requires(DentRobot::drivetrain); SetTimeout(wait); + power=NULL; +} +AutoDrive::AutoDrive(double wait, double p) : Command("AutoDrive"){ + Requires(DentRobot::drivetrain); + SetTimeout(wait); + *power=p; } void AutoDrive::Initialize(){ } void AutoDrive::Execute(){ //X axis, Y axis, Z axis, sensitivity, speed threshold (usually throttle), gyro - DentRobot::drivetrain->DriveMecanum(0.0,-.75,0.0,0.9,0.0); + if(power==NULL){ + 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); + } } bool AutoDrive::IsFinished(){ return IsTimedOut(); diff --git a/Commands/Autonomous/AutoDrive.h b/Commands/Autonomous/AutoDrive.h index d84f33f..3c1e9ae 100644 --- a/Commands/Autonomous/AutoDrive.h +++ b/Commands/Autonomous/AutoDrive.h @@ -7,8 +7,11 @@ #include "WPILib.h" class AutoDrive: public Command{ + private: + double *power; public: AutoDrive(double); + AutoDrive(double, double); void Initialize(); void Execute(); bool IsFinished(); diff --git a/Commands/Collector/CollectTote.cpp b/Commands/Collector/CollectTote.cpp new file mode 100644 index 0000000..88b078b --- /dev/null +++ b/Commands/Collector/CollectTote.cpp @@ -0,0 +1,11 @@ +#include "CollectTote.h" +#include "../../DentRobot.h" +#include "../Autonomous/AutoDrive.h" +#include "RollIn.h" +#include "CloseCollector.h" +CollectTote::CollectTote(){ + AddParallel(new RollIn()); + AddParallel(new AutoDrive(0.5, -0.75)); + AddSequential(new CloseCollector()); +} +// vim: ts=2:sw=2:et diff --git a/Commands/Collector/CollectTote.h b/Commands/Collector/CollectTote.h new file mode 100644 index 0000000..be6d94e --- /dev/null +++ b/Commands/Collector/CollectTote.h @@ -0,0 +1,14 @@ +#ifndef COLLECTTOTE_H +#define COLLECTTOTE_H + +#include "Commands/CommandGroup.h" +#include "../../CommandBase.h" +#include "../../DentRobot.h" +#include "WPILib.h" + +class CollectTote: public CommandGroup{ + public: + CollectTote(); +}; +#endif +// vim: ts=2:sw=2:et diff --git a/Commands/Collector/ReleaseTote.cpp b/Commands/Collector/ReleaseTote.cpp new file mode 100644 index 0000000..c136661 --- /dev/null +++ b/Commands/Collector/ReleaseTote.cpp @@ -0,0 +1,11 @@ +#include "ReleaseTote.h" +#include "../../DentRobot.h" +#include "RollOut.h" +#include "../Autonomous/AutoDrive.h" +#include "CloseCollector.h" +ReleaseTote::ReleaseTote(){ + AddParallel(new RollOut()); + AddParallel(new AutoDrive(0.5, 0.75)); + AddSequential(new CloseCollector()); +} +// vim: ts=2:sw=2:et diff --git a/Commands/Collector/ReleaseTote.h b/Commands/Collector/ReleaseTote.h new file mode 100644 index 0000000..df04a04 --- /dev/null +++ b/Commands/Collector/ReleaseTote.h @@ -0,0 +1,14 @@ +#ifndef RELEASETOTE_H +#define RELEASETOTE_H + +#include "Commands/CommandGroup.h" +#include "../../CommandBase.h" +#include "../../DentRobot.h" +#include "WPILib.h" + +class ReleaseTote: public CommandGroup{ + public: + ReleaseTote(); +}; +#endif +// vim: ts=2:sw=2:et diff --git a/OI.cpp b/OI.cpp index 84abd5c..9a4afa5 100644 --- a/OI.cpp +++ b/OI.cpp @@ -5,6 +5,8 @@ #include "Commands/Collector/CloseCollector.h" #include "Commands/Collector/RollIn.h" #include "Commands/Collector/RollOut.h" +#include "Commands/BinElevator/BinLower.h" +#include "Commands/BinElevator/BinRaise.h" OI::OI() { // Joysticks @@ -34,10 +36,21 @@ OI::OI() { right6->WhenPressed(raise); right5->CancelWhenPressed(lower); right6->CancelWhenPressed(lower); + // BinElevator + binRaise=new BinRaise(); + binLower=new BinLower(); + JoystickButton *right7=new JoystickButton(rightStick, 7); + JoystickButton *right8=new JoystickButton(rightStick, 8); + right7->WhenPressed(binLower); + right7->CancelWhenPressed(binRaise); + right8->WhenPressed(binRaise); + right8->CancelWhenPressed(binLower); // Cancel JoystickButton *right12=new JoystickButton(rightStick, 12); right12->CancelWhenPressed(raise); right12->CancelWhenPressed(lower); + right12->CancelWhenPressed(binRaise); + right12->CancelWhenPressed(binLower); } Joystick* OI::GetRightStick(){ return rightStick; diff --git a/OI.h b/OI.h index 357dbda..e62b157 100644 --- a/OI.h +++ b/OI.h @@ -12,7 +12,7 @@ class OI OI(); Joystick* GetRightStick(); Joystick* GetLeftStick(); - Command *raise, *lower; + Command *raise, *lower, *binLower, *binRaise; }; #endif // vim: ts=2:sw=2:et diff --git a/RobotMap.h b/RobotMap.h index a3abe10..afeb205 100644 --- a/RobotMap.h +++ b/RobotMap.h @@ -9,16 +9,16 @@ #define ELEVATOR_COLELCT_TOTE_DIO 1 #define ELEVATOR_READY_TOTE_DIO 2 #define ELEVATOR_TOP_DIO 5 -#define ELEVATOR_ENCODERA 0 -#define ELEVATOR_ENCODERB 1 +#define ELEVATOR_ENCODERA 4 +#define ELEVATOR_ENCODERB 9 // BinElevator #define BINELEVATOR_CAN 11 #define BINELEVATOR_BOTTOM_DIO 6 #define BINELEVATOR_COLELCT_BIN_DIO 7 #define BINELEVATOR_TOP_DIO 8 -#define BINELEVATOR_ENCODERA 2 -#define BINELEVATOR_ENCODERB 3 +#define BINELEVATOR_ENCODERA 10 +#define BINELEVATOR_ENCODERB 11 // Drivetrain #define DRIVE_FRONT_LEFT_CAN 2