From 300dfaafc923685c47c3de4f0033db3bc4581165 Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Sat, 17 Jan 2015 12:55:51 -0500 Subject: [PATCH] Added default command for drivetrain --- src/Commands/Collect.cpp | 2 +- src/Commands/Collect.h | 4 ++-- src/Commands/Drive.cpp | 16 ++++++++++++++++ src/Commands/Drive.h | 16 ++++++++++++++++ src/Commands/Eject.cpp | 5 +++-- src/Commands/Eject.h | 4 ++-- src/Commands/Lower.cpp | 2 +- src/Commands/Lower.h | 4 ++-- src/Commands/Raise.h | 4 ++-- src/Subsystems/Drivetrain.cpp | 2 ++ 10 files changed, 47 insertions(+), 12 deletions(-) create mode 100644 src/Commands/Drive.cpp create mode 100644 src/Commands/Drive.h diff --git a/src/Commands/Collect.cpp b/src/Commands/Collect.cpp index 2ed8766..e863ff3 100644 --- a/src/Commands/Collect.cpp +++ b/src/Commands/Collect.cpp @@ -1,5 +1,5 @@ #include "Collect.h" -Collect::Collect(){ +Collect::Collect() : Command("Collect"){ } void Collect::Initialize(){ } diff --git a/src/Commands/Collect.h b/src/Commands/Collect.h index 9851adc..a9dd24d 100644 --- a/src/Commands/Collect.h +++ b/src/Commands/Collect.h @@ -1,10 +1,10 @@ #ifndef COLLECT_H #define COLLECT_H -#include "../CommandBase.h" +#include "Commands/Command.h" #include "WPILib.h" -class Collect: public CommandBase{ +class Collect: public Command{ public: Collect(); void Initialize(); diff --git a/src/Commands/Drive.cpp b/src/Commands/Drive.cpp new file mode 100644 index 0000000..05ad2d1 --- /dev/null +++ b/src/Commands/Drive.cpp @@ -0,0 +1,16 @@ +#include "Drive.h" +#include "../DentRobot.h" +Drive::Drive() : Command("Drive"){ +} +void Drive::Initialize(){ +} +void Drive::Execute(){ + DentRobot::drivetrain->DriveMecanum(DentRobot::oi->GetLeftStick()->GetRawAxis(2), DentRobot::oi->GetLeftStick()->GetRawAxis(1), DentRobot::oi->GetLeftStick()->GetRawAxis(0)); +} +bool Drive::IsFinished(){ + return false; +} +void Drive::End(){ +} +void Drive::Interrupted(){ +} diff --git a/src/Commands/Drive.h b/src/Commands/Drive.h new file mode 100644 index 0000000..8254d17 --- /dev/null +++ b/src/Commands/Drive.h @@ -0,0 +1,16 @@ +#ifndef DRIVE_H +#define DRIVE_H + +#include "Commands/Command.h" +#include "WPILib.h" + +class Drive: public Command{ + public: + Drive(); + void Initialize(); + void Execute(); + bool IsFinished(); + void End(); + void Interrupted(); +}; +#endif diff --git a/src/Commands/Eject.cpp b/src/Commands/Eject.cpp index 98fdf0d..0e72eea 100644 --- a/src/Commands/Eject.cpp +++ b/src/Commands/Eject.cpp @@ -1,11 +1,12 @@ #include "Eject.h" #include "../DentRobot.h" -Eject::Eject(){ +Eject::Eject() : Command("Eject"){ + Requires(DentRobot::collector); } void Eject::Initialize(){ } void Eject::Execute(){ - DentRobot::collector->Set(oi->GetLeftStick()->GetThrottle()); + DentRobot::collector->Set(DentRobot::oi->GetLeftStick()->GetThrottle()); } bool Eject::IsFinished(){ return false; diff --git a/src/Commands/Eject.h b/src/Commands/Eject.h index 8124c8c..8793be9 100644 --- a/src/Commands/Eject.h +++ b/src/Commands/Eject.h @@ -1,10 +1,10 @@ #ifndef EJECT_H #define EJECT_H -#include "../CommandBase.h" +#include "Commands/Command.h" #include "WPILib.h" -class Eject: public CommandBase{ +class Eject: public Command{ public: Eject(); void Initialize(); diff --git a/src/Commands/Lower.cpp b/src/Commands/Lower.cpp index 8422fb1..d16cd09 100644 --- a/src/Commands/Lower.cpp +++ b/src/Commands/Lower.cpp @@ -1,5 +1,5 @@ #include "Lower.h" -Lower::Lower(){ +Lower::Lower() : Command("Lower"){ } void Lower::Initialize(){ } diff --git a/src/Commands/Lower.h b/src/Commands/Lower.h index 5a58de1..68be397 100644 --- a/src/Commands/Lower.h +++ b/src/Commands/Lower.h @@ -1,10 +1,10 @@ #ifndef LOWER_H #define LOWER_H -#include "../CommandBase.h" +#include "Commands/Command.h" #include "WPILib.h" -class Lower: public CommandBase{ +class Lower: public Command{ public: Lower(); void Initialize(); diff --git a/src/Commands/Raise.h b/src/Commands/Raise.h index 579ad22..8960dd8 100644 --- a/src/Commands/Raise.h +++ b/src/Commands/Raise.h @@ -1,10 +1,10 @@ #ifndef RAISE_H #define RAISE_H -#include "../CommandBase.h" +#include "Commands/Command.h" #include "WPILib.h" -class Raise: public CommandBase{ +class Raise: public Command{ public: Raise(); void Initialize(); diff --git a/src/Subsystems/Drivetrain.cpp b/src/Subsystems/Drivetrain.cpp index da53fde..be9878c 100644 --- a/src/Subsystems/Drivetrain.cpp +++ b/src/Subsystems/Drivetrain.cpp @@ -1,5 +1,6 @@ #include "Drivetrain.h" #include "../RobotMap.h" +#include "../Commands/Drive.h" Drivetrain::Drivetrain() : Subsystem("Drivetrain"){ frontLeft=new Talon(0); @@ -9,6 +10,7 @@ Drivetrain::Drivetrain() : Subsystem("Drivetrain"){ drive=new RobotDrive(frontLeft, frontRight, backLeft, backRight); } void Drivetrain::InitDefaultCommand(){ + SetDefaultCommand(new Drive()); } void Drivetrain::DriveMecanum(float x, float y, float rotation){ drive->MecanumDrive_Cartesian(x, y, rotation);