From 88ec9d52484d1143a5ff29ba9feff821726883a4 Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Sun, 11 Jan 2015 16:02:49 -0500 Subject: [PATCH 01/64] Started working on command based robot (does not work) --- src/CommandBase.cpp | 25 ++++++++++++++++++++ src/CommandBase.h | 20 ++++++++++++++++ src/DentRobot.cpp | 39 ++++++++++++++++++++++++++++++ src/HHBase.cpp | 28 ---------------------- src/HHBase.h | 26 -------------------- src/HHRobot.cpp | 46 ------------------------------------ src/HHRobot.h | 19 --------------- src/OI.cpp | 4 ++++ src/OI.h | 12 ++++++++++ src/RobotMap.h | 6 +++++ src/Subsystems/Collector.cpp | 7 ++++++ src/Subsystems/Collector.h | 13 ++++++++++ src/classes/Collector.cpp | 22 ----------------- src/classes/Collector.h | 15 ------------ src/hhlib | 1 - 15 files changed, 126 insertions(+), 157 deletions(-) create mode 100644 src/CommandBase.cpp create mode 100644 src/CommandBase.h create mode 100644 src/DentRobot.cpp delete mode 100644 src/HHBase.cpp delete mode 100644 src/HHBase.h delete mode 100644 src/HHRobot.cpp delete mode 100644 src/HHRobot.h create mode 100644 src/OI.cpp create mode 100644 src/OI.h create mode 100644 src/RobotMap.h create mode 100644 src/Subsystems/Collector.cpp create mode 100644 src/Subsystems/Collector.h delete mode 100644 src/classes/Collector.cpp delete mode 100644 src/classes/Collector.h delete mode 160000 src/hhlib diff --git a/src/CommandBase.cpp b/src/CommandBase.cpp new file mode 100644 index 0000000..7c8c4d5 --- /dev/null +++ b/src/CommandBase.cpp @@ -0,0 +1,25 @@ +#include "CommandBase.h" +#include "Subsystems/Drivetrain.h" +#include "Subsystems/Collector.h" +#include "Subsystems/Elevator.h" +#include "Commands/Drive.h" +#include "Commands/Collect.h" +#include "Commands/Eject.h" +#include "Commands/Raise.h" +#include "Commands/Lower.h" +Drivetrain* CommandBase::drivetrain = NULL; +Collector* CommandBase::collector = NULL; +Elevator* CommandBase::elevator = NULL; +OI* CommandBase::oi = NULL; +CommandBase::CommandBase(char const *name) : Command(name) { +} +CommandBase::CommandBase() : Command() { +} +void CommandBase::init() +{ + drivetrain = new Drivetrain(); + collector = new Collector(); + elevator = new Elevator(); + oi = new OI(); +} + diff --git a/src/CommandBase.h b/src/CommandBase.h new file mode 100644 index 0000000..3c5f352 --- /dev/null +++ b/src/CommandBase.h @@ -0,0 +1,20 @@ +#ifndef COMMAND_BASE_H +#define COMMAND_BASE_H + +#include +#include "Commands/Command.h" +#include "Subsystems/ExampleSubsystem.h" +#include "OI.h" +#include "WPILib.h" + +class CommandBase: public Command { +public: + CommandBase(char const *name); + CommandBase(); + static void init(); + static Drivetrain *drivetrain; + static Collector *collector; + static Elevator *elevator; + static OI *oi; +}; +#endif diff --git a/src/DentRobot.cpp b/src/DentRobot.cpp new file mode 100644 index 0000000..7a8a37b --- /dev/null +++ b/src/DentRobot.cpp @@ -0,0 +1,39 @@ +#include "WPILib.h" +#include "Commands/Command.h" +#include "Commands/Drive.h" +#include "Commands/Collect.h" +#include "Commands/Eject.h" +#include "Commands/Raise.h" +#include "Commands/Lower.h" +class DentRobot: public IterativeRobot { +private: + Command *autonomousCommand = NULL; + LiveWindow *lw; + void RobotInit() { + CommandBase::init(); + lw = LiveWindow::GetInstance(); + } + void DisabledPeriodic() { + Scheduler::GetInstance()->Run(); + } + void AutonomousInit() { + if(autonomousCommand != NULL) { + autonomousCommand->Start(); + } + } + void AutonomousPeriodic() { + Scheduler::GetInstance()->Run(); + } + void TeleopInit() { + if(autonomousCommand != NULL) { + autonomousCommand->Cancel(); + } + } + void TeleopPeriodic() { + Scheduler::GetInstance()->Run(); + } + void TestPeriodic() { + lw->Run(); + } +}; +START_ROBOT_CLASS(DentRobot); diff --git a/src/HHBase.cpp b/src/HHBase.cpp deleted file mode 100644 index 0023bc3..0000000 --- a/src/HHBase.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "HHBase.h" -#include -#include -#include -#include -HHBase::HHBase(): - hhbot(new HHRobot()){ - printf("Done\n"); - } -void HHBase::RobotInit(){ -} -void HHBase::DisabledInit(){} -void HHBase::AutonomousInit(){ -} -void HHBase::TeleopInit(){ -} -void HHBase::DisabledContinuous(){} -void HHBase::AutonomousContinuous(){} -void HHBase::TeleopContinuous(){} -void HHBase::DisabledPeriodic(){} -void HHBase::AutonomousPeriodic(){ -} -void HHBase::TeleopPeriodic(){ - hhbot->Handler(); -} -void HHBase::Test(){} -START_ROBOT_CLASS(HHBase); -// vim: ts=2:sw=2:et diff --git a/src/HHBase.h b/src/HHBase.h deleted file mode 100644 index c4e66e2..0000000 --- a/src/HHBase.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef __HH_BASE_H__ -#define __HH_BASE_H__ -#include -#include -#include "HHRobot.h" -//Because this is the first header to be included, classes need to be declared here -class HHRobot; -class HHBase : public IterativeRobot{ - private: - HHRobot *hhbot; - public: - HHBase(); - void RobotInit(); - void DisabledInit(); - void AutonomousInit(); - void TeleopInit(); - void DisabledContinuous(); - void AutonomousContinuous(); - void TeleopContinuous(); - void DisabledPeriodic(); - void AutonomousPeriodic(); - void TeleopPeriodic(); - void Test(); -}; -#endif -// vim: ts=2:sw=2:et diff --git a/src/HHRobot.cpp b/src/HHRobot.cpp deleted file mode 100644 index 1020bc1..0000000 --- a/src/HHRobot.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#include "HHRobot.h" -#include "HHBase.h" -HHRobot::HHRobot(): - hhdrive(new RobotDrive(2,0,3,1)), - gyro(new Gyro(1)), - collector(new DentCollector(4, 5, 6, 7)), - driveStick(new Extreme3dPro(0)){ - hhdrive->SetExpiration(0.1); - hhdrive->SetInvertedMotor(RobotDrive::kFrontRightMotor, true); - hhdrive->SetInvertedMotor(RobotDrive::kRearLeftMotor,true); - } -void HHRobot::Init(){ - printf("Initing\n"); - printf("Code Version: %f\n",0000.1); - gyro->Reset(); -} -//Main function used to handle periodic tasks on the robot -void HHRobot::Handler(){ - const float Kp = 0.3; - if(driveStick->GetJoystickButton(1)==1){ - hhdrive->MecanumDrive_Cartesian(driveStick->GetJoystickAxis("z"), 0, driveStick->GetJoystickAxis("x")); - }else if(driveStick->GetJoystickButton(2)==1){ - hhdrive->MecanumDrive_Cartesian(driveStick->GetJoystickAxis("z"), driveStick->GetJoystickAxis("y"), 0); - }else if(driveStick->GetJoystickButton(3)==1){ - hhdrive->Drive(driveStick->GetJoystickAxis("y"), driveStick->GetJoystickAxis("y")*Kp*-gyro->GetAngle()); - }else{ - hhdrive->MecanumDrive_Cartesian(driveStick->GetJoystickAxis("z"), driveStick->GetJoystickAxis("y"), driveStick->GetJoystickAxis("x")); - } - if(driveStick->GetJoystickButton(11)==1){ - collector->Collect(driveStick->GetThrottle()); - }else if(driveStick->GetJoystickButton(12)==1){ - collector->Collect(-driveStick->GetThrottle()); - }else if(driveStick->GetJoystickButton(9)==1){ - collector->Raise(driveStick->GetThrottle()); - }else if(driveStick->GetJoystickButton(10)==1){ - collector->Raise(-driveStick->GetThrottle()); - }else{ - collector->Rest(); - } - SmartDashboard::PutNumber("hambone1", driveStick->GetThrottle()); - SmartDashboard::PutNumber("hambone2", driveStick->GetJoystickAxis("joystick")); - SmartDashboard::PutNumber("hambone3", driveStick->GetRawJoystickAxis(3)); - printf("hambone2: %f", driveStick->GetThrottle()); - Wait(0.005); -} -// vim: ts=2:sw=2:et diff --git a/src/HHRobot.h b/src/HHRobot.h deleted file mode 100644 index f6dc004..0000000 --- a/src/HHRobot.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef __ROBOT_H__ -#define __ROBOT_H__ -#include -#include "HHBase.h" -#include "classes/Collector.h" -#include "hhlib/input/controller/Joystick.h" -class HHRobot{ - private: - RobotDrive *hhdrive; - Gyro *gyro; - DentCollector *collector; - Extreme3dPro *driveStick; - public: - HHRobot(); - void Init(); - void Handler(); -}; -#endif -// vim: ts=2:sw=2:et diff --git a/src/OI.cpp b/src/OI.cpp new file mode 100644 index 0000000..8425006 --- /dev/null +++ b/src/OI.cpp @@ -0,0 +1,4 @@ +#include "OI.h" + +OI::OI() { +} diff --git a/src/OI.h b/src/OI.h new file mode 100644 index 0000000..51aef6e --- /dev/null +++ b/src/OI.h @@ -0,0 +1,12 @@ +#ifndef OI_H +#define OI_H + +#include "WPILib.h" + +class OI +{ +private: +public: + OI(); +}; +#endif diff --git a/src/RobotMap.h b/src/RobotMap.h new file mode 100644 index 0000000..11d078f --- /dev/null +++ b/src/RobotMap.h @@ -0,0 +1,6 @@ +#ifndef ROBOTMAP_H +#define ROBOTMAP_H + +#include "WPILib.h" + +#endif diff --git a/src/Subsystems/Collector.cpp b/src/Subsystems/Collector.cpp new file mode 100644 index 0000000..7cf0192 --- /dev/null +++ b/src/Subsystems/Collector.cpp @@ -0,0 +1,7 @@ +#include "ExampleSubsystem.h" +#include "../RobotMap.h" + +ExampleSubsystem::ExampleSubsystem() : Subsystem("ExampleSubsystem") { +} +void ExampleSubsystem::InitDefaultCommand() { +} diff --git a/src/Subsystems/Collector.h b/src/Subsystems/Collector.h new file mode 100644 index 0000000..b9b6c45 --- /dev/null +++ b/src/Subsystems/Collector.h @@ -0,0 +1,13 @@ +#ifndef COLLECTOR_H +#define COLLECTOR_H + +#include "Commands/Subsystem.h" +#include "WPILib.h" +class Collector: public Subsystem +{ +private: +public: + ExampleSubsystem(); + void InitDefaultCommand(); +}; +#endif diff --git a/src/classes/Collector.cpp b/src/classes/Collector.cpp deleted file mode 100644 index 919158c..0000000 --- a/src/classes/Collector.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "Collector.h" -DentCollector::DentCollector(int fl, int fr, int rl, int rr){ - collectorLeft = new Talon(fl); - collectorRight = new Talon(fr); - raiserLeft = new Talon(rl); - raiserRight = new Talon(rr); -} -void DentCollector::Collect(float power){ - collectorLeft->Set(power); - collectorRight->Set(power); -} -void DentCollector::Raise(float power){ - raiserLeft->Set(power); - raiserRight->Set(power); -} -void DentCollector::Rest(){ - raiserLeft->Set(0); - raiserRight->Set(0); - collectorLeft->Set(0); - collectorRight->Set(0); -} -// vim: ts=2:sw=2:et diff --git a/src/classes/Collector.h b/src/classes/Collector.h deleted file mode 100644 index f112d0a..0000000 --- a/src/classes/Collector.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef __COLLECTOR_H__ -#include -#define __COLLECTOR_H__ -//#include "" -class DentCollector{ - private: - Talon *collectorLeft, *collectorRight, *raiserLeft, *raiserRight; - public: - DentCollector(int, int, int, int); - void Collect(float); - void Raise(float); - void Rest(); -}; -#endif -// vim: ts=2:sw=2:et diff --git a/src/hhlib b/src/hhlib deleted file mode 160000 index 38a965d..0000000 --- a/src/hhlib +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 38a965dd1f7c6737f722f56c0f7940805ece9917 From db1f777ec8916216127a51d0c66e58b145f42f20 Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Tue, 13 Jan 2015 11:06:34 -0500 Subject: [PATCH 02/64] Removed Debug directory --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 5761abc..12a4c4b 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ *.o +Debug From 180884bfe7ab5198aa1205189e1cf50efe3840c9 Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Fri, 16 Jan 2015 19:29:55 -0500 Subject: [PATCH 03/64] Code compiles --- src/CommandBase.h | 6 ++++-- src/Commands/Collect.cpp | 15 +++++++++++++++ src/Commands/Collect.h | 17 +++++++++++++++++ src/Commands/Drive.cpp | 15 +++++++++++++++ src/Commands/Drive.h | 17 +++++++++++++++++ src/Commands/Eject.cpp | 15 +++++++++++++++ src/Commands/Eject.h | 17 +++++++++++++++++ src/Commands/Lower.cpp | 15 +++++++++++++++ src/Commands/Lower.h | 17 +++++++++++++++++ src/Commands/Raise.cpp | 15 +++++++++++++++ src/Commands/Raise.h | 17 +++++++++++++++++ src/DentRobot.cpp | 1 - src/Subsystems/Collector.cpp | 6 +++--- src/Subsystems/Collector.h | 3 +-- src/Subsystems/Drivetrain.cpp | 7 +++++++ src/Subsystems/Drivetrain.h | 12 ++++++++++++ src/Subsystems/Elevator.cpp | 7 +++++++ src/Subsystems/Elevator.h | 12 ++++++++++++ 18 files changed, 206 insertions(+), 8 deletions(-) create mode 100644 src/Commands/Collect.cpp create mode 100644 src/Commands/Collect.h create mode 100644 src/Commands/Drive.cpp create mode 100644 src/Commands/Drive.h create mode 100644 src/Commands/Eject.cpp create mode 100644 src/Commands/Eject.h create mode 100644 src/Commands/Lower.cpp create mode 100644 src/Commands/Lower.h create mode 100644 src/Commands/Raise.cpp create mode 100644 src/Commands/Raise.h create mode 100644 src/Subsystems/Drivetrain.cpp create mode 100644 src/Subsystems/Drivetrain.h create mode 100644 src/Subsystems/Elevator.cpp create mode 100644 src/Subsystems/Elevator.h diff --git a/src/CommandBase.h b/src/CommandBase.h index 3c5f352..cd628b9 100644 --- a/src/CommandBase.h +++ b/src/CommandBase.h @@ -2,8 +2,10 @@ #define COMMAND_BASE_H #include -#include "Commands/Command.h" -#include "Subsystems/ExampleSubsystem.h" +//#include "Commands/Drive.h" +#include "Subsystems/Drivetrain.h" +#include "Subsystems/Collector.h" +#include "Subsystems/Elevator.h" #include "OI.h" #include "WPILib.h" diff --git a/src/Commands/Collect.cpp b/src/Commands/Collect.cpp new file mode 100644 index 0000000..d07eadb --- /dev/null +++ b/src/Commands/Collect.cpp @@ -0,0 +1,15 @@ +#include "Collect.h" +Collect::Collect(){ +} +void Collect::Initialize(){ +} +void Collect::Execute(){ +} +bool Collect::IsFinished(){ + return false; +} +void Collect::End(){ + +} +void Collect::Interrupted(){ +} diff --git a/src/Commands/Collect.h b/src/Commands/Collect.h new file mode 100644 index 0000000..fd25c8b --- /dev/null +++ b/src/Commands/Collect.h @@ -0,0 +1,17 @@ +#ifndef COLLECT_H +#define COLLECT_H + +#include "../CommandBase.h" +#include "WPILib.h" + +class Collect: public CommandBase{ +public: + Collect(); + void Initialize(); + void Execute(); + bool IsFinished(); + void End(); + void Interrupted(); +}; + +#endif diff --git a/src/Commands/Drive.cpp b/src/Commands/Drive.cpp new file mode 100644 index 0000000..034c2b8 --- /dev/null +++ b/src/Commands/Drive.cpp @@ -0,0 +1,15 @@ +#include "Drive.h" +Drive::Drive(){ +} +void Drive::Initialize(){ +} +void Drive::Execute(){ +} +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..e9da98a --- /dev/null +++ b/src/Commands/Drive.h @@ -0,0 +1,17 @@ +#ifndef DRIVE_H +#define DRIVE_H + +#include "../CommandBase.h" +#include "WPILib.h" + +class Drive: public CommandBase{ +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 new file mode 100644 index 0000000..a5b7f59 --- /dev/null +++ b/src/Commands/Eject.cpp @@ -0,0 +1,15 @@ +#include "Eject.h" +Eject::Eject(){ +} +void Eject::Initialize(){ +} +void Eject::Execute(){ +} +bool Eject::IsFinished(){ + return false; +} +void Eject::End(){ + +} +void Eject::Interrupted(){ +} diff --git a/src/Commands/Eject.h b/src/Commands/Eject.h new file mode 100644 index 0000000..9bbb8c7 --- /dev/null +++ b/src/Commands/Eject.h @@ -0,0 +1,17 @@ +#ifndef EJECT_H +#define EJECT_H + +#include "../CommandBase.h" +#include "WPILib.h" + +class Eject: public CommandBase{ +public: + Eject(); + void Initialize(); + void Execute(); + bool IsFinished(); + void End(); + void Interrupted(); +}; + +#endif diff --git a/src/Commands/Lower.cpp b/src/Commands/Lower.cpp new file mode 100644 index 0000000..0ef564d --- /dev/null +++ b/src/Commands/Lower.cpp @@ -0,0 +1,15 @@ +#include "Lower.h" +Lower::Lower(){ +} +void Lower::Initialize(){ +} +void Lower::Execute(){ +} +bool Lower::IsFinished(){ + return false; +} +void Lower::End(){ + +} +void Lower::Interrupted(){ +} diff --git a/src/Commands/Lower.h b/src/Commands/Lower.h new file mode 100644 index 0000000..1d5718b --- /dev/null +++ b/src/Commands/Lower.h @@ -0,0 +1,17 @@ +#ifndef LOWER_H +#define LOWER_H + +#include "../CommandBase.h" +#include "WPILib.h" + +class Lower: public CommandBase{ +public: + Lower(); + void Initialize(); + void Execute(); + bool IsFinished(); + void End(); + void Interrupted(); +}; + +#endif diff --git a/src/Commands/Raise.cpp b/src/Commands/Raise.cpp new file mode 100644 index 0000000..0cf0cec --- /dev/null +++ b/src/Commands/Raise.cpp @@ -0,0 +1,15 @@ +#include "Raise.h" +Raise::Raise(){ +} +void Raise::Initialize(){ +} +void Raise::Execute(){ +} +bool Raise::IsFinished(){ + return false; +} +void Raise::End(){ + +} +void Raise::Interrupted(){ +} diff --git a/src/Commands/Raise.h b/src/Commands/Raise.h new file mode 100644 index 0000000..1eac77e --- /dev/null +++ b/src/Commands/Raise.h @@ -0,0 +1,17 @@ +#ifndef RAISE_H +#define RAISE_H + +#include "../CommandBase.h" +#include "WPILib.h" + +class Raise: public CommandBase{ +public: + Raise(); + void Initialize(); + void Execute(); + bool IsFinished(); + void End(); + void Interrupted(); +}; + +#endif diff --git a/src/DentRobot.cpp b/src/DentRobot.cpp index 7a8a37b..6d89f15 100644 --- a/src/DentRobot.cpp +++ b/src/DentRobot.cpp @@ -1,5 +1,4 @@ #include "WPILib.h" -#include "Commands/Command.h" #include "Commands/Drive.h" #include "Commands/Collect.h" #include "Commands/Eject.h" diff --git a/src/Subsystems/Collector.cpp b/src/Subsystems/Collector.cpp index 7cf0192..443c99d 100644 --- a/src/Subsystems/Collector.cpp +++ b/src/Subsystems/Collector.cpp @@ -1,7 +1,7 @@ -#include "ExampleSubsystem.h" +#include "Collector.h" #include "../RobotMap.h" -ExampleSubsystem::ExampleSubsystem() : Subsystem("ExampleSubsystem") { +Collector::Collector() : Subsystem("Collector") { } -void ExampleSubsystem::InitDefaultCommand() { +void Collector::InitDefaultCommand() { } diff --git a/src/Subsystems/Collector.h b/src/Subsystems/Collector.h index b9b6c45..717d8ba 100644 --- a/src/Subsystems/Collector.h +++ b/src/Subsystems/Collector.h @@ -1,13 +1,12 @@ #ifndef COLLECTOR_H #define COLLECTOR_H -#include "Commands/Subsystem.h" #include "WPILib.h" class Collector: public Subsystem { private: public: - ExampleSubsystem(); + Collector(); void InitDefaultCommand(); }; #endif diff --git a/src/Subsystems/Drivetrain.cpp b/src/Subsystems/Drivetrain.cpp new file mode 100644 index 0000000..a99eb15 --- /dev/null +++ b/src/Subsystems/Drivetrain.cpp @@ -0,0 +1,7 @@ +#include "Drivetrain.h" +#include "../RobotMap.h" + +Drivetrain::Drivetrain() : Subsystem("Drivetrain") { +} +void Drivetrain::InitDefaultCommand() { +} diff --git a/src/Subsystems/Drivetrain.h b/src/Subsystems/Drivetrain.h new file mode 100644 index 0000000..26613d7 --- /dev/null +++ b/src/Subsystems/Drivetrain.h @@ -0,0 +1,12 @@ +#ifndef DRIVETRAIN_H +#define DRIVETRAIN_H + +#include "WPILib.h" +class Drivetrain: public Subsystem +{ +private: +public: + Drivetrain(); + void InitDefaultCommand(); +}; +#endif diff --git a/src/Subsystems/Elevator.cpp b/src/Subsystems/Elevator.cpp new file mode 100644 index 0000000..20d6a5b --- /dev/null +++ b/src/Subsystems/Elevator.cpp @@ -0,0 +1,7 @@ +#include "Elevator.h" +#include "../RobotMap.h" + +Elevator::Elevator() : Subsystem("Elevator") { +} +void Elevator::InitDefaultCommand() { +} diff --git a/src/Subsystems/Elevator.h b/src/Subsystems/Elevator.h new file mode 100644 index 0000000..0c7f33a --- /dev/null +++ b/src/Subsystems/Elevator.h @@ -0,0 +1,12 @@ +#ifndef ELEVATOR_H +#define ELEVATOR_H + +#include "WPILib.h" +class Elevator: public Subsystem +{ +private: +public: + Elevator(); + void InitDefaultCommand(); +}; +#endif From 0036f2dd7a2885bd0b56edcf6a446480b1f71b7d Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Fri, 16 Jan 2015 19:49:16 -0500 Subject: [PATCH 04/64] Added DentRobot.h --- src/DentRobot.cpp | 61 +++++++++++++++++++---------------------------- src/DentRobot.h | 23 ++++++++++++++++++ 2 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 src/DentRobot.h diff --git a/src/DentRobot.cpp b/src/DentRobot.cpp index 6d89f15..f34e638 100644 --- a/src/DentRobot.cpp +++ b/src/DentRobot.cpp @@ -1,38 +1,25 @@ -#include "WPILib.h" -#include "Commands/Drive.h" -#include "Commands/Collect.h" -#include "Commands/Eject.h" -#include "Commands/Raise.h" -#include "Commands/Lower.h" -class DentRobot: public IterativeRobot { -private: - Command *autonomousCommand = NULL; - LiveWindow *lw; - void RobotInit() { - CommandBase::init(); - lw = LiveWindow::GetInstance(); - } - void DisabledPeriodic() { - Scheduler::GetInstance()->Run(); - } - void AutonomousInit() { - if(autonomousCommand != NULL) { - autonomousCommand->Start(); - } - } - void AutonomousPeriodic() { - Scheduler::GetInstance()->Run(); - } - void TeleopInit() { - if(autonomousCommand != NULL) { - autonomousCommand->Cancel(); - } - } - void TeleopPeriodic() { - Scheduler::GetInstance()->Run(); - } - void TestPeriodic() { - lw->Run(); - } -}; +#include "DentRobot.h" +DentRobot::DentRobot(): + driveCommand(new Drive()){ + printf("Initialized"); +} +void DentRobot::RobotInit(){ + printf("Initializing"); + CommandBase::init(); +} +void DentRobot::DisabledPeriodic(){ + Scheduler::GetInstance()->Run(); +} +void DentRobot::AutonomousInit(){ +} +void DentRobot::AutonomousPeriodic(){ + Scheduler::GetInstance()->Run(); +} +void DentRobot::TeleopInit(){ +} +void DentRobot::TeleopPeriodic(){ + Scheduler::GetInstance()->Run(); +} +void DentRobot::TestPeriodic(){ +} START_ROBOT_CLASS(DentRobot); diff --git a/src/DentRobot.h b/src/DentRobot.h new file mode 100644 index 0000000..2ec1f47 --- /dev/null +++ b/src/DentRobot.h @@ -0,0 +1,23 @@ +#ifndef DENTROBOT_H +#define DENTROBOT_H +#include "WPILib.h" +#include "Commands/Drive.h" +#include "Commands/Collect.h" +#include "Commands/Eject.h" +#include "Commands/Raise.h" +#include "Commands/Lower.h" +class DentRobot: public IterativeRobot { +private: + Command *driveCommand = NULL; +public: + DentRobot(); + void RobotInit(); + void DisabledPeriodic(); + void AutonomousInit(); + void AutonomousPeriodic(); + void TeleopInit(); + void TeleopPeriodic(); + void TestPeriodic(); +}; +#endif +// vim: ts=2:sw=2:et From 214318b5fbc9b6d567838524ed8ffea3d5c63a97 Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Fri, 16 Jan 2015 20:12:48 -0500 Subject: [PATCH 05/64] Removed tabs --- src/CommandBase.h | 17 ++++++++--------- src/Commands/Collect.cpp | 2 +- src/Commands/Collect.h | 14 +++++++------- src/Commands/Drive.cpp | 2 +- src/Commands/Drive.h | 14 +++++++------- src/Commands/Eject.cpp | 2 +- src/Commands/Eject.h | 14 +++++++------- src/Commands/Lower.cpp | 2 +- src/Commands/Lower.h | 14 +++++++------- src/Commands/Raise.cpp | 2 +- src/Commands/Raise.h | 14 +++++++------- src/OI.h | 6 +++--- src/Subsystems/Collector.h | 8 ++++---- src/Subsystems/Drivetrain.h | 8 ++++---- src/Subsystems/Elevator.h | 8 ++++---- 15 files changed, 63 insertions(+), 64 deletions(-) diff --git a/src/CommandBase.h b/src/CommandBase.h index cd628b9..a0e5d05 100644 --- a/src/CommandBase.h +++ b/src/CommandBase.h @@ -2,7 +2,6 @@ #define COMMAND_BASE_H #include -//#include "Commands/Drive.h" #include "Subsystems/Drivetrain.h" #include "Subsystems/Collector.h" #include "Subsystems/Elevator.h" @@ -10,13 +9,13 @@ #include "WPILib.h" class CommandBase: public Command { -public: - CommandBase(char const *name); - CommandBase(); - static void init(); - static Drivetrain *drivetrain; - static Collector *collector; - static Elevator *elevator; - static OI *oi; + public: + CommandBase(char const *name); + CommandBase(); + static void init(); + static Drivetrain *drivetrain; + static Collector *collector; + static Elevator *elevator; + static OI *oi; }; #endif diff --git a/src/Commands/Collect.cpp b/src/Commands/Collect.cpp index d07eadb..2ed8766 100644 --- a/src/Commands/Collect.cpp +++ b/src/Commands/Collect.cpp @@ -6,7 +6,7 @@ void Collect::Initialize(){ void Collect::Execute(){ } bool Collect::IsFinished(){ - return false; + return false; } void Collect::End(){ diff --git a/src/Commands/Collect.h b/src/Commands/Collect.h index fd25c8b..9851adc 100644 --- a/src/Commands/Collect.h +++ b/src/Commands/Collect.h @@ -5,13 +5,13 @@ #include "WPILib.h" class Collect: public CommandBase{ -public: - Collect(); - void Initialize(); - void Execute(); - bool IsFinished(); - void End(); - void Interrupted(); + public: + Collect(); + void Initialize(); + void Execute(); + bool IsFinished(); + void End(); + void Interrupted(); }; #endif diff --git a/src/Commands/Drive.cpp b/src/Commands/Drive.cpp index 034c2b8..e901aa6 100644 --- a/src/Commands/Drive.cpp +++ b/src/Commands/Drive.cpp @@ -6,7 +6,7 @@ void Drive::Initialize(){ void Drive::Execute(){ } bool Drive::IsFinished(){ - return false; + return false; } void Drive::End(){ diff --git a/src/Commands/Drive.h b/src/Commands/Drive.h index e9da98a..7d8e070 100644 --- a/src/Commands/Drive.h +++ b/src/Commands/Drive.h @@ -5,13 +5,13 @@ #include "WPILib.h" class Drive: public CommandBase{ -public: - Drive(); - void Initialize(); - void Execute(); - bool IsFinished(); - void End(); - void Interrupted(); + 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 a5b7f59..4ac7f59 100644 --- a/src/Commands/Eject.cpp +++ b/src/Commands/Eject.cpp @@ -6,7 +6,7 @@ void Eject::Initialize(){ void Eject::Execute(){ } bool Eject::IsFinished(){ - return false; + return false; } void Eject::End(){ diff --git a/src/Commands/Eject.h b/src/Commands/Eject.h index 9bbb8c7..8124c8c 100644 --- a/src/Commands/Eject.h +++ b/src/Commands/Eject.h @@ -5,13 +5,13 @@ #include "WPILib.h" class Eject: public CommandBase{ -public: - Eject(); - void Initialize(); - void Execute(); - bool IsFinished(); - void End(); - void Interrupted(); + public: + Eject(); + void Initialize(); + void Execute(); + bool IsFinished(); + void End(); + void Interrupted(); }; #endif diff --git a/src/Commands/Lower.cpp b/src/Commands/Lower.cpp index 0ef564d..8422fb1 100644 --- a/src/Commands/Lower.cpp +++ b/src/Commands/Lower.cpp @@ -6,7 +6,7 @@ void Lower::Initialize(){ void Lower::Execute(){ } bool Lower::IsFinished(){ - return false; + return false; } void Lower::End(){ diff --git a/src/Commands/Lower.h b/src/Commands/Lower.h index 1d5718b..5a58de1 100644 --- a/src/Commands/Lower.h +++ b/src/Commands/Lower.h @@ -5,13 +5,13 @@ #include "WPILib.h" class Lower: public CommandBase{ -public: - Lower(); - void Initialize(); - void Execute(); - bool IsFinished(); - void End(); - void Interrupted(); + public: + Lower(); + void Initialize(); + void Execute(); + bool IsFinished(); + void End(); + void Interrupted(); }; #endif diff --git a/src/Commands/Raise.cpp b/src/Commands/Raise.cpp index 0cf0cec..9eb7559 100644 --- a/src/Commands/Raise.cpp +++ b/src/Commands/Raise.cpp @@ -6,7 +6,7 @@ void Raise::Initialize(){ void Raise::Execute(){ } bool Raise::IsFinished(){ - return false; + return false; } void Raise::End(){ diff --git a/src/Commands/Raise.h b/src/Commands/Raise.h index 1eac77e..579ad22 100644 --- a/src/Commands/Raise.h +++ b/src/Commands/Raise.h @@ -5,13 +5,13 @@ #include "WPILib.h" class Raise: public CommandBase{ -public: - Raise(); - void Initialize(); - void Execute(); - bool IsFinished(); - void End(); - void Interrupted(); + public: + Raise(); + void Initialize(); + void Execute(); + bool IsFinished(); + void End(); + void Interrupted(); }; #endif diff --git a/src/OI.h b/src/OI.h index 51aef6e..01b5823 100644 --- a/src/OI.h +++ b/src/OI.h @@ -5,8 +5,8 @@ class OI { -private: -public: - OI(); + private: + public: + OI(); }; #endif diff --git a/src/Subsystems/Collector.h b/src/Subsystems/Collector.h index 717d8ba..c9026ce 100644 --- a/src/Subsystems/Collector.h +++ b/src/Subsystems/Collector.h @@ -4,9 +4,9 @@ #include "WPILib.h" class Collector: public Subsystem { -private: -public: - Collector(); - void InitDefaultCommand(); + private: + public: + Collector(); + void InitDefaultCommand(); }; #endif diff --git a/src/Subsystems/Drivetrain.h b/src/Subsystems/Drivetrain.h index 26613d7..1e5e039 100644 --- a/src/Subsystems/Drivetrain.h +++ b/src/Subsystems/Drivetrain.h @@ -4,9 +4,9 @@ #include "WPILib.h" class Drivetrain: public Subsystem { -private: -public: - Drivetrain(); - void InitDefaultCommand(); + private: + public: + Drivetrain(); + void InitDefaultCommand(); }; #endif diff --git a/src/Subsystems/Elevator.h b/src/Subsystems/Elevator.h index 0c7f33a..7c379e2 100644 --- a/src/Subsystems/Elevator.h +++ b/src/Subsystems/Elevator.h @@ -4,9 +4,9 @@ #include "WPILib.h" class Elevator: public Subsystem { -private: -public: - Elevator(); - void InitDefaultCommand(); + private: + public: + Elevator(); + void InitDefaultCommand(); }; #endif From 3dd19f8a5398ed88226e5b36b22267b95d8767b8 Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Fri, 16 Jan 2015 20:46:58 -0500 Subject: [PATCH 06/64] Added elevator code --- src/Subsystems/Elevator.cpp | 14 ++++++++++++-- src/Subsystems/Elevator.h | 8 +++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/Subsystems/Elevator.cpp b/src/Subsystems/Elevator.cpp index 20d6a5b..cf37a88 100644 --- a/src/Subsystems/Elevator.cpp +++ b/src/Subsystems/Elevator.cpp @@ -1,7 +1,17 @@ #include "Elevator.h" #include "../RobotMap.h" - -Elevator::Elevator() : Subsystem("Elevator") { +Elevator::Elevator() : PIDSubsystem("Elevator", kP_real, kI_real, 0.0){ + pot=new AnalogPotentiometer(0); + leftMotor=new Talon(1); + rightMotor=new Talon(0); + SetAbsoluteTolerance(0.004); } void Elevator::InitDefaultCommand() { } +float Elevator::GetPotValue(){ + return pot->Get(); +} +void Elevator::Run(double power){ + leftMotor->Set(power); + rightMotor->Set(power); +} diff --git a/src/Subsystems/Elevator.h b/src/Subsystems/Elevator.h index 7c379e2..2ed8c01 100644 --- a/src/Subsystems/Elevator.h +++ b/src/Subsystems/Elevator.h @@ -2,11 +2,17 @@ #define ELEVATOR_H #include "WPILib.h" -class Elevator: public Subsystem +#include "Commands/PIDSubsystem.h" +class Elevator: public PIDSubsystem { private: + AnalogPotentiometer *pot; + Talon *leftMotor, *rightMotor; + static constexpr double kP_real=4, kI_real=.0f, kP_simulation=18, kI_simulation=.2; public: Elevator(); void InitDefaultCommand(); + float GetPotValue(); + void Run(double); }; #endif From ade2ce7bfb4a25b4292849cfd366719be616aad1 Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Sat, 17 Jan 2015 10:34:08 -0500 Subject: [PATCH 07/64] Added drivetrain code --- src/Subsystems/Drivetrain.cpp | 11 +++++++++++ src/Subsystems/Drivetrain.h | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/src/Subsystems/Drivetrain.cpp b/src/Subsystems/Drivetrain.cpp index a99eb15..c152a4a 100644 --- a/src/Subsystems/Drivetrain.cpp +++ b/src/Subsystems/Drivetrain.cpp @@ -2,6 +2,17 @@ #include "../RobotMap.h" Drivetrain::Drivetrain() : Subsystem("Drivetrain") { + frontLeft=new Talon(0); + frontRight=new Talon(1); + backLeft=new Talon(2); + backRight=new Talon(3); + drive=new RobotDrive(frontLeft, frontRight, backLeft, backRight); } void Drivetrain::InitDefaultCommand() { } +void Drivetrain::DriveMecanum(float x, float y, float rotation){ + drive->MecanumDrive_Cartesian(x, y, rotation); +} +void Drivetrain::DriveArcade(float x, float y){ + drive->ArcadeDrive(x, y); +} diff --git a/src/Subsystems/Drivetrain.h b/src/Subsystems/Drivetrain.h index 1e5e039..84274b1 100644 --- a/src/Subsystems/Drivetrain.h +++ b/src/Subsystems/Drivetrain.h @@ -5,8 +5,12 @@ class Drivetrain: public Subsystem { private: + Talon *frontLeft, *frontRight, *backLeft, *backRight; + RobotDrive *drive; public: Drivetrain(); void InitDefaultCommand(); + void DriveMecanum(float, float, float); + void DriveArcade(float, float); }; #endif From 4c24ac320630cedb545c5ad03bb6377930cef039 Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Sat, 17 Jan 2015 12:21:16 -0500 Subject: [PATCH 08/64] Robot compiles (still untested) --- src/CommandBase.cpp | 1 - src/Commands/Drive.cpp | 15 --------------- src/Commands/Drive.h | 17 ----------------- src/Commands/Eject.cpp | 2 ++ src/DentRobot.cpp | 13 +++++++++---- src/DentRobot.h | 13 ++++++++----- src/Makefile | 27 +++++++++++++++++++++++++++ src/OI.cpp | 16 ++++++++++++++++ src/OI.h | 3 +++ src/Subsystems/Collector.cpp | 6 ++++++ src/Subsystems/Collector.h | 2 ++ src/Subsystems/Drivetrain.cpp | 4 ++-- src/Subsystems/Elevator.cpp | 7 ++++--- src/Subsystems/Elevator.h | 6 +++--- 14 files changed, 82 insertions(+), 50 deletions(-) delete mode 100644 src/Commands/Drive.cpp delete mode 100644 src/Commands/Drive.h create mode 100644 src/Makefile diff --git a/src/CommandBase.cpp b/src/CommandBase.cpp index 7c8c4d5..3d51e70 100644 --- a/src/CommandBase.cpp +++ b/src/CommandBase.cpp @@ -2,7 +2,6 @@ #include "Subsystems/Drivetrain.h" #include "Subsystems/Collector.h" #include "Subsystems/Elevator.h" -#include "Commands/Drive.h" #include "Commands/Collect.h" #include "Commands/Eject.h" #include "Commands/Raise.h" diff --git a/src/Commands/Drive.cpp b/src/Commands/Drive.cpp deleted file mode 100644 index e901aa6..0000000 --- a/src/Commands/Drive.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include "Drive.h" -Drive::Drive(){ -} -void Drive::Initialize(){ -} -void Drive::Execute(){ -} -bool Drive::IsFinished(){ - return false; -} -void Drive::End(){ - -} -void Drive::Interrupted(){ -} diff --git a/src/Commands/Drive.h b/src/Commands/Drive.h deleted file mode 100644 index 7d8e070..0000000 --- a/src/Commands/Drive.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef DRIVE_H -#define DRIVE_H - -#include "../CommandBase.h" -#include "WPILib.h" - -class Drive: public CommandBase{ - 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 4ac7f59..98fdf0d 100644 --- a/src/Commands/Eject.cpp +++ b/src/Commands/Eject.cpp @@ -1,9 +1,11 @@ #include "Eject.h" +#include "../DentRobot.h" Eject::Eject(){ } void Eject::Initialize(){ } void Eject::Execute(){ + DentRobot::collector->Set(oi->GetLeftStick()->GetThrottle()); } bool Eject::IsFinished(){ return false; diff --git a/src/DentRobot.cpp b/src/DentRobot.cpp index f34e638..ad9a71b 100644 --- a/src/DentRobot.cpp +++ b/src/DentRobot.cpp @@ -1,11 +1,16 @@ #include "DentRobot.h" -DentRobot::DentRobot(): - driveCommand(new Drive()){ +OI* DentRobot::oi=NULL; +Collector* DentRobot::collector=NULL; +Drivetrain* DentRobot::drivetrain=NULL; +Elevator* DentRobot::elevator=NULL; +DentRobot::DentRobot(){ + oi=new OI(); + collector=new Collector(); + drivetrain=new Drivetrain(); + elevator=new Elevator(); printf("Initialized"); } void DentRobot::RobotInit(){ - printf("Initializing"); - CommandBase::init(); } void DentRobot::DisabledPeriodic(){ Scheduler::GetInstance()->Run(); diff --git a/src/DentRobot.h b/src/DentRobot.h index 2ec1f47..cd88121 100644 --- a/src/DentRobot.h +++ b/src/DentRobot.h @@ -1,15 +1,18 @@ #ifndef DENTROBOT_H #define DENTROBOT_H #include "WPILib.h" -#include "Commands/Drive.h" -#include "Commands/Collect.h" -#include "Commands/Eject.h" -#include "Commands/Raise.h" -#include "Commands/Lower.h" +#include "OI.h" +#include "Subsystems/Elevator.h" +#include "Subsystems/Drivetrain.h" +#include "Subsystems/Collector.h" class DentRobot: public IterativeRobot { private: Command *driveCommand = NULL; public: + static OI* oi; + static Collector* collector; + static Drivetrain* drivetrain; + static Elevator* elevator; DentRobot(); void RobotInit(); void DisabledPeriodic(); diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000..a1c6857 --- /dev/null +++ b/src/Makefile @@ -0,0 +1,27 @@ +REMOTEIP=10.20.59.2 +CC=arm-frc-linux-gnueabi-g++ +CFLAGS=-std=c++11 -O0 -g3 -Wall -c -fmessage-length=0 +LDFLAGS=-Wl,-rpath,/opt/GenICam_v2_3/bin/Linux_armv7-a +SOURCES=$(shell find -type f -name "*.cpp") +OBJECTS=$(SOURCES:.cpp=.o) +WPILIB=/home/stonewareslord/Applications/vagrant/frc-cpp-vagrantfile/wpilib +EXEC=bin/FRCUserProgram +CLEANSER=rm -r + +all : $(OBJECTS) + $(CC) -L$(WPILIB)/lib $(LDFLAGS) -o $(EXEC) $(OBJECTS) -lwpi + +%.o : %.cpp + $(CC) $(CFLAGS) -I$(WPILIB)/include $^ -o $@ + +clean: + $(CLEANSER) $(OBJECTS) bin/FRCUserProgram + +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;/usr/local/frc/bin/frcKillRobot.sh -t -r' + +putkey: + @test -d ~/.ssh||mkdir ~/.ssh;test -f ~/.ssh/id_rsa||ssh-keygen -t rsa -f ~/.ssh/id_rsa -b 4096 -q -N '';cat ~/.ssh/id_rsa.pub|ssh -v admin@$(REMOTEIP) 'cat >> /tmp/key;mkdir -p ~/.ssh;cat /tmp/key >> ~/.ssh/authorized_keys;rm /tmp/key' + +updatemakefile: + @curl -s https://raw.githubusercontent.com/int0x191f2/nameless/master/configure.sh | sh diff --git a/src/OI.cpp b/src/OI.cpp index 8425006..dc5f0f2 100644 --- a/src/OI.cpp +++ b/src/OI.cpp @@ -1,4 +1,20 @@ #include "OI.h" +#include "Commands/Lower.h" +#include "Commands/Raise.h" +#include "Commands/Collect.h" +#include "Commands/Eject.h" OI::OI() { + leftStick=new Joystick(0); + rightStick=new Joystick(1); + JoystickButton *left10=new JoystickButton(leftStick, 10); + JoystickButton *left11=new JoystickButton(leftStick, 11); + left10->WhenPressed(new Eject()); + left11->WhenPressed(new Collect()); +} +Joystick* OI::GetRightStick(){ + return rightStick; +} +Joystick* OI::GetLeftStick(){ + return leftStick; } diff --git a/src/OI.h b/src/OI.h index 01b5823..e89ec0a 100644 --- a/src/OI.h +++ b/src/OI.h @@ -6,7 +6,10 @@ class OI { private: + Joystick *leftStick, *rightStick; public: OI(); + Joystick* GetRightStick(); + Joystick* GetLeftStick(); }; #endif diff --git a/src/Subsystems/Collector.cpp b/src/Subsystems/Collector.cpp index 443c99d..9180975 100644 --- a/src/Subsystems/Collector.cpp +++ b/src/Subsystems/Collector.cpp @@ -2,6 +2,12 @@ #include "../RobotMap.h" Collector::Collector() : Subsystem("Collector") { + motor1=new Talon(0); + motor2=new Talon(1); } void Collector::InitDefaultCommand() { } +void Collector::Set(float power){ + motor1->Set(power); + motor2->Set(power); +} diff --git a/src/Subsystems/Collector.h b/src/Subsystems/Collector.h index c9026ce..9308d15 100644 --- a/src/Subsystems/Collector.h +++ b/src/Subsystems/Collector.h @@ -5,8 +5,10 @@ class Collector: public Subsystem { private: + Talon *motor1, *motor2; public: Collector(); void InitDefaultCommand(); + void Set(float); }; #endif diff --git a/src/Subsystems/Drivetrain.cpp b/src/Subsystems/Drivetrain.cpp index c152a4a..da53fde 100644 --- a/src/Subsystems/Drivetrain.cpp +++ b/src/Subsystems/Drivetrain.cpp @@ -1,14 +1,14 @@ #include "Drivetrain.h" #include "../RobotMap.h" -Drivetrain::Drivetrain() : Subsystem("Drivetrain") { +Drivetrain::Drivetrain() : Subsystem("Drivetrain"){ frontLeft=new Talon(0); frontRight=new Talon(1); backLeft=new Talon(2); backRight=new Talon(3); drive=new RobotDrive(frontLeft, frontRight, backLeft, backRight); } -void Drivetrain::InitDefaultCommand() { +void Drivetrain::InitDefaultCommand(){ } void Drivetrain::DriveMecanum(float x, float y, float rotation){ drive->MecanumDrive_Cartesian(x, y, rotation); diff --git a/src/Subsystems/Elevator.cpp b/src/Subsystems/Elevator.cpp index cf37a88..2aa7368 100644 --- a/src/Subsystems/Elevator.cpp +++ b/src/Subsystems/Elevator.cpp @@ -1,12 +1,13 @@ #include "Elevator.h" #include "../RobotMap.h" -Elevator::Elevator() : PIDSubsystem("Elevator", kP_real, kI_real, 0.0){ +//Elevator::Elevator() : PIDSubsystem("Elevator", kP_real, kI_real, 0.0){ +Elevator::Elevator() : Subsystem("Elevator"){ pot=new AnalogPotentiometer(0); leftMotor=new Talon(1); rightMotor=new Talon(0); - SetAbsoluteTolerance(0.004); + //SetAbsoluteTolerance(0.004); } -void Elevator::InitDefaultCommand() { +void Elevator::InitDefaultCommand(){ } float Elevator::GetPotValue(){ return pot->Get(); diff --git a/src/Subsystems/Elevator.h b/src/Subsystems/Elevator.h index 2ed8c01..9108aa5 100644 --- a/src/Subsystems/Elevator.h +++ b/src/Subsystems/Elevator.h @@ -2,9 +2,9 @@ #define ELEVATOR_H #include "WPILib.h" -#include "Commands/PIDSubsystem.h" -class Elevator: public PIDSubsystem -{ +//#include "Commands/PIDSubsystem.h" +//class Elevator: public PIDSubsystem{ +class Elevator: public Subsystem{ private: AnalogPotentiometer *pot; Talon *leftMotor, *rightMotor; From 300dfaafc923685c47c3de4f0033db3bc4581165 Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Sat, 17 Jan 2015 12:55:51 -0500 Subject: [PATCH 09/64] 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); From 8d296a67187d3002867d09fb333a2c54468dda56 Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Sat, 17 Jan 2015 13:01:48 -0500 Subject: [PATCH 10/64] Ignore bin directory --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 12a4c4b..e62f2ae 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ *.o Debug +src/bin + From 6c62797e074702d9273afeb1aafbf0287a2aa57e Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Sat, 17 Jan 2015 13:28:27 -0500 Subject: [PATCH 11/64] Attempted writing Raise and Lower commands (untested) --- src/CommandBase.cpp | 2 +- src/Commands/Collect.cpp | 1 - src/Commands/Drive.cpp | 13 ++++++++++++- src/Commands/Eject.cpp | 1 - src/Commands/Lower.cpp | 8 ++++++-- src/Commands/Lower.h | 1 - src/Commands/Raise.cpp | 8 ++++++-- src/Subsystems/Elevator.cpp | 3 +-- src/Subsystems/Elevator.h | 5 ++--- 9 files changed, 28 insertions(+), 14 deletions(-) diff --git a/src/CommandBase.cpp b/src/CommandBase.cpp index 3d51e70..42344fb 100644 --- a/src/CommandBase.cpp +++ b/src/CommandBase.cpp @@ -2,6 +2,7 @@ #include "Subsystems/Drivetrain.h" #include "Subsystems/Collector.h" #include "Subsystems/Elevator.h" +#include "Commands/Drive.h" #include "Commands/Collect.h" #include "Commands/Eject.h" #include "Commands/Raise.h" @@ -21,4 +22,3 @@ void CommandBase::init() elevator = new Elevator(); oi = new OI(); } - diff --git a/src/Commands/Collect.cpp b/src/Commands/Collect.cpp index e863ff3..2ce95e3 100644 --- a/src/Commands/Collect.cpp +++ b/src/Commands/Collect.cpp @@ -9,7 +9,6 @@ bool Collect::IsFinished(){ return false; } void Collect::End(){ - } void Collect::Interrupted(){ } diff --git a/src/Commands/Drive.cpp b/src/Commands/Drive.cpp index 05ad2d1..f8f5a0f 100644 --- a/src/Commands/Drive.cpp +++ b/src/Commands/Drive.cpp @@ -1,11 +1,22 @@ #include "Drive.h" +#include #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)); + static float sens=0.7; + float x, y, twist; + x=DentRobot::oi->GetLeftStick()->GetRawAxis(0); + y=DentRobot::oi->GetLeftStick()->GetRawAxis(1); + twist=DentRobot::oi->GetLeftStick()->GetRawAxis(2); + if(true){ + x=sens*std::pow(x, 3)+(1.0f-sens)*x; + y=sens*std::pow(y, 3)+(1.0f-sens)*y; + } + //DentRobot::drivetrain->DriveMecanum(DentRobot::oi->GetLeftStick()->GetRawAxis(2), DentRobot::oi->GetLeftStick()->GetRawAxis(1), DentRobot::oi->GetLeftStick()->GetRawAxis(0)); + DentRobot::drivetrain->DriveMecanum(x, y, twist); } bool Drive::IsFinished(){ return false; diff --git a/src/Commands/Eject.cpp b/src/Commands/Eject.cpp index 0e72eea..f94ae8a 100644 --- a/src/Commands/Eject.cpp +++ b/src/Commands/Eject.cpp @@ -12,7 +12,6 @@ bool Eject::IsFinished(){ return false; } void Eject::End(){ - } void Eject::Interrupted(){ } diff --git a/src/Commands/Lower.cpp b/src/Commands/Lower.cpp index d16cd09..b30b0c8 100644 --- a/src/Commands/Lower.cpp +++ b/src/Commands/Lower.cpp @@ -1,15 +1,19 @@ #include "Lower.h" +#include "../DentRobot.h" Lower::Lower() : Command("Lower"){ } void Lower::Initialize(){ } void Lower::Execute(){ + DentRobot::elevator->Run(-0.4f); } bool Lower::IsFinished(){ - return false; + // 0.1f is a placeholder for the min elevator value + return DentRobot::elevator->GetPotValue()>=0.1f; } void Lower::End(){ - + DentRobot::elevator->Run(0.0f); } void Lower::Interrupted(){ + End(); } diff --git a/src/Commands/Lower.h b/src/Commands/Lower.h index 68be397..1f39059 100644 --- a/src/Commands/Lower.h +++ b/src/Commands/Lower.h @@ -13,5 +13,4 @@ class Lower: public Command{ void End(); void Interrupted(); }; - #endif diff --git a/src/Commands/Raise.cpp b/src/Commands/Raise.cpp index 9eb7559..2d6dd30 100644 --- a/src/Commands/Raise.cpp +++ b/src/Commands/Raise.cpp @@ -1,15 +1,19 @@ #include "Raise.h" +#include "../DentRobot.h" Raise::Raise(){ } void Raise::Initialize(){ } void Raise::Execute(){ + DentRobot::elevator->Run(0.4f); } bool Raise::IsFinished(){ - return false; + // 0.9f is a placeholder for the max elevator value + return DentRobot::elevator->GetPotValue()>=0.9f; } void Raise::End(){ - + DentRobot::elevator->Run(0.0f); } void Raise::Interrupted(){ + End(); } diff --git a/src/Subsystems/Elevator.cpp b/src/Subsystems/Elevator.cpp index 2aa7368..490cc7c 100644 --- a/src/Subsystems/Elevator.cpp +++ b/src/Subsystems/Elevator.cpp @@ -1,7 +1,6 @@ #include "Elevator.h" #include "../RobotMap.h" -//Elevator::Elevator() : PIDSubsystem("Elevator", kP_real, kI_real, 0.0){ -Elevator::Elevator() : Subsystem("Elevator"){ +Elevator::Elevator() : PIDSubsystem("Elevator", kP_real, kI_real, 0.0){ pot=new AnalogPotentiometer(0); leftMotor=new Talon(1); rightMotor=new Talon(0); diff --git a/src/Subsystems/Elevator.h b/src/Subsystems/Elevator.h index 9108aa5..d80ddd0 100644 --- a/src/Subsystems/Elevator.h +++ b/src/Subsystems/Elevator.h @@ -2,9 +2,8 @@ #define ELEVATOR_H #include "WPILib.h" -//#include "Commands/PIDSubsystem.h" -//class Elevator: public PIDSubsystem{ -class Elevator: public Subsystem{ +#include "Commands/PIDSubsystem.h" +class Elevator: public PIDSubsystem{ private: AnalogPotentiometer *pot; Talon *leftMotor, *rightMotor; From f336874a29fab21dcb5d52e5419ce4a479a5a931 Mon Sep 17 00:00:00 2001 From: Adam Long Date: Sun, 18 Jan 2015 14:03:41 +0000 Subject: [PATCH 12/64] it kinda works sorta maybe --- src/Commands/Drive.cpp | 1 + src/Commands/Drive.h | 2 ++ src/Subsystems/Drivetrain.cpp | 8 ++++---- src/Subsystems/Drivetrain.h | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Commands/Drive.cpp b/src/Commands/Drive.cpp index 05ad2d1..3320949 100644 --- a/src/Commands/Drive.cpp +++ b/src/Commands/Drive.cpp @@ -1,6 +1,7 @@ #include "Drive.h" #include "../DentRobot.h" Drive::Drive() : Command("Drive"){ + Requires(DentRobot::drivetrain); } void Drive::Initialize(){ } diff --git a/src/Commands/Drive.h b/src/Commands/Drive.h index 8254d17..258cbc1 100644 --- a/src/Commands/Drive.h +++ b/src/Commands/Drive.h @@ -1,6 +1,8 @@ #ifndef DRIVE_H #define DRIVE_H +#include "../CommandBase.h" +#include "../DentRobot.h" #include "Commands/Command.h" #include "WPILib.h" diff --git a/src/Subsystems/Drivetrain.cpp b/src/Subsystems/Drivetrain.cpp index be9878c..cfbf5bf 100644 --- a/src/Subsystems/Drivetrain.cpp +++ b/src/Subsystems/Drivetrain.cpp @@ -3,10 +3,10 @@ #include "../Commands/Drive.h" Drivetrain::Drivetrain() : Subsystem("Drivetrain"){ - frontLeft=new Talon(0); - frontRight=new Talon(1); - backLeft=new Talon(2); - backRight=new Talon(3); + frontLeft=new CANTalon(40); + frontRight=new CANTalon(41); + backLeft=new CANTalon(42); + backRight=new CANTalon(43); drive=new RobotDrive(frontLeft, frontRight, backLeft, backRight); } void Drivetrain::InitDefaultCommand(){ diff --git a/src/Subsystems/Drivetrain.h b/src/Subsystems/Drivetrain.h index 84274b1..d4b1a6c 100644 --- a/src/Subsystems/Drivetrain.h +++ b/src/Subsystems/Drivetrain.h @@ -5,7 +5,7 @@ class Drivetrain: public Subsystem { private: - Talon *frontLeft, *frontRight, *backLeft, *backRight; + CANTalon *frontLeft, *frontRight, *backLeft, *backRight; RobotDrive *drive; public: Drivetrain(); From d61da0b43678ec3eea55c2545cdd2e07ce351889 Mon Sep 17 00:00:00 2001 From: Adam Long Date: Mon, 19 Jan 2015 17:08:25 +0000 Subject: [PATCH 13/64] Fixed the driving --- src/Commands/Drive.cpp | 25 +++++++++++++++---------- src/Subsystems/Drivetrain.cpp | 23 +++++++++++++---------- src/Subsystems/Drivetrain.h | 4 ++-- src/Subsystems/Elevator.cpp | 2 +- src/Subsystems/Elevator.h | 2 +- src/hhlib | 1 + 6 files changed, 33 insertions(+), 24 deletions(-) create mode 160000 src/hhlib diff --git a/src/Commands/Drive.cpp b/src/Commands/Drive.cpp index fd136b0..d4dfdbd 100644 --- a/src/Commands/Drive.cpp +++ b/src/Commands/Drive.cpp @@ -7,17 +7,22 @@ Drive::Drive() : Command("Drive"){ void Drive::Initialize(){ } void Drive::Execute(){ - static float sens=0.7; - float x, y, twist; - x=DentRobot::oi->GetLeftStick()->GetRawAxis(0); - y=DentRobot::oi->GetLeftStick()->GetRawAxis(1); - twist=DentRobot::oi->GetLeftStick()->GetRawAxis(2); - if(true){ - x=sens*std::pow(x, 3)+(1.0f-sens)*x; - y=sens*std::pow(y, 3)+(1.0f-sens)*y; + double x,y,z; + //Code to lock the x axis when not holding button 1 + if (DentRobot::oi->GetLeftStick()->GetRawButton(1)){ + x = DentRobot::oi->GetLeftStick()->GetRawAxis(0); + x /= 1.3; + }else{ + x = 0; } - //DentRobot::drivetrain->DriveMecanum(DentRobot::oi->GetLeftStick()->GetRawAxis(2), DentRobot::oi->GetLeftStick()->GetRawAxis(1), DentRobot::oi->GetLeftStick()->GetRawAxis(0)); - DentRobot::drivetrain->DriveMecanum(x, y, twist); + z = DentRobot::oi->GetLeftStick()->GetRawAxis(2); + y = DentRobot::oi->GetLeftStick()->GetRawAxis(1); + 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); } bool Drive::IsFinished(){ return false; diff --git a/src/Subsystems/Drivetrain.cpp b/src/Subsystems/Drivetrain.cpp index cfbf5bf..e9fc379 100644 --- a/src/Subsystems/Drivetrain.cpp +++ b/src/Subsystems/Drivetrain.cpp @@ -3,18 +3,21 @@ #include "../Commands/Drive.h" Drivetrain::Drivetrain() : Subsystem("Drivetrain"){ - frontLeft=new CANTalon(40); - frontRight=new CANTalon(41); - backLeft=new CANTalon(42); - backRight=new CANTalon(43); - drive=new RobotDrive(frontLeft, frontRight, backLeft, backRight); + rightFront = new CANTalon(40); + leftFront = new CANTalon(41); + rightRear = new CANTalon(42); + leftRear = new CANTalon(43); } void Drivetrain::InitDefaultCommand(){ SetDefaultCommand(new Drive()); } -void Drivetrain::DriveMecanum(float x, float y, float rotation){ - drive->MecanumDrive_Cartesian(x, y, rotation); -} -void Drivetrain::DriveArcade(float x, float y){ - drive->ArcadeDrive(x, y); +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 slowfactor = 2.5; + rightFront->Set((-correctX + correctY - correctZ)); + leftFront->Set((correctX + correctY + correctZ)*-1); + rightRear->Set((correctX + correctY - correctZ)); + leftRear->Set((-correctX + correctY + correctZ)*-1); } diff --git a/src/Subsystems/Drivetrain.h b/src/Subsystems/Drivetrain.h index d4b1a6c..bdf3f70 100644 --- a/src/Subsystems/Drivetrain.h +++ b/src/Subsystems/Drivetrain.h @@ -5,12 +5,12 @@ class Drivetrain: public Subsystem { private: - CANTalon *frontLeft, *frontRight, *backLeft, *backRight; + CANTalon *rightFront, *leftFront, *rightRear, *leftRear; RobotDrive *drive; public: Drivetrain(); void InitDefaultCommand(); - void DriveMecanum(float, float, float); + void DriveMecanum(float,float,float,float,float); void DriveArcade(float, float); }; #endif diff --git a/src/Subsystems/Elevator.cpp b/src/Subsystems/Elevator.cpp index 490cc7c..20261b5 100644 --- a/src/Subsystems/Elevator.cpp +++ b/src/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()/* : PIDSubsystem("Elevator", kP_real, kI_real, 0.0)*/{ pot=new AnalogPotentiometer(0); leftMotor=new Talon(1); rightMotor=new Talon(0); diff --git a/src/Subsystems/Elevator.h b/src/Subsystems/Elevator.h index d80ddd0..e54d719 100644 --- a/src/Subsystems/Elevator.h +++ b/src/Subsystems/Elevator.h @@ -3,7 +3,7 @@ #include "WPILib.h" #include "Commands/PIDSubsystem.h" -class Elevator: public PIDSubsystem{ +class Elevator/*: public PIDSubsystem*/{ private: AnalogPotentiometer *pot; Talon *leftMotor, *rightMotor; diff --git a/src/hhlib b/src/hhlib new file mode 160000 index 0000000..181fb15 --- /dev/null +++ b/src/hhlib @@ -0,0 +1 @@ +Subproject commit 181fb1556d4cc96daa430bfce0fb6ce26c7c90c9 From 8744869328fe616c932194c40854e8df0a443d73 Mon Sep 17 00:00:00 2001 From: Adam Long Date: Tue, 20 Jan 2015 12:02:46 +0000 Subject: [PATCH 14/64] Added basic compressor support --- src/CommandBase.cpp | 3 +++ src/CommandBase.h | 2 ++ src/Commands/Compress.cpp | 18 ++++++++++++++++++ src/Commands/Compress.h | 18 ++++++++++++++++++ src/DentRobot.cpp | 2 ++ src/DentRobot.h | 2 ++ src/Subsystems/AirCompressor.cpp | 14 ++++++++++++++ src/Subsystems/AirCompressor.h | 15 +++++++++++++++ src/Subsystems/Drivetrain.cpp | 1 - 9 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 src/Commands/Compress.cpp create mode 100644 src/Commands/Compress.h create mode 100644 src/Subsystems/AirCompressor.cpp create mode 100644 src/Subsystems/AirCompressor.h diff --git a/src/CommandBase.cpp b/src/CommandBase.cpp index 42344fb..5470252 100644 --- a/src/CommandBase.cpp +++ b/src/CommandBase.cpp @@ -2,6 +2,7 @@ #include "Subsystems/Drivetrain.h" #include "Subsystems/Collector.h" #include "Subsystems/Elevator.h" +#include "Subsystems/AirCompressor.h" #include "Commands/Drive.h" #include "Commands/Collect.h" #include "Commands/Eject.h" @@ -10,6 +11,7 @@ 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) { } @@ -20,5 +22,6 @@ void CommandBase::init() drivetrain = new Drivetrain(); collector = new Collector(); elevator = new Elevator(); + airCompressor = new AirCompressor(); oi = new OI(); } diff --git a/src/CommandBase.h b/src/CommandBase.h index a0e5d05..e6891d1 100644 --- a/src/CommandBase.h +++ b/src/CommandBase.h @@ -5,6 +5,7 @@ #include "Subsystems/Drivetrain.h" #include "Subsystems/Collector.h" #include "Subsystems/Elevator.h" +#include "Subsystems/AirCompressor.h" #include "OI.h" #include "WPILib.h" @@ -16,6 +17,7 @@ class CommandBase: public Command { static Drivetrain *drivetrain; static Collector *collector; static Elevator *elevator; + static AirCompressor *airCompressor; static OI *oi; }; #endif diff --git a/src/Commands/Compress.cpp b/src/Commands/Compress.cpp new file mode 100644 index 0000000..92f0e8e --- /dev/null +++ b/src/Commands/Compress.cpp @@ -0,0 +1,18 @@ +#include "Compress.h" +#include +#include "../DentRobot.h" +Compress::Compress() : Command("Compress"){ + Requires(DentRobot::airCompressor); +} +void Compress::Initialize(){ +} +void Compress::Execute(){ + DentRobot::airCompressor->CreateCompressedAir(); +} +bool Compress::IsFinished(){ + return false; +} +void Compress::End(){ +} +void Compress::Interrupted(){ +} diff --git a/src/Commands/Compress.h b/src/Commands/Compress.h new file mode 100644 index 0000000..89a440c --- /dev/null +++ b/src/Commands/Compress.h @@ -0,0 +1,18 @@ +#ifndef COMPRESSOR_H +#define COMPRESSOR_H + +#include "../CommandBase.h" +#include "../DentRobot.h" +#include "Commands/Command.h" +#include "WPILib.h" + +class Compress: public Command{ + public: + Compress(); + void Initialize(); + void Execute(); + bool IsFinished(); + void End(); + void Interrupted(); +}; +#endif diff --git a/src/DentRobot.cpp b/src/DentRobot.cpp index ad9a71b..3861d86 100644 --- a/src/DentRobot.cpp +++ b/src/DentRobot.cpp @@ -3,11 +3,13 @@ OI* DentRobot::oi=NULL; Collector* DentRobot::collector=NULL; Drivetrain* DentRobot::drivetrain=NULL; Elevator* DentRobot::elevator=NULL; +AirCompressor * DentRobot::airCompressor=NULL; DentRobot::DentRobot(){ oi=new OI(); collector=new Collector(); drivetrain=new Drivetrain(); elevator=new Elevator(); + airCompressor=new AirCompressor(); printf("Initialized"); } void DentRobot::RobotInit(){ diff --git a/src/DentRobot.h b/src/DentRobot.h index cd88121..e111c83 100644 --- a/src/DentRobot.h +++ b/src/DentRobot.h @@ -5,6 +5,7 @@ #include "Subsystems/Elevator.h" #include "Subsystems/Drivetrain.h" #include "Subsystems/Collector.h" +#include "Subsystems/AirCompressor.h" class DentRobot: public IterativeRobot { private: Command *driveCommand = NULL; @@ -13,6 +14,7 @@ public: static Collector* collector; static Drivetrain* drivetrain; static Elevator* elevator; + static AirCompressor* airCompressor; DentRobot(); void RobotInit(); void DisabledPeriodic(); diff --git a/src/Subsystems/AirCompressor.cpp b/src/Subsystems/AirCompressor.cpp new file mode 100644 index 0000000..f8738f9 --- /dev/null +++ b/src/Subsystems/AirCompressor.cpp @@ -0,0 +1,14 @@ +#include "AirCompressor.h" +#include "../RobotMap.h" + +AirCompressor::AirCompressor() : Subsystem("AirCompressor") { + compressher = new Compressor(31); +} +void AirCompressor::InitDefaultCommand() { +} +void AirCompressor::CreateCompressedAir() { + compressher->Start(); +} +void AirCompressor::StopCreatingCompressedAir() { + compressher->Stop(); +} diff --git a/src/Subsystems/AirCompressor.h b/src/Subsystems/AirCompressor.h new file mode 100644 index 0000000..e997c27 --- /dev/null +++ b/src/Subsystems/AirCompressor.h @@ -0,0 +1,15 @@ +#ifndef AIRCOMPRESSOR_H +#define AIRCOMPRESSOR_H + +#include "WPILib.h" +class AirCompressor: public Subsystem +{ + private: + Compressor *compressher; + public: + AirCompressor(); + void InitDefaultCommand(); + void CreateCompressedAir(); + void StopCreatingCompressedAir(); +}; +#endif diff --git a/src/Subsystems/Drivetrain.cpp b/src/Subsystems/Drivetrain.cpp index e9fc379..17f690c 100644 --- a/src/Subsystems/Drivetrain.cpp +++ b/src/Subsystems/Drivetrain.cpp @@ -15,7 +15,6 @@ 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; - double slowfactor = 2.5; rightFront->Set((-correctX + correctY - correctZ)); leftFront->Set((correctX + correctY + correctZ)*-1); rightRear->Set((correctX + correctY - correctZ)); From adc97fbb48b41dd8cecd6d594e20381c43164450 Mon Sep 17 00:00:00 2001 From: Adam Long Date: Sun, 25 Jan 2015 15:13:53 +0000 Subject: [PATCH 15/64] Fixed makefile kinda --- src/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Makefile b/src/Makefile index a1c6857..44d0e3b 100644 --- a/src/Makefile +++ b/src/Makefile @@ -4,7 +4,7 @@ CFLAGS=-std=c++11 -O0 -g3 -Wall -c -fmessage-length=0 LDFLAGS=-Wl,-rpath,/opt/GenICam_v2_3/bin/Linux_armv7-a SOURCES=$(shell find -type f -name "*.cpp") OBJECTS=$(SOURCES:.cpp=.o) -WPILIB=/home/stonewareslord/Applications/vagrant/frc-cpp-vagrantfile/wpilib +WPILIB=/var/frc/wpilib EXEC=bin/FRCUserProgram CLEANSER=rm -r @@ -18,7 +18,7 @@ clean: $(CLEANSER) $(OBJECTS) bin/FRCUserProgram 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;/usr/local/frc/bin/frcKillRobot.sh -t -r' + @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: @test -d ~/.ssh||mkdir ~/.ssh;test -f ~/.ssh/id_rsa||ssh-keygen -t rsa -f ~/.ssh/id_rsa -b 4096 -q -N '';cat ~/.ssh/id_rsa.pub|ssh -v admin@$(REMOTEIP) 'cat >> /tmp/key;mkdir -p ~/.ssh;cat /tmp/key >> ~/.ssh/authorized_keys;rm /tmp/key' From e496f313df6eb3c420dec8243a7c9c166c37ba2a Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Sun, 25 Jan 2015 08:46:48 -0500 Subject: [PATCH 16/64] Removed src folder --- src/CommandBase.cpp => CommandBase.cpp | 0 src/CommandBase.h => CommandBase.h | 0 {src/Commands => Commands}/Collect.cpp | 0 {src/Commands => Commands}/Collect.h | 0 {src/Commands => Commands}/Compress.cpp | 0 {src/Commands => Commands}/Compress.h | 0 {src/Commands => Commands}/Drive.cpp | 0 {src/Commands => Commands}/Drive.h | 0 {src/Commands => Commands}/Eject.cpp | 0 {src/Commands => Commands}/Eject.h | 0 {src/Commands => Commands}/Lower.cpp | 0 {src/Commands => Commands}/Lower.h | 0 {src/Commands => Commands}/Raise.cpp | 0 {src/Commands => Commands}/Raise.h | 0 src/DentRobot.cpp => DentRobot.cpp | 0 src/DentRobot.h => DentRobot.h | 0 src/Makefile => Makefile | 0 src/OI.cpp => OI.cpp | 0 src/OI.h => OI.h | 0 src/RobotMap.h => RobotMap.h | 0 {src/Subsystems => Subsystems}/AirCompressor.cpp | 0 {src/Subsystems => Subsystems}/AirCompressor.h | 0 {src/Subsystems => Subsystems}/Collector.cpp | 0 {src/Subsystems => Subsystems}/Collector.h | 0 {src/Subsystems => Subsystems}/Drivetrain.cpp | 0 {src/Subsystems => Subsystems}/Drivetrain.h | 0 {src/Subsystems => Subsystems}/Elevator.cpp | 0 {src/Subsystems => Subsystems}/Elevator.h | 0 src/hhlib | 1 - 29 files changed, 1 deletion(-) rename src/CommandBase.cpp => CommandBase.cpp (100%) rename src/CommandBase.h => CommandBase.h (100%) rename {src/Commands => Commands}/Collect.cpp (100%) rename {src/Commands => Commands}/Collect.h (100%) rename {src/Commands => Commands}/Compress.cpp (100%) rename {src/Commands => Commands}/Compress.h (100%) rename {src/Commands => Commands}/Drive.cpp (100%) rename {src/Commands => Commands}/Drive.h (100%) rename {src/Commands => Commands}/Eject.cpp (100%) rename {src/Commands => Commands}/Eject.h (100%) rename {src/Commands => Commands}/Lower.cpp (100%) rename {src/Commands => Commands}/Lower.h (100%) rename {src/Commands => Commands}/Raise.cpp (100%) rename {src/Commands => Commands}/Raise.h (100%) rename src/DentRobot.cpp => DentRobot.cpp (100%) rename src/DentRobot.h => DentRobot.h (100%) rename src/Makefile => Makefile (100%) rename src/OI.cpp => OI.cpp (100%) rename src/OI.h => OI.h (100%) rename src/RobotMap.h => RobotMap.h (100%) rename {src/Subsystems => Subsystems}/AirCompressor.cpp (100%) rename {src/Subsystems => Subsystems}/AirCompressor.h (100%) rename {src/Subsystems => Subsystems}/Collector.cpp (100%) rename {src/Subsystems => Subsystems}/Collector.h (100%) rename {src/Subsystems => Subsystems}/Drivetrain.cpp (100%) rename {src/Subsystems => Subsystems}/Drivetrain.h (100%) rename {src/Subsystems => Subsystems}/Elevator.cpp (100%) rename {src/Subsystems => Subsystems}/Elevator.h (100%) delete mode 160000 src/hhlib diff --git a/src/CommandBase.cpp b/CommandBase.cpp similarity index 100% rename from src/CommandBase.cpp rename to CommandBase.cpp diff --git a/src/CommandBase.h b/CommandBase.h similarity index 100% rename from src/CommandBase.h rename to CommandBase.h diff --git a/src/Commands/Collect.cpp b/Commands/Collect.cpp similarity index 100% rename from src/Commands/Collect.cpp rename to Commands/Collect.cpp diff --git a/src/Commands/Collect.h b/Commands/Collect.h similarity index 100% rename from src/Commands/Collect.h rename to Commands/Collect.h diff --git a/src/Commands/Compress.cpp b/Commands/Compress.cpp similarity index 100% rename from src/Commands/Compress.cpp rename to Commands/Compress.cpp diff --git a/src/Commands/Compress.h b/Commands/Compress.h similarity index 100% rename from src/Commands/Compress.h rename to Commands/Compress.h diff --git a/src/Commands/Drive.cpp b/Commands/Drive.cpp similarity index 100% rename from src/Commands/Drive.cpp rename to Commands/Drive.cpp diff --git a/src/Commands/Drive.h b/Commands/Drive.h similarity index 100% rename from src/Commands/Drive.h rename to Commands/Drive.h diff --git a/src/Commands/Eject.cpp b/Commands/Eject.cpp similarity index 100% rename from src/Commands/Eject.cpp rename to Commands/Eject.cpp diff --git a/src/Commands/Eject.h b/Commands/Eject.h similarity index 100% rename from src/Commands/Eject.h rename to Commands/Eject.h diff --git a/src/Commands/Lower.cpp b/Commands/Lower.cpp similarity index 100% rename from src/Commands/Lower.cpp rename to Commands/Lower.cpp diff --git a/src/Commands/Lower.h b/Commands/Lower.h similarity index 100% rename from src/Commands/Lower.h rename to Commands/Lower.h diff --git a/src/Commands/Raise.cpp b/Commands/Raise.cpp similarity index 100% rename from src/Commands/Raise.cpp rename to Commands/Raise.cpp diff --git a/src/Commands/Raise.h b/Commands/Raise.h similarity index 100% rename from src/Commands/Raise.h rename to Commands/Raise.h diff --git a/src/DentRobot.cpp b/DentRobot.cpp similarity index 100% rename from src/DentRobot.cpp rename to DentRobot.cpp diff --git a/src/DentRobot.h b/DentRobot.h similarity index 100% rename from src/DentRobot.h rename to DentRobot.h diff --git a/src/Makefile b/Makefile similarity index 100% rename from src/Makefile rename to Makefile diff --git a/src/OI.cpp b/OI.cpp similarity index 100% rename from src/OI.cpp rename to OI.cpp diff --git a/src/OI.h b/OI.h similarity index 100% rename from src/OI.h rename to OI.h diff --git a/src/RobotMap.h b/RobotMap.h similarity index 100% rename from src/RobotMap.h rename to RobotMap.h diff --git a/src/Subsystems/AirCompressor.cpp b/Subsystems/AirCompressor.cpp similarity index 100% rename from src/Subsystems/AirCompressor.cpp rename to Subsystems/AirCompressor.cpp diff --git a/src/Subsystems/AirCompressor.h b/Subsystems/AirCompressor.h similarity index 100% rename from src/Subsystems/AirCompressor.h rename to Subsystems/AirCompressor.h diff --git a/src/Subsystems/Collector.cpp b/Subsystems/Collector.cpp similarity index 100% rename from src/Subsystems/Collector.cpp rename to Subsystems/Collector.cpp diff --git a/src/Subsystems/Collector.h b/Subsystems/Collector.h similarity index 100% rename from src/Subsystems/Collector.h rename to Subsystems/Collector.h diff --git a/src/Subsystems/Drivetrain.cpp b/Subsystems/Drivetrain.cpp similarity index 100% rename from src/Subsystems/Drivetrain.cpp rename to Subsystems/Drivetrain.cpp diff --git a/src/Subsystems/Drivetrain.h b/Subsystems/Drivetrain.h similarity index 100% rename from src/Subsystems/Drivetrain.h rename to Subsystems/Drivetrain.h diff --git a/src/Subsystems/Elevator.cpp b/Subsystems/Elevator.cpp similarity index 100% rename from src/Subsystems/Elevator.cpp rename to Subsystems/Elevator.cpp diff --git a/src/Subsystems/Elevator.h b/Subsystems/Elevator.h similarity index 100% rename from src/Subsystems/Elevator.h rename to Subsystems/Elevator.h diff --git a/src/hhlib b/src/hhlib deleted file mode 160000 index 181fb15..0000000 --- a/src/hhlib +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 181fb1556d4cc96daa430bfce0fb6ce26c7c90c9 From b4b54ee5e786af43692358093044bb4443ea33de Mon Sep 17 00:00:00 2001 From: Adam Long Date: Thu, 29 Jan 2015 19:53:11 +0000 Subject: [PATCH 17/64] Added compressor stopping. kinda works --- Commands/Compress.cpp | 18 ------------------ Commands/Compress.h | 18 ------------------ Commands/Compressor/StartCompressing.cpp | 18 ++++++++++++++++++ Commands/Compressor/StartCompressing.h | 18 ++++++++++++++++++ Commands/Compressor/StopCompressing.cpp | 18 ++++++++++++++++++ Commands/Compressor/StopCompressing.h | 18 ++++++++++++++++++ Makefile | 3 +++ OI.cpp | 2 ++ Subsystems/AirCompressor.cpp | 8 ++++++-- Subsystems/AirCompressor.h | 4 ++-- 10 files changed, 85 insertions(+), 40 deletions(-) delete mode 100644 Commands/Compress.cpp delete mode 100644 Commands/Compress.h create mode 100644 Commands/Compressor/StartCompressing.cpp create mode 100644 Commands/Compressor/StartCompressing.h create mode 100644 Commands/Compressor/StopCompressing.cpp create mode 100644 Commands/Compressor/StopCompressing.h diff --git a/Commands/Compress.cpp b/Commands/Compress.cpp deleted file mode 100644 index 92f0e8e..0000000 --- a/Commands/Compress.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "Compress.h" -#include -#include "../DentRobot.h" -Compress::Compress() : Command("Compress"){ - Requires(DentRobot::airCompressor); -} -void Compress::Initialize(){ -} -void Compress::Execute(){ - DentRobot::airCompressor->CreateCompressedAir(); -} -bool Compress::IsFinished(){ - return false; -} -void Compress::End(){ -} -void Compress::Interrupted(){ -} diff --git a/Commands/Compress.h b/Commands/Compress.h deleted file mode 100644 index 89a440c..0000000 --- a/Commands/Compress.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef COMPRESSOR_H -#define COMPRESSOR_H - -#include "../CommandBase.h" -#include "../DentRobot.h" -#include "Commands/Command.h" -#include "WPILib.h" - -class Compress: public Command{ - public: - Compress(); - void Initialize(); - void Execute(); - bool IsFinished(); - void End(); - void Interrupted(); -}; -#endif diff --git a/Commands/Compressor/StartCompressing.cpp b/Commands/Compressor/StartCompressing.cpp new file mode 100644 index 0000000..8e3b047 --- /dev/null +++ b/Commands/Compressor/StartCompressing.cpp @@ -0,0 +1,18 @@ +#include "StartCompressing.h" +#include +#include "../../DentRobot.h" +StartCompressing::StartCompressing() : Command("StartCompressing"){ + Requires(DentRobot::airCompressor); +} +void StartCompressing::Initialize(){ +} +void StartCompressing::Execute(){ + DentRobot::airCompressor->CreateCompressedAir(); +} +bool StartCompressing::IsFinished(){ + return false; +} +void StartCompressing::End(){ +} +void StartCompressing::Interrupted(){ +} diff --git a/Commands/Compressor/StartCompressing.h b/Commands/Compressor/StartCompressing.h new file mode 100644 index 0000000..8e503ee --- /dev/null +++ b/Commands/Compressor/StartCompressing.h @@ -0,0 +1,18 @@ +#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 new file mode 100644 index 0000000..7d2120a --- /dev/null +++ b/Commands/Compressor/StopCompressing.cpp @@ -0,0 +1,18 @@ +#include "StopCompressing.h" +#include +#include "../../DentRobot.h" +StopCompressing::StopCompressing() : Command("StopCompressing"){ + Requires(DentRobot::airCompressor); +} +void StopCompressing::Initialize(){ +} +void StopCompressing::Execute(){ + DentRobot::airCompressor->StopCreatingCompressedAir(); +} +bool StopCompressing::IsFinished(){ + return false; +} +void StopCompressing::End(){ +} +void StopCompressing::Interrupted(){ +} diff --git a/Commands/Compressor/StopCompressing.h b/Commands/Compressor/StopCompressing.h new file mode 100644 index 0000000..7d5c27c --- /dev/null +++ b/Commands/Compressor/StopCompressing.h @@ -0,0 +1,18 @@ +#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/Makefile b/Makefile index 44d0e3b..0eee4bc 100644 --- a/Makefile +++ b/Makefile @@ -18,6 +18,9 @@ clean: $(CLEANSER) $(OBJECTS) bin/FRCUserProgram 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: @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: diff --git a/OI.cpp b/OI.cpp index dc5f0f2..3af8941 100644 --- a/OI.cpp +++ b/OI.cpp @@ -3,6 +3,8 @@ #include "Commands/Raise.h" #include "Commands/Collect.h" #include "Commands/Eject.h" +#include "Commands/Compressor/StartCompressing.h" +#include "Commands/Compressor/StopCompressing.h" OI::OI() { leftStick=new Joystick(0); diff --git a/Subsystems/AirCompressor.cpp b/Subsystems/AirCompressor.cpp index f8738f9..cda5a76 100644 --- a/Subsystems/AirCompressor.cpp +++ b/Subsystems/AirCompressor.cpp @@ -6,9 +6,13 @@ AirCompressor::AirCompressor() : Subsystem("AirCompressor") { } void AirCompressor::InitDefaultCommand() { } -void AirCompressor::CreateCompressedAir() { +int AirCompressor::CreateCompressedAir() { + printf("compressing and stuff\n"); compressher->Start(); + return 0; } -void AirCompressor::StopCreatingCompressedAir() { +int AirCompressor::StopCreatingCompressedAir() { + printf("not compressing and stuff\n"); compressher->Stop(); + return 0; } diff --git a/Subsystems/AirCompressor.h b/Subsystems/AirCompressor.h index e997c27..c57296d 100644 --- a/Subsystems/AirCompressor.h +++ b/Subsystems/AirCompressor.h @@ -9,7 +9,7 @@ class AirCompressor: public Subsystem public: AirCompressor(); void InitDefaultCommand(); - void CreateCompressedAir(); - void StopCreatingCompressedAir(); + int CreateCompressedAir(); + int StopCreatingCompressedAir(); }; #endif From 059c690b864327f90e7b9f71d8a6df4e6e93cdf4 Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Sat, 31 Jan 2015 12:16:02 -0500 Subject: [PATCH 18/64] Added elevator calibrate function (untested) --- CommandBase.cpp | 4 ++++ CommandBase.h | 2 ++ Commands/Calibrate.cpp | 18 ++++++++++++++++++ Commands/Calibrate.h | 16 ++++++++++++++++ DentRobot.cpp | 2 ++ DentRobot.h | 2 ++ Subsystems/DIO.cpp | 18 ++++++++++++++++++ Subsystems/DIO.h | 18 ++++++++++++++++++ Subsystems/Drivetrain.h | 3 +-- Subsystems/Elevator.cpp | 7 +++++++ Subsystems/Elevator.h | 3 +++ 11 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 Commands/Calibrate.cpp create mode 100644 Commands/Calibrate.h create mode 100644 Subsystems/DIO.cpp create mode 100644 Subsystems/DIO.h diff --git a/CommandBase.cpp b/CommandBase.cpp index 5470252..37136ed 100644 --- a/CommandBase.cpp +++ b/CommandBase.cpp @@ -2,15 +2,18 @@ #include "Subsystems/Drivetrain.h" #include "Subsystems/Collector.h" #include "Subsystems/Elevator.h" +#include "Subsystems/DIO.h" #include "Subsystems/AirCompressor.h" #include "Commands/Drive.h" #include "Commands/Collect.h" #include "Commands/Eject.h" #include "Commands/Raise.h" #include "Commands/Lower.h" +#include "Commands/Calibrate.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) { @@ -22,6 +25,7 @@ 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 e6891d1..18f90d0 100644 --- a/CommandBase.h +++ b/CommandBase.h @@ -5,6 +5,7 @@ #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" @@ -17,6 +18,7 @@ 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/Calibrate.cpp b/Commands/Calibrate.cpp new file mode 100644 index 0000000..b0d1bdc --- /dev/null +++ b/Commands/Calibrate.cpp @@ -0,0 +1,18 @@ +#include "Calibrate.h" +#include "../DentRobot.h" +Calibrate::Calibrate() : Command("Calibrate"){ +} +void Calibrate::Initialize(){ +} +void Calibrate::Execute(){ + DentRobot::elevator->Run(-0.4f); +} +bool Calibrate::IsFinished(){ + return DentRobot::elevator->GetPotValue()>=0.1f; +} +void Calibrate::End(){ + DentRobot::elevator->Run(0.0f); +} +void Calibrate::Interrupted(){ + End(); +} diff --git a/Commands/Calibrate.h b/Commands/Calibrate.h new file mode 100644 index 0000000..72fdbed --- /dev/null +++ b/Commands/Calibrate.h @@ -0,0 +1,16 @@ +#ifndef CALIBRATE_H +#define CALIBRATE_H + +#include "Commands/Command.h" +#include "WPILib.h" + +class Calibrate: public Command{ + public: + Calibrate(); + void Initialize(); + void Execute(); + bool IsFinished(); + void End(); + void Interrupted(); +}; +#endif diff --git a/DentRobot.cpp b/DentRobot.cpp index 3861d86..0d9e4ab 100644 --- a/DentRobot.cpp +++ b/DentRobot.cpp @@ -3,12 +3,14 @@ OI* DentRobot::oi=NULL; Collector* DentRobot::collector=NULL; Drivetrain* DentRobot::drivetrain=NULL; Elevator* DentRobot::elevator=NULL; +DIO* DentRobot::dio = NULL; AirCompressor * DentRobot::airCompressor=NULL; DentRobot::DentRobot(){ oi=new OI(); collector=new Collector(); drivetrain=new Drivetrain(); elevator=new Elevator(); + dio = new DIO(); airCompressor=new AirCompressor(); printf("Initialized"); } diff --git a/DentRobot.h b/DentRobot.h index e111c83..000a33e 100644 --- a/DentRobot.h +++ b/DentRobot.h @@ -3,6 +3,7 @@ #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" @@ -14,6 +15,7 @@ public: static Collector* collector; static Drivetrain* drivetrain; static Elevator* elevator; + static DIO* dio; static AirCompressor* airCompressor; DentRobot(); void RobotInit(); diff --git a/Subsystems/DIO.cpp b/Subsystems/DIO.cpp new file mode 100644 index 0000000..d282e01 --- /dev/null +++ b/Subsystems/DIO.cpp @@ -0,0 +1,18 @@ +#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){ + if(dioSig == ELEVATORTOP){ + // The top elevator digitalinput was triggered + return elevatorTop->Get(); + }else if(dioSig == ELEVATORBOTTOM){ + // The buttom elevator digitalinput was triggered + return elevatorBottom->Get(); + } + return false; +} diff --git a/Subsystems/DIO.h b/Subsystems/DIO.h new file mode 100644 index 0000000..c9e533b --- /dev/null +++ b/Subsystems/DIO.h @@ -0,0 +1,18 @@ +#ifndef DIO_H +#define DIO_H + +#include "WPILib.h" +#include "Commands/PIDSubsystem.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/Drivetrain.h b/Subsystems/Drivetrain.h index bdf3f70..81a5168 100644 --- a/Subsystems/Drivetrain.h +++ b/Subsystems/Drivetrain.h @@ -2,8 +2,7 @@ #define DRIVETRAIN_H #include "WPILib.h" -class Drivetrain: public Subsystem -{ +class Drivetrain: public Subsystem{ private: CANTalon *rightFront, *leftFront, *rightRear, *leftRear; RobotDrive *drive; diff --git a/Subsystems/Elevator.cpp b/Subsystems/Elevator.cpp index 20261b5..b2e28b7 100644 --- a/Subsystems/Elevator.cpp +++ b/Subsystems/Elevator.cpp @@ -4,6 +4,7 @@ Elevator::Elevator()/* : PIDSubsystem("Elevator", kP_real, kI_real, 0.0)*/{ pot=new AnalogPotentiometer(0); leftMotor=new Talon(1); rightMotor=new Talon(0); + height=0; //SetAbsoluteTolerance(0.004); } void Elevator::InitDefaultCommand(){ @@ -15,3 +16,9 @@ void Elevator::Run(double power){ leftMotor->Set(power); rightMotor->Set(power); } +void Elevator::SetHeight(double ht){ + height=ht; +} +double Elevator::GetHeight(){ + return height; +} diff --git a/Subsystems/Elevator.h b/Subsystems/Elevator.h index e54d719..9c391f5 100644 --- a/Subsystems/Elevator.h +++ b/Subsystems/Elevator.h @@ -8,10 +8,13 @@ class Elevator/*: public PIDSubsystem*/{ AnalogPotentiometer *pot; Talon *leftMotor, *rightMotor; static constexpr double kP_real=4, kI_real=.0f, kP_simulation=18, kI_simulation=.2; + double height; public: Elevator(); void InitDefaultCommand(); float GetPotValue(); void Run(double); + void SetHeight(double); + double GetHeight(); }; #endif From 814ddb15793a0fb4bd5a02ae56ee94d44cdfe6dd Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Sat, 31 Jan 2015 12:22:11 -0500 Subject: [PATCH 19/64] Ignore wpilib/ --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index e62f2ae..2a7b124 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ *.o Debug src/bin - +wpilib From 760a30a8a264319a2ed8b136f22baa7c2e2f0d66 Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Sat, 31 Jan 2015 14:30:09 -0500 Subject: [PATCH 20/64] Continued development of elevator (not working) --- Commands/Calibrate.cpp | 9 ++++++++- Subsystems/Elevator.cpp | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Commands/Calibrate.cpp b/Commands/Calibrate.cpp index b0d1bdc..250ebab 100644 --- a/Commands/Calibrate.cpp +++ b/Commands/Calibrate.cpp @@ -1,14 +1,21 @@ #include "Calibrate.h" #include "../DentRobot.h" +// Lowers elevator until it hits the limit switch then sets the height of the elevator to the height of the limit switches Calibrate::Calibrate() : Command("Calibrate"){ } void Calibrate::Initialize(){ } void Calibrate::Execute(){ + // Lower collector until End() DentRobot::elevator->Run(-0.4f); } bool Calibrate::IsFinished(){ - return DentRobot::elevator->GetPotValue()>=0.1f; + if(DentRobot::DIO->Get()){ + // 0.99 is a placeholder for the height of the limit switches + DentRobot::elevator->SetHeight(0.99); + return true; + } + return false; } void Calibrate::End(){ DentRobot::elevator->Run(0.0f); diff --git a/Subsystems/Elevator.cpp b/Subsystems/Elevator.cpp index b2e28b7..76188c8 100644 --- a/Subsystems/Elevator.cpp +++ b/Subsystems/Elevator.cpp @@ -13,6 +13,8 @@ float Elevator::GetPotValue(){ return pot->Get(); } void Elevator::Run(double power){ + // Height supposed to be the location of the elevator + //height+=power; leftMotor->Set(power); rightMotor->Set(power); } From b548bee06792fc37ac671fb6ae1dd608c9a90ec3 Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Sat, 31 Jan 2015 15:02:33 -0500 Subject: [PATCH 21/64] Code compiles now --- Commands/Calibrate.cpp | 2 +- Commands/Compressor/StartCompressing.h | 2 +- Commands/Compressor/StopCompressing.h | 2 +- Subsystems/DIO.h | 1 - 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Commands/Calibrate.cpp b/Commands/Calibrate.cpp index 250ebab..4c86822 100644 --- a/Commands/Calibrate.cpp +++ b/Commands/Calibrate.cpp @@ -10,7 +10,7 @@ void Calibrate::Execute(){ DentRobot::elevator->Run(-0.4f); } bool Calibrate::IsFinished(){ - if(DentRobot::DIO->Get()){ + if(DentRobot::dio->Get(DIO::ELEVATORBOTTOM)){ // 0.99 is a placeholder for the height of the limit switches DentRobot::elevator->SetHeight(0.99); return true; diff --git a/Commands/Compressor/StartCompressing.h b/Commands/Compressor/StartCompressing.h index 8e503ee..a681bd0 100644 --- a/Commands/Compressor/StartCompressing.h +++ b/Commands/Compressor/StartCompressing.h @@ -3,7 +3,7 @@ #include "../../CommandBase.h" #include "../../DentRobot.h" -#include "../../Commands/Command.h" +#include "Commands/Command.h" #include "WPILib.h" class StartCompressing: public Command{ diff --git a/Commands/Compressor/StopCompressing.h b/Commands/Compressor/StopCompressing.h index 7d5c27c..c723098 100644 --- a/Commands/Compressor/StopCompressing.h +++ b/Commands/Compressor/StopCompressing.h @@ -3,7 +3,7 @@ #include "../../CommandBase.h" #include "../../DentRobot.h" -#include "../../Commands/Command.h" +#include "Commands/Command.h" #include "WPILib.h" class StopCompressing: public Command{ diff --git a/Subsystems/DIO.h b/Subsystems/DIO.h index c9e533b..8862850 100644 --- a/Subsystems/DIO.h +++ b/Subsystems/DIO.h @@ -2,7 +2,6 @@ #define DIO_H #include "WPILib.h" -#include "Commands/PIDSubsystem.h" class DIO{ private: DigitalInput *elevatorTop, *elevatorBottom; From a3e272dfdc78e41fa3c7631b6538fe90115cadc5 Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Sat, 31 Jan 2015 15:02:53 -0500 Subject: [PATCH 22/64] Fixed gitignore --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 2a7b124..ebc65cf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ *.o Debug -src/bin +bin wpilib From e30390e43ff3f057da52f823a346f80686712c72 Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Sun, 1 Feb 2015 14:48:01 -0500 Subject: [PATCH 23/64] Started adding encoder support (not working) --- Commands/Calibrate.cpp | 4 ++-- Subsystems/Elevator.cpp | 17 ++++++++++------- Subsystems/Elevator.h | 7 ++++--- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/Commands/Calibrate.cpp b/Commands/Calibrate.cpp index 4c86822..411dc03 100644 --- a/Commands/Calibrate.cpp +++ b/Commands/Calibrate.cpp @@ -11,8 +11,8 @@ void Calibrate::Execute(){ } bool Calibrate::IsFinished(){ if(DentRobot::dio->Get(DIO::ELEVATORBOTTOM)){ - // 0.99 is a placeholder for the height of the limit switches - DentRobot::elevator->SetHeight(0.99); + DentRobot::elevator->ResetEncoder(); + DentRobot::elevator->SetOffset(0.99); return true; } return false; diff --git a/Subsystems/Elevator.cpp b/Subsystems/Elevator.cpp index 76188c8..487917f 100644 --- a/Subsystems/Elevator.cpp +++ b/Subsystems/Elevator.cpp @@ -2,8 +2,10 @@ #include "../RobotMap.h" Elevator::Elevator()/* : PIDSubsystem("Elevator", kP_real, kI_real, 0.0)*/{ pot=new AnalogPotentiometer(0); - leftMotor=new Talon(1); - rightMotor=new Talon(0); + leftMotor=new CANTalon(1); + rightMotor=new CANTalon(0); + elevatorEncoder=new Encoder(0,1,false); + offset=0; height=0; //SetAbsoluteTolerance(0.004); } @@ -13,14 +15,15 @@ float Elevator::GetPotValue(){ return pot->Get(); } void Elevator::Run(double power){ - // Height supposed to be the location of the elevator - //height+=power; leftMotor->Set(power); rightMotor->Set(power); } -void Elevator::SetHeight(double ht){ - height=ht; +void Elevator::SetOffset(double ht){ + offset=ht; +} +void Elevator::ResetEncoder(){ + elevatorEncoder->Reset(); } double Elevator::GetHeight(){ - return height; + return elevatorEncoder->Get()+offset; } diff --git a/Subsystems/Elevator.h b/Subsystems/Elevator.h index 9c391f5..cb4ecb4 100644 --- a/Subsystems/Elevator.h +++ b/Subsystems/Elevator.h @@ -6,15 +6,16 @@ class Elevator/*: public PIDSubsystem*/{ private: AnalogPotentiometer *pot; - Talon *leftMotor, *rightMotor; + CANTalon *leftMotor, *rightMotor; + Encoder *elevatorEncoder; static constexpr double kP_real=4, kI_real=.0f, kP_simulation=18, kI_simulation=.2; - double height; + double offset, height; public: Elevator(); void InitDefaultCommand(); float GetPotValue(); void Run(double); - void SetHeight(double); + void SetOffset(double); double GetHeight(); }; #endif From 2cf5d410817bae47949905b7923b58baab1eba17 Mon Sep 17 00:00:00 2001 From: Adam Long Date: Mon, 2 Feb 2015 17:14:27 +0000 Subject: [PATCH 24/64] Added a lot of collector code, needs fine tuning and calibration --- CommandBase.cpp | 5 ++++- Commands/CloseCollector.cpp | 16 ++++++++++++++ Commands/CloseCollector.h | 19 +++++++++++++++++ Commands/Collect.cpp | 14 ------------- Commands/CollectTote.cpp | 17 +++++++++++++++ Commands/{Collect.h => CollectTote.h} | 10 +++++---- Commands/Eject.cpp | 1 - Commands/OpenCollector.cpp | 17 +++++++++++++++ Commands/OpenCollector.h | 19 +++++++++++++++++ Commands/ReleaseTote.cpp | 17 +++++++++++++++ Commands/ReleaseTote.h | 19 +++++++++++++++++ OI.cpp | 15 ++++++++++++-- Subsystems/Collector.cpp | 30 ++++++++++++++++++++++----- Subsystems/Collector.h | 9 ++++++-- hhlib | 1 + 15 files changed, 180 insertions(+), 29 deletions(-) create mode 100644 Commands/CloseCollector.cpp create mode 100644 Commands/CloseCollector.h delete mode 100644 Commands/Collect.cpp create mode 100644 Commands/CollectTote.cpp rename Commands/{Collect.h => CollectTote.h} (54%) create mode 100644 Commands/OpenCollector.cpp create mode 100644 Commands/OpenCollector.h create mode 100644 Commands/ReleaseTote.cpp create mode 100644 Commands/ReleaseTote.h create mode 160000 hhlib diff --git a/CommandBase.cpp b/CommandBase.cpp index 37136ed..ed78e06 100644 --- a/CommandBase.cpp +++ b/CommandBase.cpp @@ -5,7 +5,10 @@ #include "Subsystems/DIO.h" #include "Subsystems/AirCompressor.h" #include "Commands/Drive.h" -#include "Commands/Collect.h" +#include "Commands/CloseCollector.h" +#include "Commands/OpenCollector.h" +#include "Commands/CollectTote.h" +#include "Commands/ReleaseTote.h" #include "Commands/Eject.h" #include "Commands/Raise.h" #include "Commands/Lower.h" diff --git a/Commands/CloseCollector.cpp b/Commands/CloseCollector.cpp new file mode 100644 index 0000000..94e4c5d --- /dev/null +++ b/Commands/CloseCollector.cpp @@ -0,0 +1,16 @@ +#include "CloseCollector.h" +CloseCollector::CloseCollector() : Command("CloseCollector"){ + Requires(DentRobot::collector); +} +void CloseCollector::Initialize(){ +} +void CloseCollector::Execute(){ + DentRobot::collector->MoveArms(.1); +} +bool CloseCollector::IsFinished(){ + return DentRobot::collector->ArmsDoneMoving(); +} +void CloseCollector::End(){ +} +void CloseCollector::Interrupted(){ +} diff --git a/Commands/CloseCollector.h b/Commands/CloseCollector.h new file mode 100644 index 0000000..aaf6776 --- /dev/null +++ b/Commands/CloseCollector.h @@ -0,0 +1,19 @@ +#ifndef CLOSECOLLECTOR_H +#define CLOSECOLLECTOR_H + +#include "Commands/Command.h" +#include "../CommandBase.h" +#include "../DentRobot.h" +#include "WPILib.h" + +class CloseCollector: public Command{ + public: + CloseCollector(); + void Initialize(); + void Execute(); + bool IsFinished(); + void End(); + void Interrupted(); +}; + +#endif diff --git a/Commands/Collect.cpp b/Commands/Collect.cpp deleted file mode 100644 index 2ce95e3..0000000 --- a/Commands/Collect.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "Collect.h" -Collect::Collect() : Command("Collect"){ -} -void Collect::Initialize(){ -} -void Collect::Execute(){ -} -bool Collect::IsFinished(){ - return false; -} -void Collect::End(){ -} -void Collect::Interrupted(){ -} diff --git a/Commands/CollectTote.cpp b/Commands/CollectTote.cpp new file mode 100644 index 0000000..f28c974 --- /dev/null +++ b/Commands/CollectTote.cpp @@ -0,0 +1,17 @@ +#include "CollectTote.h" +CollectTote::CollectTote() : Command("CollectTote"){ + Requires(DentRobot::collector); +} +void CollectTote::Initialize(){ +} +void CollectTote::Execute(){ + //TODO check this value to move the motors in the right direction + DentRobot::collector->MoveRollers(-1); +} +bool CollectTote::IsFinished(){ + return DentRobot::collector->BoxCollected(); +} +void CollectTote::End(){ +} +void CollectTote::Interrupted(){ +} diff --git a/Commands/Collect.h b/Commands/CollectTote.h similarity index 54% rename from Commands/Collect.h rename to Commands/CollectTote.h index a9dd24d..370cc51 100644 --- a/Commands/Collect.h +++ b/Commands/CollectTote.h @@ -1,12 +1,14 @@ -#ifndef COLLECT_H -#define COLLECT_H +#ifndef COLLECTTOTE_H +#define COLLECTTOTE_H #include "Commands/Command.h" +#include "../CommandBase.h" +#include "../DentRobot.h" #include "WPILib.h" -class Collect: public Command{ +class CollectTote: public Command{ public: - Collect(); + CollectTote(); void Initialize(); void Execute(); bool IsFinished(); diff --git a/Commands/Eject.cpp b/Commands/Eject.cpp index f94ae8a..17ca579 100644 --- a/Commands/Eject.cpp +++ b/Commands/Eject.cpp @@ -6,7 +6,6 @@ Eject::Eject() : Command("Eject"){ void Eject::Initialize(){ } void Eject::Execute(){ - DentRobot::collector->Set(DentRobot::oi->GetLeftStick()->GetThrottle()); } bool Eject::IsFinished(){ return false; diff --git a/Commands/OpenCollector.cpp b/Commands/OpenCollector.cpp new file mode 100644 index 0000000..8538ec6 --- /dev/null +++ b/Commands/OpenCollector.cpp @@ -0,0 +1,17 @@ +#include "OpenCollector.h" +OpenCollector::OpenCollector() : Command("OpenCollector"){ + Requires(DentRobot::collector); +} +void OpenCollector::Initialize(){ +} +void OpenCollector::Execute(){ + //TODO check this value to move the motors in the right direction + DentRobot::collector->MoveArms(-.1); +} +bool OpenCollector::IsFinished(){ + return DentRobot::collector->ArmsDoneMoving(); +} +void OpenCollector::End(){ +} +void OpenCollector::Interrupted(){ +} diff --git a/Commands/OpenCollector.h b/Commands/OpenCollector.h new file mode 100644 index 0000000..2264a1a --- /dev/null +++ b/Commands/OpenCollector.h @@ -0,0 +1,19 @@ +#ifndef OPENCOLLECTOR_H +#define OPENCOLLECTOR_H + +#include "Commands/Command.h" +#include "../CommandBase.h" +#include "../DentRobot.h" +#include "WPILib.h" + +class OpenCollector: public Command{ + public: + OpenCollector(); + void Initialize(); + void Execute(); + bool IsFinished(); + void End(); + void Interrupted(); +}; + +#endif diff --git a/Commands/ReleaseTote.cpp b/Commands/ReleaseTote.cpp new file mode 100644 index 0000000..21b6e2a --- /dev/null +++ b/Commands/ReleaseTote.cpp @@ -0,0 +1,17 @@ +#include "ReleaseTote.h" +ReleaseTote::ReleaseTote() : Command("ReleaseTote"){ + Requires(DentRobot::collector); +} +void ReleaseTote::Initialize(){ +} +void ReleaseTote::Execute(){ + //TODO check this value to move the motors in the right direction + DentRobot::collector->MoveRollers(1); +} +bool ReleaseTote::IsFinished(){ + return DentRobot::collector->BoxCollected(); +} +void ReleaseTote::End(){ +} +void ReleaseTote::Interrupted(){ +} diff --git a/Commands/ReleaseTote.h b/Commands/ReleaseTote.h new file mode 100644 index 0000000..9d6b7fd --- /dev/null +++ b/Commands/ReleaseTote.h @@ -0,0 +1,19 @@ +#ifndef RELEASETOTE_H +#define RELEASETOTE_H + +#include "Commands/Command.h" +#include "../CommandBase.h" +#include "../DentRobot.h" +#include "WPILib.h" + +class ReleaseTote: public Command{ + public: + ReleaseTote(); + void Initialize(); + void Execute(); + bool IsFinished(); + void End(); + void Interrupted(); +}; + +#endif diff --git a/OI.cpp b/OI.cpp index 3af8941..1a16364 100644 --- a/OI.cpp +++ b/OI.cpp @@ -1,18 +1,29 @@ #include "OI.h" #include "Commands/Lower.h" #include "Commands/Raise.h" -#include "Commands/Collect.h" #include "Commands/Eject.h" +#include "Commands/OpenCollector.h" +#include "Commands/CloseCollector.h" +#include "Commands/CollectTote.h" +#include "Commands/ReleaseTote.h" #include "Commands/Compressor/StartCompressing.h" #include "Commands/Compressor/StopCompressing.h" OI::OI() { leftStick=new Joystick(0); rightStick=new Joystick(1); + //TODO name these buttons to their functions rather to their number JoystickButton *left10=new JoystickButton(leftStick, 10); JoystickButton *left11=new JoystickButton(leftStick, 11); + JoystickButton *right1=new JoystickButton(rightStick, 1); + JoystickButton *right2=new JoystickButton(rightStick, 2); + JoystickButton *right3=new JoystickButton(rightStick, 3); + JoystickButton *right4=new JoystickButton(rightStick, 4); + right1->WhenPressed(new OpenCollector()); + right2->WhenPressed(new CloseCollector()); + right3->WhenPressed(new CollectTote()); + right4->WhenPressed(new ReleaseTote()); left10->WhenPressed(new Eject()); - left11->WhenPressed(new Collect()); } Joystick* OI::GetRightStick(){ return rightStick; diff --git a/Subsystems/Collector.cpp b/Subsystems/Collector.cpp index 9180975..a6d5a5a 100644 --- a/Subsystems/Collector.cpp +++ b/Subsystems/Collector.cpp @@ -2,12 +2,32 @@ #include "../RobotMap.h" Collector::Collector() : Subsystem("Collector") { - motor1=new Talon(0); - motor2=new Talon(1); + windowMotorLeft=new CANTalon(50); + windowMotorRight=new CANTalon(51); + collectorMotorLeft=new CANTalon(52); + collectorMotorRight=new CANTalon(53); + boxSwitch=new DigitalInput(9); } void Collector::InitDefaultCommand() { } -void Collector::Set(float power){ - motor1->Set(power); - motor2->Set(power); +void Collector::MoveArms(float a){ + windowMotorLeft->Set(a); + windowMotorRight->Set(-a); + a++; +} +void Collector::MoveRollers(float a){ + collectorMotorLeft->Set(a); + collectorMotorRight->Set(-a); + r++; +} +bool Collector::ArmsDoneMoving(){ + //TODO calibrate these values or find a sensor to use + if(a>=200){ + return true; + }else{ + return false; + } +} +bool Collector::BoxCollected(){ + return boxSwitch->Get(); } diff --git a/Subsystems/Collector.h b/Subsystems/Collector.h index 9308d15..c6e85a9 100644 --- a/Subsystems/Collector.h +++ b/Subsystems/Collector.h @@ -5,10 +5,15 @@ class Collector: public Subsystem { private: - Talon *motor1, *motor2; + CANTalon *windowMotorLeft, *windowMotorRight, *collectorMotorLeft, *collectorMotorRight; + DigitalInput *boxSwitch; + int a,r; public: Collector(); void InitDefaultCommand(); - void Set(float); + void MoveArms(float); + void MoveRollers(float); + bool ArmsDoneMoving(); + bool BoxCollected(); }; #endif diff --git a/hhlib b/hhlib new file mode 160000 index 0000000..787733b --- /dev/null +++ b/hhlib @@ -0,0 +1 @@ +Subproject commit 787733b3d4204d061620c7906af0cf4777c47e34 From df4c727ab249d50ee4a6ff8ad36dbc32e819d2e0 Mon Sep 17 00:00:00 2001 From: Adam Long Date: Mon, 2 Feb 2015 17:37:32 +0000 Subject: [PATCH 25/64] Updated OI to remove unused vars --- OI.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/OI.cpp b/OI.cpp index 1a16364..bf1225f 100644 --- a/OI.cpp +++ b/OI.cpp @@ -14,7 +14,6 @@ OI::OI() { rightStick=new Joystick(1); //TODO name these buttons to their functions rather to their number JoystickButton *left10=new JoystickButton(leftStick, 10); - JoystickButton *left11=new JoystickButton(leftStick, 11); JoystickButton *right1=new JoystickButton(rightStick, 1); JoystickButton *right2=new JoystickButton(rightStick, 2); JoystickButton *right3=new JoystickButton(rightStick, 3); From e5a8402f15561b01fc6bdb57f4fb560b8afa68de Mon Sep 17 00:00:00 2001 From: Adam Long Date: Mon, 2 Feb 2015 17:42:18 +0000 Subject: [PATCH 26/64] Updated elevator header to fix compiler error --- Subsystems/Elevator.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Subsystems/Elevator.h b/Subsystems/Elevator.h index cb4ecb4..abcdf9e 100644 --- a/Subsystems/Elevator.h +++ b/Subsystems/Elevator.h @@ -16,6 +16,7 @@ class Elevator/*: public PIDSubsystem*/{ float GetPotValue(); void Run(double); void SetOffset(double); + void ResetEncoder(); double GetHeight(); }; #endif From 0ff142c25b3cbc22010d2f2c10606399b6c42d36 Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Mon, 2 Feb 2015 18:53:02 -0500 Subject: [PATCH 27/64] Updated to match robot specs --- Commands/Lower.cpp | 3 +-- Commands/Raise.cpp | 3 +-- Subsystems/Collector.cpp | 26 +++++++++++++------------- Subsystems/Elevator.cpp | 10 ++-------- Subsystems/Elevator.h | 4 +--- 5 files changed, 18 insertions(+), 28 deletions(-) diff --git a/Commands/Lower.cpp b/Commands/Lower.cpp index b30b0c8..38b6c94 100644 --- a/Commands/Lower.cpp +++ b/Commands/Lower.cpp @@ -8,8 +8,7 @@ void Lower::Execute(){ DentRobot::elevator->Run(-0.4f); } bool Lower::IsFinished(){ - // 0.1f is a placeholder for the min elevator value - return DentRobot::elevator->GetPotValue()>=0.1f; + return false; } void Lower::End(){ DentRobot::elevator->Run(0.0f); diff --git a/Commands/Raise.cpp b/Commands/Raise.cpp index 2d6dd30..e2e7107 100644 --- a/Commands/Raise.cpp +++ b/Commands/Raise.cpp @@ -8,8 +8,7 @@ void Raise::Execute(){ DentRobot::elevator->Run(0.4f); } bool Raise::IsFinished(){ - // 0.9f is a placeholder for the max elevator value - return DentRobot::elevator->GetPotValue()>=0.9f; + return false; } void Raise::End(){ DentRobot::elevator->Run(0.0f); diff --git a/Subsystems/Collector.cpp b/Subsystems/Collector.cpp index a6d5a5a..4e39880 100644 --- a/Subsystems/Collector.cpp +++ b/Subsystems/Collector.cpp @@ -11,23 +11,23 @@ Collector::Collector() : Subsystem("Collector") { void Collector::InitDefaultCommand() { } void Collector::MoveArms(float a){ - windowMotorLeft->Set(a); - windowMotorRight->Set(-a); - a++; + windowMotorLeft->Set(a); + windowMotorRight->Set(-a); + a++; } void Collector::MoveRollers(float a){ - collectorMotorLeft->Set(a); - collectorMotorRight->Set(-a); - r++; + collectorMotorLeft->Set(a); + collectorMotorRight->Set(-a); + r++; } bool Collector::ArmsDoneMoving(){ - //TODO calibrate these values or find a sensor to use - if(a>=200){ - return true; - }else{ - return false; - } + //TODO calibrate these values or find a sensor to use + if(a>=200){ + return true; + }else{ + return false; + } } bool Collector::BoxCollected(){ - return boxSwitch->Get(); + return boxSwitch->Get(); } diff --git a/Subsystems/Elevator.cpp b/Subsystems/Elevator.cpp index 487917f..a4637ee 100644 --- a/Subsystems/Elevator.cpp +++ b/Subsystems/Elevator.cpp @@ -1,9 +1,7 @@ #include "Elevator.h" #include "../RobotMap.h" Elevator::Elevator()/* : PIDSubsystem("Elevator", kP_real, kI_real, 0.0)*/{ - pot=new AnalogPotentiometer(0); - leftMotor=new CANTalon(1); - rightMotor=new CANTalon(0); + motor=new CANTalon(0); elevatorEncoder=new Encoder(0,1,false); offset=0; height=0; @@ -11,12 +9,8 @@ Elevator::Elevator()/* : PIDSubsystem("Elevator", kP_real, kI_real, 0.0)*/{ } void Elevator::InitDefaultCommand(){ } -float Elevator::GetPotValue(){ - return pot->Get(); -} void Elevator::Run(double power){ - leftMotor->Set(power); - rightMotor->Set(power); + motor->Set(power); } void Elevator::SetOffset(double ht){ offset=ht; diff --git a/Subsystems/Elevator.h b/Subsystems/Elevator.h index abcdf9e..26902d8 100644 --- a/Subsystems/Elevator.h +++ b/Subsystems/Elevator.h @@ -5,15 +5,13 @@ #include "Commands/PIDSubsystem.h" class Elevator/*: public PIDSubsystem*/{ private: - AnalogPotentiometer *pot; - CANTalon *leftMotor, *rightMotor; + CANTalon *motor; Encoder *elevatorEncoder; static constexpr double kP_real=4, kI_real=.0f, kP_simulation=18, kI_simulation=.2; double offset, height; public: Elevator(); void InitDefaultCommand(); - float GetPotValue(); void Run(double); void SetOffset(double); void ResetEncoder(); From 653bb9aacc277c412c9c14dbdee17cb5da75a81a Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Mon, 2 Feb 2015 19:56:27 -0500 Subject: [PATCH 28/64] Fixed poorly written code --- CommandBase.cpp | 4 +--- Commands/CloseCollector.cpp | 3 ++- Commands/Compressor/StartCompressing.cpp | 5 ++--- Commands/Compressor/StopCompressing.cpp | 5 ++--- Commands/Eject.cpp | 16 ---------------- Commands/Eject.h | 17 ----------------- Commands/OpenCollector.cpp | 8 ++++---- OI.cpp | 3 --- RobotMap.h | 19 +++++++++++++++++++ Subsystems/AirCompressor.cpp | 16 +++++++--------- Subsystems/AirCompressor.h | 6 +++--- Subsystems/Collector.cpp | 22 ++++++++-------------- Subsystems/Collector.h | 3 +-- Subsystems/Drivetrain.cpp | 22 +++++++++++----------- Subsystems/Elevator.cpp | 2 +- 15 files changed, 61 insertions(+), 90 deletions(-) delete mode 100644 Commands/Eject.cpp delete mode 100644 Commands/Eject.h diff --git a/CommandBase.cpp b/CommandBase.cpp index ed78e06..a517bee 100644 --- a/CommandBase.cpp +++ b/CommandBase.cpp @@ -9,7 +9,6 @@ #include "Commands/OpenCollector.h" #include "Commands/CollectTote.h" #include "Commands/ReleaseTote.h" -#include "Commands/Eject.h" #include "Commands/Raise.h" #include "Commands/Lower.h" #include "Commands/Calibrate.h" @@ -23,8 +22,7 @@ CommandBase::CommandBase(char const *name) : Command(name) { } CommandBase::CommandBase() : Command() { } -void CommandBase::init() -{ +void CommandBase::init(){ drivetrain = new Drivetrain(); collector = new Collector(); elevator = new Elevator(); diff --git a/Commands/CloseCollector.cpp b/Commands/CloseCollector.cpp index 94e4c5d..b415152 100644 --- a/Commands/CloseCollector.cpp +++ b/Commands/CloseCollector.cpp @@ -3,12 +3,13 @@ CloseCollector::CloseCollector() : Command("CloseCollector"){ Requires(DentRobot::collector); } void CloseCollector::Initialize(){ + SetTimeout(0.5); } void CloseCollector::Execute(){ DentRobot::collector->MoveArms(.1); } bool CloseCollector::IsFinished(){ - return DentRobot::collector->ArmsDoneMoving(); + return DentRobot::collector->ArmSensor(); } void CloseCollector::End(){ } diff --git a/Commands/Compressor/StartCompressing.cpp b/Commands/Compressor/StartCompressing.cpp index 8e3b047..b71d975 100644 --- a/Commands/Compressor/StartCompressing.cpp +++ b/Commands/Compressor/StartCompressing.cpp @@ -1,13 +1,12 @@ #include "StartCompressing.h" -#include #include "../../DentRobot.h" StartCompressing::StartCompressing() : Command("StartCompressing"){ - Requires(DentRobot::airCompressor); + Requires(DentRobot::airCompressor); } void StartCompressing::Initialize(){ } void StartCompressing::Execute(){ - DentRobot::airCompressor->CreateCompressedAir(); + DentRobot::airCompressor->StartCompressing(); } bool StartCompressing::IsFinished(){ return false; diff --git a/Commands/Compressor/StopCompressing.cpp b/Commands/Compressor/StopCompressing.cpp index 7d2120a..009ae4f 100644 --- a/Commands/Compressor/StopCompressing.cpp +++ b/Commands/Compressor/StopCompressing.cpp @@ -1,13 +1,12 @@ #include "StopCompressing.h" -#include #include "../../DentRobot.h" StopCompressing::StopCompressing() : Command("StopCompressing"){ - Requires(DentRobot::airCompressor); + Requires(DentRobot::airCompressor); } void StopCompressing::Initialize(){ } void StopCompressing::Execute(){ - DentRobot::airCompressor->StopCreatingCompressedAir(); + DentRobot::airCompressor->StopCompressing(); } bool StopCompressing::IsFinished(){ return false; diff --git a/Commands/Eject.cpp b/Commands/Eject.cpp deleted file mode 100644 index 17ca579..0000000 --- a/Commands/Eject.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "Eject.h" -#include "../DentRobot.h" -Eject::Eject() : Command("Eject"){ - Requires(DentRobot::collector); -} -void Eject::Initialize(){ -} -void Eject::Execute(){ -} -bool Eject::IsFinished(){ - return false; -} -void Eject::End(){ -} -void Eject::Interrupted(){ -} diff --git a/Commands/Eject.h b/Commands/Eject.h deleted file mode 100644 index 8793be9..0000000 --- a/Commands/Eject.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef EJECT_H -#define EJECT_H - -#include "Commands/Command.h" -#include "WPILib.h" - -class Eject: public Command{ - public: - Eject(); - void Initialize(); - void Execute(); - bool IsFinished(); - void End(); - void Interrupted(); -}; - -#endif diff --git a/Commands/OpenCollector.cpp b/Commands/OpenCollector.cpp index 8538ec6..bbd00c5 100644 --- a/Commands/OpenCollector.cpp +++ b/Commands/OpenCollector.cpp @@ -1,15 +1,15 @@ #include "OpenCollector.h" OpenCollector::OpenCollector() : Command("OpenCollector"){ - Requires(DentRobot::collector); + Requires(DentRobot::collector); } void OpenCollector::Initialize(){ } void OpenCollector::Execute(){ - //TODO check this value to move the motors in the right direction - DentRobot::collector->MoveArms(-.1); + //TODO check this value to move the motors in the right direction + DentRobot::collector->MoveArms(-.1); } bool OpenCollector::IsFinished(){ - return DentRobot::collector->ArmsDoneMoving(); + return DentRobot::collector->ArmSensor(); } void OpenCollector::End(){ } diff --git a/OI.cpp b/OI.cpp index bf1225f..a2c9e66 100644 --- a/OI.cpp +++ b/OI.cpp @@ -1,7 +1,6 @@ #include "OI.h" #include "Commands/Lower.h" #include "Commands/Raise.h" -#include "Commands/Eject.h" #include "Commands/OpenCollector.h" #include "Commands/CloseCollector.h" #include "Commands/CollectTote.h" @@ -13,7 +12,6 @@ OI::OI() { leftStick=new Joystick(0); rightStick=new Joystick(1); //TODO name these buttons to their functions rather to their number - JoystickButton *left10=new JoystickButton(leftStick, 10); JoystickButton *right1=new JoystickButton(rightStick, 1); JoystickButton *right2=new JoystickButton(rightStick, 2); JoystickButton *right3=new JoystickButton(rightStick, 3); @@ -22,7 +20,6 @@ OI::OI() { right2->WhenPressed(new CloseCollector()); right3->WhenPressed(new CollectTote()); right4->WhenPressed(new ReleaseTote()); - left10->WhenPressed(new Eject()); } Joystick* OI::GetRightStick(){ return rightStick; diff --git a/RobotMap.h b/RobotMap.h index 11d078f..294feab 100644 --- a/RobotMap.h +++ b/RobotMap.h @@ -3,4 +3,23 @@ #include "WPILib.h" +// Elevator +#define ELEVATOR_CAN 0 + +// Drivetrain +#define DRIVE_FRONT_LEFT_CAN 41 +#define DRIVE_BACK_LEFT_CAN 43 +#define DRIVE_FRONT_RIGHT_CAN 40 +#define DRIVE_BACK_RIGHT_CAN 42 + +// Collector +#define COLLECTOR_WINDOW_LEFT_CAN 50 +#define COLLECTOR_WINDOW_RIGHT_CAN 51 +#define COLLECTOR_LEFT_CAN 52 +#define COLLECTOR_RIGHT_CAN 53 +#define COLLECTOR_BOXSWITCH_DIO 9 + +// Compressor +#define COMPRESSOR_CAN 31 + #endif diff --git a/Subsystems/AirCompressor.cpp b/Subsystems/AirCompressor.cpp index cda5a76..b813d9b 100644 --- a/Subsystems/AirCompressor.cpp +++ b/Subsystems/AirCompressor.cpp @@ -2,17 +2,15 @@ #include "../RobotMap.h" AirCompressor::AirCompressor() : Subsystem("AirCompressor") { - compressher = new Compressor(31); + compressor = new Compressor(COMPRESSOR_CAN); } void AirCompressor::InitDefaultCommand() { } -int AirCompressor::CreateCompressedAir() { - printf("compressing and stuff\n"); - compressher->Start(); - return 0; +void AirCompressor::StartCompressing() { + printf("Starting compressor\n"); + compressor->Start(); } -int AirCompressor::StopCreatingCompressedAir() { - printf("not compressing and stuff\n"); - compressher->Stop(); - return 0; +void AirCompressor::StopCompressing() { + printf("Stopping compressor\n"); + compressor->Stop(); } diff --git a/Subsystems/AirCompressor.h b/Subsystems/AirCompressor.h index c57296d..ca48f25 100644 --- a/Subsystems/AirCompressor.h +++ b/Subsystems/AirCompressor.h @@ -5,11 +5,11 @@ class AirCompressor: public Subsystem { private: - Compressor *compressher; + Compressor *compressor; public: AirCompressor(); void InitDefaultCommand(); - int CreateCompressedAir(); - int StopCreatingCompressedAir(); + void StartCompressing(); + void StopCompressing(); }; #endif diff --git a/Subsystems/Collector.cpp b/Subsystems/Collector.cpp index 4e39880..563eb54 100644 --- a/Subsystems/Collector.cpp +++ b/Subsystems/Collector.cpp @@ -2,31 +2,25 @@ #include "../RobotMap.h" Collector::Collector() : Subsystem("Collector") { - windowMotorLeft=new CANTalon(50); - windowMotorRight=new CANTalon(51); - collectorMotorLeft=new CANTalon(52); - collectorMotorRight=new CANTalon(53); - boxSwitch=new DigitalInput(9); + windowMotorLeft=new CANTalon(COLLECTOR_WINDOW_LEFT_CAN); + windowMotorRight=new CANTalon(COLLECTOR_WINDOW_RIGHT_CAN); + collectorMotorLeft=new CANTalon(COLLECTOR_LEFT_CAN); + collectorMotorRight=new CANTalon(COLLECTOR_RIGHT_CAN); + boxSwitch=new DigitalInput(COLLECTOR_BOXSWITCH_DIO); } void Collector::InitDefaultCommand() { } void Collector::MoveArms(float a){ windowMotorLeft->Set(a); windowMotorRight->Set(-a); - a++; } void Collector::MoveRollers(float a){ collectorMotorLeft->Set(a); collectorMotorRight->Set(-a); - r++; } -bool Collector::ArmsDoneMoving(){ - //TODO calibrate these values or find a sensor to use - if(a>=200){ - return true; - }else{ - return false; - } +bool Collector::ArmSensor(){ + // TODO: include limit switch code + return false; } bool Collector::BoxCollected(){ return boxSwitch->Get(); diff --git a/Subsystems/Collector.h b/Subsystems/Collector.h index c6e85a9..f5bc658 100644 --- a/Subsystems/Collector.h +++ b/Subsystems/Collector.h @@ -7,13 +7,12 @@ class Collector: public Subsystem private: CANTalon *windowMotorLeft, *windowMotorRight, *collectorMotorLeft, *collectorMotorRight; DigitalInput *boxSwitch; - int a,r; public: Collector(); void InitDefaultCommand(); void MoveArms(float); void MoveRollers(float); - bool ArmsDoneMoving(); + bool ArmSensor(); bool BoxCollected(); }; #endif diff --git a/Subsystems/Drivetrain.cpp b/Subsystems/Drivetrain.cpp index 17f690c..1ba7c9b 100644 --- a/Subsystems/Drivetrain.cpp +++ b/Subsystems/Drivetrain.cpp @@ -3,20 +3,20 @@ #include "../Commands/Drive.h" Drivetrain::Drivetrain() : Subsystem("Drivetrain"){ - rightFront = new CANTalon(40); - leftFront = new CANTalon(41); - rightRear = new CANTalon(42); - leftRear = new CANTalon(43); + rightFront = new CANTalon(DRIVE_FRONT_RIGHT_CAN); + leftFront = new CANTalon(DRIVE_FRONT_LEFT_CAN); + rightRear = new CANTalon(DRIVE_BACK_RIGHT_CAN); + leftRear = new CANTalon(DRIVE_BACK_LEFT_CAN); } 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; - rightFront->Set((-correctX + correctY - correctZ)); - leftFront->Set((correctX + correctY + correctZ)*-1); - rightRear->Set((correctX + correctY - correctZ)); - leftRear->Set((-correctX + correctY + correctZ)*-1); + double correctY = (sensitivity*(pow(y,3))+(1-sensitivity)*y); + double correctX = -(sensitivity*(pow(x,3))+(1-sensitivity)*x); + double correctZ = -z *.5; + rightFront->Set((-correctX + correctY - correctZ)); + leftFront->Set((correctX + correctY + correctZ)*-1); + rightRear->Set((correctX + correctY - correctZ)); + leftRear->Set((-correctX + correctY + correctZ)*-1); } diff --git a/Subsystems/Elevator.cpp b/Subsystems/Elevator.cpp index a4637ee..d32943b 100644 --- a/Subsystems/Elevator.cpp +++ b/Subsystems/Elevator.cpp @@ -1,7 +1,7 @@ #include "Elevator.h" #include "../RobotMap.h" Elevator::Elevator()/* : PIDSubsystem("Elevator", kP_real, kI_real, 0.0)*/{ - motor=new CANTalon(0); + motor=new CANTalon(ELEVATOR_CAN); elevatorEncoder=new Encoder(0,1,false); offset=0; height=0; From 4717e6f029f31e202385a1d75e66800272dbe99c Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Mon, 2 Feb 2015 20:08:04 -0500 Subject: [PATCH 29/64] Call End when commands are interrupted --- Commands/CloseCollector.cpp | 1 + Commands/CollectTote.cpp | 1 + Commands/Compressor/StartCompressing.cpp | 1 + Commands/Compressor/StopCompressing.cpp | 1 + Commands/Drive.cpp | 1 + Commands/OpenCollector.cpp | 1 + Commands/ReleaseTote.cpp | 1 + 7 files changed, 7 insertions(+) diff --git a/Commands/CloseCollector.cpp b/Commands/CloseCollector.cpp index b415152..92b1362 100644 --- a/Commands/CloseCollector.cpp +++ b/Commands/CloseCollector.cpp @@ -14,4 +14,5 @@ bool CloseCollector::IsFinished(){ void CloseCollector::End(){ } void CloseCollector::Interrupted(){ + End(); } diff --git a/Commands/CollectTote.cpp b/Commands/CollectTote.cpp index f28c974..ce8ed62 100644 --- a/Commands/CollectTote.cpp +++ b/Commands/CollectTote.cpp @@ -14,4 +14,5 @@ bool CollectTote::IsFinished(){ void CollectTote::End(){ } void CollectTote::Interrupted(){ + End(); } diff --git a/Commands/Compressor/StartCompressing.cpp b/Commands/Compressor/StartCompressing.cpp index b71d975..50425b5 100644 --- a/Commands/Compressor/StartCompressing.cpp +++ b/Commands/Compressor/StartCompressing.cpp @@ -14,4 +14,5 @@ bool StartCompressing::IsFinished(){ void StartCompressing::End(){ } void StartCompressing::Interrupted(){ + End(); } diff --git a/Commands/Compressor/StopCompressing.cpp b/Commands/Compressor/StopCompressing.cpp index 009ae4f..4ef05fb 100644 --- a/Commands/Compressor/StopCompressing.cpp +++ b/Commands/Compressor/StopCompressing.cpp @@ -14,4 +14,5 @@ bool StopCompressing::IsFinished(){ void StopCompressing::End(){ } void StopCompressing::Interrupted(){ + End(); } diff --git a/Commands/Drive.cpp b/Commands/Drive.cpp index d4dfdbd..7c82425 100644 --- a/Commands/Drive.cpp +++ b/Commands/Drive.cpp @@ -30,4 +30,5 @@ bool Drive::IsFinished(){ void Drive::End(){ } void Drive::Interrupted(){ + End(); } diff --git a/Commands/OpenCollector.cpp b/Commands/OpenCollector.cpp index bbd00c5..d3a6133 100644 --- a/Commands/OpenCollector.cpp +++ b/Commands/OpenCollector.cpp @@ -14,4 +14,5 @@ bool OpenCollector::IsFinished(){ void OpenCollector::End(){ } void OpenCollector::Interrupted(){ + End(); } diff --git a/Commands/ReleaseTote.cpp b/Commands/ReleaseTote.cpp index 21b6e2a..e1b1e89 100644 --- a/Commands/ReleaseTote.cpp +++ b/Commands/ReleaseTote.cpp @@ -14,4 +14,5 @@ bool ReleaseTote::IsFinished(){ void ReleaseTote::End(){ } void ReleaseTote::Interrupted(){ + End(); } From 7f3a5044729566f3e8fb4d7c4ebace90aa41f96c Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Mon, 2 Feb 2015 20:43:22 -0500 Subject: [PATCH 30/64] Fixed indentation --- Commands/CloseCollector.cpp | 6 +++--- Commands/CollectTote.cpp | 8 ++++---- Commands/Drive.cpp | 6 +++--- Commands/ReleaseTote.cpp | 8 ++++---- DentRobot.h | 34 +++++++++++++++++----------------- OI.cpp | 4 ++++ Subsystems/AirCompressor.h | 2 +- Subsystems/Collector.h | 4 ++-- 8 files changed, 38 insertions(+), 34 deletions(-) diff --git a/Commands/CloseCollector.cpp b/Commands/CloseCollector.cpp index 92b1362..3a956f4 100644 --- a/Commands/CloseCollector.cpp +++ b/Commands/CloseCollector.cpp @@ -1,15 +1,15 @@ #include "CloseCollector.h" CloseCollector::CloseCollector() : Command("CloseCollector"){ - Requires(DentRobot::collector); + Requires(DentRobot::collector); } void CloseCollector::Initialize(){ SetTimeout(0.5); } void CloseCollector::Execute(){ - DentRobot::collector->MoveArms(.1); + DentRobot::collector->MoveArms(.1); } bool CloseCollector::IsFinished(){ - return DentRobot::collector->ArmSensor(); + return DentRobot::collector->ArmSensor(); } void CloseCollector::End(){ } diff --git a/Commands/CollectTote.cpp b/Commands/CollectTote.cpp index ce8ed62..c634fcb 100644 --- a/Commands/CollectTote.cpp +++ b/Commands/CollectTote.cpp @@ -1,15 +1,15 @@ #include "CollectTote.h" CollectTote::CollectTote() : Command("CollectTote"){ - Requires(DentRobot::collector); + Requires(DentRobot::collector); } void CollectTote::Initialize(){ } void CollectTote::Execute(){ - //TODO check this value to move the motors in the right direction - DentRobot::collector->MoveRollers(-1); + //TODO check this value to move the motors in the right direction + DentRobot::collector->MoveRollers(-1); } bool CollectTote::IsFinished(){ - return DentRobot::collector->BoxCollected(); + return DentRobot::collector->BoxCollected(); } void CollectTote::End(){ } diff --git a/Commands/Drive.cpp b/Commands/Drive.cpp index 7c82425..5882880 100644 --- a/Commands/Drive.cpp +++ b/Commands/Drive.cpp @@ -2,7 +2,7 @@ #include #include "../DentRobot.h" Drive::Drive() : Command("Drive"){ - Requires(DentRobot::drivetrain); + Requires(DentRobot::drivetrain); } void Drive::Initialize(){ } @@ -18,8 +18,8 @@ void Drive::Execute(){ z = DentRobot::oi->GetLeftStick()->GetRawAxis(2); y = DentRobot::oi->GetLeftStick()->GetRawAxis(1); if (DentRobot::oi->GetLeftStick()->GetRawAxis(3)<=0.5){ - y /= 2; - z /= 2; + 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/ReleaseTote.cpp b/Commands/ReleaseTote.cpp index e1b1e89..67306ad 100644 --- a/Commands/ReleaseTote.cpp +++ b/Commands/ReleaseTote.cpp @@ -1,15 +1,15 @@ #include "ReleaseTote.h" ReleaseTote::ReleaseTote() : Command("ReleaseTote"){ - Requires(DentRobot::collector); + Requires(DentRobot::collector); } void ReleaseTote::Initialize(){ } void ReleaseTote::Execute(){ - //TODO check this value to move the motors in the right direction - DentRobot::collector->MoveRollers(1); + //TODO check this value to move the motors in the right direction + DentRobot::collector->MoveRollers(1); } bool ReleaseTote::IsFinished(){ - return DentRobot::collector->BoxCollected(); + return DentRobot::collector->BoxCollected(); } void ReleaseTote::End(){ } diff --git a/DentRobot.h b/DentRobot.h index 000a33e..653114a 100644 --- a/DentRobot.h +++ b/DentRobot.h @@ -8,23 +8,23 @@ #include "Subsystems/Collector.h" #include "Subsystems/AirCompressor.h" class DentRobot: public IterativeRobot { -private: - Command *driveCommand = NULL; -public: - static OI* oi; - static Collector* collector; - static Drivetrain* drivetrain; - static Elevator* elevator; - static DIO* dio; - static AirCompressor* airCompressor; - DentRobot(); - void RobotInit(); - void DisabledPeriodic(); - void AutonomousInit(); - void AutonomousPeriodic(); - void TeleopInit(); - void TeleopPeriodic(); - void TestPeriodic(); + private: + Command *driveCommand = NULL; + public: + static OI* oi; + static Collector* collector; + static Drivetrain* drivetrain; + static Elevator* elevator; + static DIO* dio; + static AirCompressor* airCompressor; + DentRobot(); + void RobotInit(); + void DisabledPeriodic(); + void AutonomousInit(); + void AutonomousPeriodic(); + void TeleopInit(); + void TeleopPeriodic(); + void TestPeriodic(); }; #endif // vim: ts=2:sw=2:et diff --git a/OI.cpp b/OI.cpp index a2c9e66..dc49b63 100644 --- a/OI.cpp +++ b/OI.cpp @@ -16,10 +16,14 @@ OI::OI() { 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->WhenPressed(new OpenCollector()); right2->WhenPressed(new CloseCollector()); right3->WhenPressed(new CollectTote()); right4->WhenPressed(new ReleaseTote()); + right5->WhenPressed(new StartCompressing()); + right6->WhenPressed(new StopCompressing()); } Joystick* OI::GetRightStick(){ return rightStick; diff --git a/Subsystems/AirCompressor.h b/Subsystems/AirCompressor.h index ca48f25..df9ec00 100644 --- a/Subsystems/AirCompressor.h +++ b/Subsystems/AirCompressor.h @@ -5,7 +5,7 @@ class AirCompressor: public Subsystem { private: - Compressor *compressor; + Compressor *compressor; public: AirCompressor(); void InitDefaultCommand(); diff --git a/Subsystems/Collector.h b/Subsystems/Collector.h index f5bc658..5302835 100644 --- a/Subsystems/Collector.h +++ b/Subsystems/Collector.h @@ -5,8 +5,8 @@ class Collector: public Subsystem { private: - CANTalon *windowMotorLeft, *windowMotorRight, *collectorMotorLeft, *collectorMotorRight; - DigitalInput *boxSwitch; + CANTalon *windowMotorLeft, *windowMotorRight, *collectorMotorLeft, *collectorMotorRight; + DigitalInput *boxSwitch; public: Collector(); void InitDefaultCommand(); From b783a2604cd555a7f9df10cc7abb72e284d71f46 Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Tue, 3 Feb 2015 15:20:10 -0500 Subject: [PATCH 31/64] Added todo.txt, elevator support --- OI.cpp | 4 ++++ RobotMap.h | 20 ++++++++++---------- TODO.txt | 4 ++++ 3 files changed, 18 insertions(+), 10 deletions(-) create mode 100644 TODO.txt diff --git a/OI.cpp b/OI.cpp index dc49b63..545da24 100644 --- a/OI.cpp +++ b/OI.cpp @@ -18,12 +18,16 @@ OI::OI() { JoystickButton *right4=new JoystickButton(rightStick, 4); JoystickButton *right5=new JoystickButton(rightStick, 5); JoystickButton *right6=new JoystickButton(rightStick, 6); + JoystickButton *right7=new JoystickButton(rightStick, 7); + JoystickButton *right8=new JoystickButton(rightStick, 8); right1->WhenPressed(new OpenCollector()); right2->WhenPressed(new CloseCollector()); right3->WhenPressed(new CollectTote()); right4->WhenPressed(new ReleaseTote()); right5->WhenPressed(new StartCompressing()); right6->WhenPressed(new StopCompressing()); + right7->WhenPressed(new Raise()); + right8->WhenPressed(new Lower()); } Joystick* OI::GetRightStick(){ return rightStick; diff --git a/RobotMap.h b/RobotMap.h index 294feab..bd596cf 100644 --- a/RobotMap.h +++ b/RobotMap.h @@ -4,22 +4,22 @@ #include "WPILib.h" // Elevator -#define ELEVATOR_CAN 0 +#define ELEVATOR_CAN 1 // Drivetrain -#define DRIVE_FRONT_LEFT_CAN 41 -#define DRIVE_BACK_LEFT_CAN 43 -#define DRIVE_FRONT_RIGHT_CAN 40 -#define DRIVE_BACK_RIGHT_CAN 42 +#define DRIVE_FRONT_LEFT_CAN 2 +#define DRIVE_BACK_LEFT_CAN 3 +#define DRIVE_FRONT_RIGHT_CAN 4 +#define DRIVE_BACK_RIGHT_CAN 5 // Collector -#define COLLECTOR_WINDOW_LEFT_CAN 50 -#define COLLECTOR_WINDOW_RIGHT_CAN 51 -#define COLLECTOR_LEFT_CAN 52 -#define COLLECTOR_RIGHT_CAN 53 +#define COLLECTOR_WINDOW_LEFT_CAN 6 +#define COLLECTOR_WINDOW_RIGHT_CAN 7 +#define COLLECTOR_LEFT_CAN 8 +#define COLLECTOR_RIGHT_CAN 9 #define COLLECTOR_BOXSWITCH_DIO 9 // Compressor -#define COMPRESSOR_CAN 31 +#define COMPRESSOR_CAN 10 #endif diff --git a/TODO.txt b/TODO.txt new file mode 100644 index 0000000..a386c8a --- /dev/null +++ b/TODO.txt @@ -0,0 +1,4 @@ +Release for all buttons does not work +raise is pushed, elevator raises, lower is pushed, elevator lowers, raise is pushed, no effect +lower is pushed, elevator lowers, raise is pushed, no effect +dos compressor on compressor start or stop From 5ac16f85d4a9e4a9a04b8a25b088e95cab40a4d1 Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Tue, 3 Feb 2015 15:55:11 -0500 Subject: [PATCH 32/64] Moved commands into directories (untested) --- CommandBase.cpp | 16 ++++++++-------- Commands/{ => Collector}/CloseCollector.cpp | 0 Commands/{ => Collector}/CloseCollector.h | 4 ++-- Commands/{ => Collector}/CollectTote.cpp | 0 Commands/{ => Collector}/CollectTote.h | 4 ++-- Commands/{ => Collector}/OpenCollector.cpp | 0 Commands/{ => Collector}/OpenCollector.h | 4 ++-- Commands/{ => Collector}/ReleaseTote.cpp | 0 Commands/{ => Collector}/ReleaseTote.h | 4 ++-- Commands/{ => Drivetrain}/Drive.cpp | 2 +- Commands/{ => Drivetrain}/Drive.h | 4 ++-- Commands/{ => Elevator}/Calibrate.cpp | 2 +- Commands/{ => Elevator}/Calibrate.h | 0 Commands/{ => Elevator}/Lower.cpp | 2 +- Commands/{ => Elevator}/Lower.h | 0 Commands/{ => Elevator}/Raise.cpp | 2 +- Commands/{ => Elevator}/Raise.h | 0 OI.cpp | 12 ++++++------ Subsystems/Drivetrain.cpp | 2 +- 19 files changed, 29 insertions(+), 29 deletions(-) rename Commands/{ => Collector}/CloseCollector.cpp (100%) rename Commands/{ => Collector}/CloseCollector.h (82%) rename Commands/{ => Collector}/CollectTote.cpp (100%) rename Commands/{ => Collector}/CollectTote.h (82%) rename Commands/{ => Collector}/OpenCollector.cpp (100%) rename Commands/{ => Collector}/OpenCollector.h (82%) rename Commands/{ => Collector}/ReleaseTote.cpp (100%) rename Commands/{ => Collector}/ReleaseTote.h (82%) rename Commands/{ => Drivetrain}/Drive.cpp (96%) rename Commands/{ => Drivetrain}/Drive.h (80%) rename Commands/{ => Elevator}/Calibrate.cpp (95%) rename Commands/{ => Elevator}/Calibrate.h (100%) rename Commands/{ => Elevator}/Lower.cpp (90%) rename Commands/{ => Elevator}/Lower.h (100%) rename Commands/{ => Elevator}/Raise.cpp (90%) rename Commands/{ => Elevator}/Raise.h (100%) diff --git a/CommandBase.cpp b/CommandBase.cpp index a517bee..0b28ca5 100644 --- a/CommandBase.cpp +++ b/CommandBase.cpp @@ -4,14 +4,14 @@ #include "Subsystems/Elevator.h" #include "Subsystems/DIO.h" #include "Subsystems/AirCompressor.h" -#include "Commands/Drive.h" -#include "Commands/CloseCollector.h" -#include "Commands/OpenCollector.h" -#include "Commands/CollectTote.h" -#include "Commands/ReleaseTote.h" -#include "Commands/Raise.h" -#include "Commands/Lower.h" -#include "Commands/Calibrate.h" +//#include "Commands/Drive.h" +//#include "Commands/CloseCollector.h" +//#include "Commands/OpenCollector.h" +//#include "Commands/CollectTote.h" +//#include "Commands/ReleaseTote.h" +//#include "Commands/Raise.h" +//#include "Commands/Lower.h" +//#include "Commands/Calibrate.h" Drivetrain* CommandBase::drivetrain = NULL; Collector* CommandBase::collector = NULL; Elevator* CommandBase::elevator = NULL; diff --git a/Commands/CloseCollector.cpp b/Commands/Collector/CloseCollector.cpp similarity index 100% rename from Commands/CloseCollector.cpp rename to Commands/Collector/CloseCollector.cpp diff --git a/Commands/CloseCollector.h b/Commands/Collector/CloseCollector.h similarity index 82% rename from Commands/CloseCollector.h rename to Commands/Collector/CloseCollector.h index aaf6776..3042699 100644 --- a/Commands/CloseCollector.h +++ b/Commands/Collector/CloseCollector.h @@ -2,8 +2,8 @@ #define CLOSECOLLECTOR_H #include "Commands/Command.h" -#include "../CommandBase.h" -#include "../DentRobot.h" +#include "../../CommandBase.h" +#include "../../DentRobot.h" #include "WPILib.h" class CloseCollector: public Command{ diff --git a/Commands/CollectTote.cpp b/Commands/Collector/CollectTote.cpp similarity index 100% rename from Commands/CollectTote.cpp rename to Commands/Collector/CollectTote.cpp diff --git a/Commands/CollectTote.h b/Commands/Collector/CollectTote.h similarity index 82% rename from Commands/CollectTote.h rename to Commands/Collector/CollectTote.h index 370cc51..c06fac3 100644 --- a/Commands/CollectTote.h +++ b/Commands/Collector/CollectTote.h @@ -2,8 +2,8 @@ #define COLLECTTOTE_H #include "Commands/Command.h" -#include "../CommandBase.h" -#include "../DentRobot.h" +#include "../../CommandBase.h" +#include "../../DentRobot.h" #include "WPILib.h" class CollectTote: public Command{ diff --git a/Commands/OpenCollector.cpp b/Commands/Collector/OpenCollector.cpp similarity index 100% rename from Commands/OpenCollector.cpp rename to Commands/Collector/OpenCollector.cpp diff --git a/Commands/OpenCollector.h b/Commands/Collector/OpenCollector.h similarity index 82% rename from Commands/OpenCollector.h rename to Commands/Collector/OpenCollector.h index 2264a1a..c75b20b 100644 --- a/Commands/OpenCollector.h +++ b/Commands/Collector/OpenCollector.h @@ -2,8 +2,8 @@ #define OPENCOLLECTOR_H #include "Commands/Command.h" -#include "../CommandBase.h" -#include "../DentRobot.h" +#include "../../CommandBase.h" +#include "../../DentRobot.h" #include "WPILib.h" class OpenCollector: public Command{ diff --git a/Commands/ReleaseTote.cpp b/Commands/Collector/ReleaseTote.cpp similarity index 100% rename from Commands/ReleaseTote.cpp rename to Commands/Collector/ReleaseTote.cpp diff --git a/Commands/ReleaseTote.h b/Commands/Collector/ReleaseTote.h similarity index 82% rename from Commands/ReleaseTote.h rename to Commands/Collector/ReleaseTote.h index 9d6b7fd..deacad9 100644 --- a/Commands/ReleaseTote.h +++ b/Commands/Collector/ReleaseTote.h @@ -2,8 +2,8 @@ #define RELEASETOTE_H #include "Commands/Command.h" -#include "../CommandBase.h" -#include "../DentRobot.h" +#include "../../CommandBase.h" +#include "../../DentRobot.h" #include "WPILib.h" class ReleaseTote: public Command{ diff --git a/Commands/Drive.cpp b/Commands/Drivetrain/Drive.cpp similarity index 96% rename from Commands/Drive.cpp rename to Commands/Drivetrain/Drive.cpp index 5882880..9d0e199 100644 --- a/Commands/Drive.cpp +++ b/Commands/Drivetrain/Drive.cpp @@ -1,6 +1,6 @@ #include "Drive.h" #include -#include "../DentRobot.h" +#include "../../DentRobot.h" Drive::Drive() : Command("Drive"){ Requires(DentRobot::drivetrain); } diff --git a/Commands/Drive.h b/Commands/Drivetrain/Drive.h similarity index 80% rename from Commands/Drive.h rename to Commands/Drivetrain/Drive.h index 258cbc1..4ecc4eb 100644 --- a/Commands/Drive.h +++ b/Commands/Drivetrain/Drive.h @@ -1,9 +1,9 @@ #ifndef DRIVE_H #define DRIVE_H -#include "../CommandBase.h" -#include "../DentRobot.h" #include "Commands/Command.h" +#include "../../CommandBase.h" +#include "../../DentRobot.h" #include "WPILib.h" class Drive: public Command{ diff --git a/Commands/Calibrate.cpp b/Commands/Elevator/Calibrate.cpp similarity index 95% rename from Commands/Calibrate.cpp rename to Commands/Elevator/Calibrate.cpp index 411dc03..2132127 100644 --- a/Commands/Calibrate.cpp +++ b/Commands/Elevator/Calibrate.cpp @@ -1,5 +1,5 @@ #include "Calibrate.h" -#include "../DentRobot.h" +#include "../../DentRobot.h" // Lowers elevator until it hits the limit switch then sets the height of the elevator to the height of the limit switches Calibrate::Calibrate() : Command("Calibrate"){ } diff --git a/Commands/Calibrate.h b/Commands/Elevator/Calibrate.h similarity index 100% rename from Commands/Calibrate.h rename to Commands/Elevator/Calibrate.h diff --git a/Commands/Lower.cpp b/Commands/Elevator/Lower.cpp similarity index 90% rename from Commands/Lower.cpp rename to Commands/Elevator/Lower.cpp index 38b6c94..e3c44ab 100644 --- a/Commands/Lower.cpp +++ b/Commands/Elevator/Lower.cpp @@ -1,5 +1,5 @@ #include "Lower.h" -#include "../DentRobot.h" +#include "../../DentRobot.h" Lower::Lower() : Command("Lower"){ } void Lower::Initialize(){ diff --git a/Commands/Lower.h b/Commands/Elevator/Lower.h similarity index 100% rename from Commands/Lower.h rename to Commands/Elevator/Lower.h diff --git a/Commands/Raise.cpp b/Commands/Elevator/Raise.cpp similarity index 90% rename from Commands/Raise.cpp rename to Commands/Elevator/Raise.cpp index e2e7107..0335cc5 100644 --- a/Commands/Raise.cpp +++ b/Commands/Elevator/Raise.cpp @@ -1,5 +1,5 @@ #include "Raise.h" -#include "../DentRobot.h" +#include "../../DentRobot.h" Raise::Raise(){ } void Raise::Initialize(){ diff --git a/Commands/Raise.h b/Commands/Elevator/Raise.h similarity index 100% rename from Commands/Raise.h rename to Commands/Elevator/Raise.h diff --git a/OI.cpp b/OI.cpp index 545da24..c1e46c7 100644 --- a/OI.cpp +++ b/OI.cpp @@ -1,10 +1,10 @@ #include "OI.h" -#include "Commands/Lower.h" -#include "Commands/Raise.h" -#include "Commands/OpenCollector.h" -#include "Commands/CloseCollector.h" -#include "Commands/CollectTote.h" -#include "Commands/ReleaseTote.h" +#include "Commands/Elevator/Lower.h" +#include "Commands/Elevator/Raise.h" +#include "Commands/Collector/OpenCollector.h" +#include "Commands/Collector/CloseCollector.h" +#include "Commands/Collector/CollectTote.h" +#include "Commands/Collector/ReleaseTote.h" #include "Commands/Compressor/StartCompressing.h" #include "Commands/Compressor/StopCompressing.h" diff --git a/Subsystems/Drivetrain.cpp b/Subsystems/Drivetrain.cpp index 1ba7c9b..80df4e7 100644 --- a/Subsystems/Drivetrain.cpp +++ b/Subsystems/Drivetrain.cpp @@ -1,6 +1,6 @@ #include "Drivetrain.h" #include "../RobotMap.h" -#include "../Commands/Drive.h" +#include "../Commands/Drivetrain/Drive.h" Drivetrain::Drivetrain() : Subsystem("Drivetrain"){ rightFront = new CANTalon(DRIVE_FRONT_RIGHT_CAN); From ed2ae766fb390380d4f06138e78c3f9d1a20860a Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Wed, 4 Feb 2015 11:15:21 -0500 Subject: [PATCH 33/64] Stop motors when button is released (untested) --- Commands/Collector/CloseCollector.cpp | 3 ++- Commands/Collector/CollectTote.cpp | 3 ++- Commands/Collector/OpenCollector.cpp | 3 ++- Commands/Collector/ReleaseTote.cpp | 3 ++- OI.cpp | 34 ++++++++++++++------------- Subsystems/AirCompressor.cpp | 12 ++++++---- 6 files changed, 34 insertions(+), 24 deletions(-) diff --git a/Commands/Collector/CloseCollector.cpp b/Commands/Collector/CloseCollector.cpp index 3a956f4..5dc5e07 100644 --- a/Commands/Collector/CloseCollector.cpp +++ b/Commands/Collector/CloseCollector.cpp @@ -6,12 +6,13 @@ void CloseCollector::Initialize(){ SetTimeout(0.5); } void CloseCollector::Execute(){ - DentRobot::collector->MoveArms(.1); + DentRobot::collector->MoveArms(0.1f); } bool CloseCollector::IsFinished(){ return DentRobot::collector->ArmSensor(); } void CloseCollector::End(){ + DentRobot::collector->MoveArms(0.0f); } void CloseCollector::Interrupted(){ End(); diff --git a/Commands/Collector/CollectTote.cpp b/Commands/Collector/CollectTote.cpp index c634fcb..1623d53 100644 --- a/Commands/Collector/CollectTote.cpp +++ b/Commands/Collector/CollectTote.cpp @@ -6,12 +6,13 @@ void CollectTote::Initialize(){ } void CollectTote::Execute(){ //TODO check this value to move the motors in the right direction - DentRobot::collector->MoveRollers(-1); + DentRobot::collector->MoveRollers(-1.0); } bool CollectTote::IsFinished(){ return DentRobot::collector->BoxCollected(); } void CollectTote::End(){ + DentRobot::collector->MoveRollers(0.0f); } void CollectTote::Interrupted(){ End(); diff --git a/Commands/Collector/OpenCollector.cpp b/Commands/Collector/OpenCollector.cpp index d3a6133..54928c5 100644 --- a/Commands/Collector/OpenCollector.cpp +++ b/Commands/Collector/OpenCollector.cpp @@ -6,12 +6,13 @@ void OpenCollector::Initialize(){ } void OpenCollector::Execute(){ //TODO check this value to move the motors in the right direction - DentRobot::collector->MoveArms(-.1); + DentRobot::collector->MoveArms(-0.1); } bool OpenCollector::IsFinished(){ return DentRobot::collector->ArmSensor(); } void OpenCollector::End(){ + DentRobot::collector->MoveArms(0.0f); } void OpenCollector::Interrupted(){ End(); diff --git a/Commands/Collector/ReleaseTote.cpp b/Commands/Collector/ReleaseTote.cpp index 67306ad..2f7d6ff 100644 --- a/Commands/Collector/ReleaseTote.cpp +++ b/Commands/Collector/ReleaseTote.cpp @@ -6,12 +6,13 @@ void ReleaseTote::Initialize(){ } void ReleaseTote::Execute(){ //TODO check this value to move the motors in the right direction - DentRobot::collector->MoveRollers(1); + DentRobot::collector->MoveRollers(1.0f); } bool ReleaseTote::IsFinished(){ return DentRobot::collector->BoxCollected(); } void ReleaseTote::End(){ + DentRobot::collector->MoveRollers(0.0f); } void ReleaseTote::Interrupted(){ End(); diff --git a/OI.cpp b/OI.cpp index c1e46c7..5910d71 100644 --- a/OI.cpp +++ b/OI.cpp @@ -5,6 +5,8 @@ #include "Commands/Collector/CloseCollector.h" #include "Commands/Collector/CollectTote.h" #include "Commands/Collector/ReleaseTote.h" +#include "Commands/Collector/StopCollector.h" +#include "Commands/Collector/StopArm.h" #include "Commands/Compressor/StartCompressing.h" #include "Commands/Compressor/StopCompressing.h" @@ -12,22 +14,22 @@ OI::OI() { leftStick=new Joystick(0); rightStick=new Joystick(1); //TODO name these buttons to their functions rather to their number - 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); - JoystickButton *right7=new JoystickButton(rightStick, 7); - JoystickButton *right8=new JoystickButton(rightStick, 8); - right1->WhenPressed(new OpenCollector()); - right2->WhenPressed(new CloseCollector()); - right3->WhenPressed(new CollectTote()); - right4->WhenPressed(new ReleaseTote()); - right5->WhenPressed(new StartCompressing()); - right6->WhenPressed(new StopCompressing()); - right7->WhenPressed(new Raise()); - right8->WhenPressed(new Lower()); + 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); + JoystickButton *left7=new JoystickButton(leftStick, 7); + JoystickButton *left8=new JoystickButton(leftStick, 8); + left1->WhileHeld(new OpenCollector()); + left2->WhileHeld(new CloseCollector()); + left3->WhileHeld(new CollectTote()); + left4->WhileHeld(new ReleaseTote()); + left5->WhileHeld(new StartCompressing()); + left6->WhileHeld(new StopCompressing()); + left7->WhileHeld(new Raise()); + left8->WhileHeld(new Lower()); } Joystick* OI::GetRightStick(){ return rightStick; diff --git a/Subsystems/AirCompressor.cpp b/Subsystems/AirCompressor.cpp index b813d9b..b63ff8b 100644 --- a/Subsystems/AirCompressor.cpp +++ b/Subsystems/AirCompressor.cpp @@ -7,10 +7,14 @@ AirCompressor::AirCompressor() : Subsystem("AirCompressor") { void AirCompressor::InitDefaultCommand() { } void AirCompressor::StartCompressing() { - printf("Starting compressor\n"); - compressor->Start(); + if(compressor->Enabled()){ + printf("Starting compressor\n"); + compressor->Start(); + } } void AirCompressor::StopCompressing() { - printf("Stopping compressor\n"); - compressor->Stop(); + if(compressor->Enabled()){ + printf("Stopping compressor\n"); + compressor->Stop(); + } } From 578efd7a88802ba4e3d99405abb1940fa5d5aff8 Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Wed, 4 Feb 2015 20:57:33 -0500 Subject: [PATCH 34/64] Robot works, used throttle to control power of collcetor/elevator --- Commands/Collector/CollectTote.cpp | 5 +++-- Commands/Collector/ReleaseTote.cpp | 3 ++- Commands/Elevator/Lower.cpp | 2 +- Commands/Elevator/Raise.cpp | 3 ++- OI.cpp | 11 ++--------- Subsystems/Collector.cpp | 6 ++++-- Subsystems/Collector.h | 2 +- TODO.txt | 6 ++---- 8 files changed, 17 insertions(+), 21 deletions(-) diff --git a/Commands/Collector/CollectTote.cpp b/Commands/Collector/CollectTote.cpp index 1623d53..9780b39 100644 --- a/Commands/Collector/CollectTote.cpp +++ b/Commands/Collector/CollectTote.cpp @@ -6,13 +6,14 @@ void CollectTote::Initialize(){ } void CollectTote::Execute(){ //TODO check this value to move the motors in the right direction - DentRobot::collector->MoveRollers(-1.0); + printf("collecting tote\n"); + DentRobot::collector->MoveRollers(-(-DentRobot::oi->GetLeftStick()->GetRawAxis(3)+1.0)/2); } bool CollectTote::IsFinished(){ return DentRobot::collector->BoxCollected(); } void CollectTote::End(){ - DentRobot::collector->MoveRollers(0.0f); + DentRobot::collector->MoveRollers(0.0); } void CollectTote::Interrupted(){ End(); diff --git a/Commands/Collector/ReleaseTote.cpp b/Commands/Collector/ReleaseTote.cpp index 2f7d6ff..90ceaab 100644 --- a/Commands/Collector/ReleaseTote.cpp +++ b/Commands/Collector/ReleaseTote.cpp @@ -6,7 +6,8 @@ void ReleaseTote::Initialize(){ } void ReleaseTote::Execute(){ //TODO check this value to move the motors in the right direction - DentRobot::collector->MoveRollers(1.0f); + printf("releasing tote\n"); + DentRobot::collector->MoveRollers((-DentRobot::oi->GetLeftStick()->GetRawAxis(3)+1.0)/2); } bool ReleaseTote::IsFinished(){ return DentRobot::collector->BoxCollected(); diff --git a/Commands/Elevator/Lower.cpp b/Commands/Elevator/Lower.cpp index e3c44ab..e33f3b2 100644 --- a/Commands/Elevator/Lower.cpp +++ b/Commands/Elevator/Lower.cpp @@ -5,7 +5,7 @@ Lower::Lower() : Command("Lower"){ void Lower::Initialize(){ } void Lower::Execute(){ - DentRobot::elevator->Run(-0.4f); + DentRobot::elevator->Run((-DentRobot::oi->GetLeftStick()->GetRawAxis(3)+1.0)/2); } bool Lower::IsFinished(){ return false; diff --git a/Commands/Elevator/Raise.cpp b/Commands/Elevator/Raise.cpp index 0335cc5..ce1248f 100644 --- a/Commands/Elevator/Raise.cpp +++ b/Commands/Elevator/Raise.cpp @@ -1,11 +1,12 @@ #include "Raise.h" #include "../../DentRobot.h" +#include "../../OI.h" Raise::Raise(){ } void Raise::Initialize(){ } void Raise::Execute(){ - DentRobot::elevator->Run(0.4f); + DentRobot::elevator->Run(-(-DentRobot::oi->GetLeftStick()->GetRawAxis(3)+1.0)/2); } bool Raise::IsFinished(){ return false; diff --git a/OI.cpp b/OI.cpp index 5910d71..4fc58f9 100644 --- a/OI.cpp +++ b/OI.cpp @@ -5,10 +5,7 @@ #include "Commands/Collector/CloseCollector.h" #include "Commands/Collector/CollectTote.h" #include "Commands/Collector/ReleaseTote.h" -#include "Commands/Collector/StopCollector.h" -#include "Commands/Collector/StopArm.h" #include "Commands/Compressor/StartCompressing.h" -#include "Commands/Compressor/StopCompressing.h" OI::OI() { leftStick=new Joystick(0); @@ -20,16 +17,12 @@ OI::OI() { JoystickButton *left4=new JoystickButton(leftStick, 4); JoystickButton *left5=new JoystickButton(leftStick, 5); JoystickButton *left6=new JoystickButton(leftStick, 6); - JoystickButton *left7=new JoystickButton(leftStick, 7); - JoystickButton *left8=new JoystickButton(leftStick, 8); left1->WhileHeld(new OpenCollector()); left2->WhileHeld(new CloseCollector()); left3->WhileHeld(new CollectTote()); left4->WhileHeld(new ReleaseTote()); - left5->WhileHeld(new StartCompressing()); - left6->WhileHeld(new StopCompressing()); - left7->WhileHeld(new Raise()); - left8->WhileHeld(new Lower()); + left5->WhileHeld(new Raise()); + left6->WhileHeld(new Lower()); } Joystick* OI::GetRightStick(){ return rightStick; diff --git a/Subsystems/Collector.cpp b/Subsystems/Collector.cpp index 563eb54..b05c76c 100644 --- a/Subsystems/Collector.cpp +++ b/Subsystems/Collector.cpp @@ -14,7 +14,8 @@ void Collector::MoveArms(float a){ windowMotorLeft->Set(a); windowMotorRight->Set(-a); } -void Collector::MoveRollers(float a){ +void Collector::MoveRollers(double a){ + printf("Collector: %f\n", a); collectorMotorLeft->Set(a); collectorMotorRight->Set(-a); } @@ -23,5 +24,6 @@ bool Collector::ArmSensor(){ return false; } bool Collector::BoxCollected(){ - return boxSwitch->Get(); + return false; + //return boxSwitch->Get(); } diff --git a/Subsystems/Collector.h b/Subsystems/Collector.h index 5302835..ef5acf3 100644 --- a/Subsystems/Collector.h +++ b/Subsystems/Collector.h @@ -11,7 +11,7 @@ class Collector: public Subsystem Collector(); void InitDefaultCommand(); void MoveArms(float); - void MoveRollers(float); + void MoveRollers(double); bool ArmSensor(); bool BoxCollected(); }; diff --git a/TODO.txt b/TODO.txt index a386c8a..0f710ce 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,4 +1,2 @@ -Release for all buttons does not work -raise is pushed, elevator raises, lower is pushed, elevator lowers, raise is pushed, no effect -lower is pushed, elevator lowers, raise is pushed, no effect -dos compressor on compressor start or stop +Compressor isn't in use + (dos compressor on compressor start or stop)? From 3ee24abcedb1229c01011359ece18a2b55303276 Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Fri, 6 Feb 2015 11:01:28 -0500 Subject: [PATCH 35/64] Added .env file --- .env | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .env diff --git a/.env b/.env new file mode 100644 index 0000000..b9c7e51 --- /dev/null +++ b/.env @@ -0,0 +1,9 @@ +function mb(){ + ssh vagrant@127.0.0.1 -p 2222 -o Compression=yes -o DSAAuthentication=yes -o LogLevel=FATAL -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -i /home/stonewareslord/git/frc-cpp-vagrantfile/.vagrant/machines/default/virtualbox/private_key "cd /vagrant/src;make clean 2>&1 >/dev/null;make" +} +function mc(){ + ssh vagrant@127.0.0.1 -p 2222 -o Compression=yes -o DSAAuthentication=yes -o LogLevel=FATAL -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -i /home/stonewareslord/git/frc-cpp-vagrantfile/.vagrant/machines/default/virtualbox/private_key "cd /vagrant/src;make clean" +} +function mk(){ + ssh vagrant@127.0.0.1 -p 2222 -o Compression=yes -o DSAAuthentication=yes -o LogLevel=FATAL -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -i /home/stonewareslord/git/frc-cpp-vagrantfile/.vagrant/machines/default/virtualbox/private_key "cd /vagrant/src;make" +} From 28d266c8c2cb15afdd41bd829d54b84f155359cf Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Fri, 6 Feb 2015 13:45:01 -0500 Subject: [PATCH 36/64] Started working on autonomous --- CommandBase.cpp | 8 -------- Commands/Autonomous/AutoDrive.cpp | 21 +++++++++++++++++++++ Commands/Autonomous/AutoDrive.h | 18 ++++++++++++++++++ Commands/Autonomous/Autonomous.cpp | 20 ++++++++++++++++++++ Commands/Autonomous/Autonomous.h | 18 ++++++++++++++++++ 5 files changed, 77 insertions(+), 8 deletions(-) create mode 100644 Commands/Autonomous/AutoDrive.cpp create mode 100644 Commands/Autonomous/AutoDrive.h create mode 100644 Commands/Autonomous/Autonomous.cpp create mode 100644 Commands/Autonomous/Autonomous.h diff --git a/CommandBase.cpp b/CommandBase.cpp index 0b28ca5..c68ce0e 100644 --- a/CommandBase.cpp +++ b/CommandBase.cpp @@ -4,14 +4,6 @@ #include "Subsystems/Elevator.h" #include "Subsystems/DIO.h" #include "Subsystems/AirCompressor.h" -//#include "Commands/Drive.h" -//#include "Commands/CloseCollector.h" -//#include "Commands/OpenCollector.h" -//#include "Commands/CollectTote.h" -//#include "Commands/ReleaseTote.h" -//#include "Commands/Raise.h" -//#include "Commands/Lower.h" -//#include "Commands/Calibrate.h" Drivetrain* CommandBase::drivetrain = NULL; Collector* CommandBase::collector = NULL; Elevator* CommandBase::elevator = NULL; diff --git a/Commands/Autonomous/AutoDrive.cpp b/Commands/Autonomous/AutoDrive.cpp new file mode 100644 index 0000000..01718f2 --- /dev/null +++ b/Commands/Autonomous/AutoDrive.cpp @@ -0,0 +1,21 @@ +#include "AutoDrive.h" +#include +#include "../../DentRobot.h" +AutoDrive::AutoDrive() : Command("AutoDrive"){ + Requires(DentRobot::drivetrain); + SetTimeout(1.0); +} +void AutoDrive::Initialize(){ +} +void AutoDrive::Execute(){ + //X axis, Y axis, Z axis, sensitivity, speed threshold (usually throttle), gyro + DentRobot::drivetrain->DriveMecanum(0.5,0,0,0.9,0); +} +bool AutoDrive::IsFinished(){ + return false; +} +void AutoDrive::End(){ +} +void AutoDrive::Interrupted(){ + End(); +} diff --git a/Commands/Autonomous/AutoDrive.h b/Commands/Autonomous/AutoDrive.h new file mode 100644 index 0000000..f7538b2 --- /dev/null +++ b/Commands/Autonomous/AutoDrive.h @@ -0,0 +1,18 @@ +#ifndef AUTODRIVE_H +#define AUTODRIVE_H + +#include "Commands/Command.h" +#include "../../CommandBase.h" +#include "../../DentRobot.h" +#include "WPILib.h" + +class AutoDrive: public Command{ + public: + AutoDrive(); + void Initialize(); + void Execute(); + bool IsFinished(); + void End(); + void Interrupted(); +}; +#endif diff --git a/Commands/Autonomous/Autonomous.cpp b/Commands/Autonomous/Autonomous.cpp new file mode 100644 index 0000000..c3e2e3b --- /dev/null +++ b/Commands/Autonomous/Autonomous.cpp @@ -0,0 +1,20 @@ +#include "Autonomous.h" +#include "AutoDrive.h" +#include +#include "Commands/CommandGroup.h" +#include "../../DentRobot.h" +Autonomous::Autonomous() : CommandGroup("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 new file mode 100644 index 0000000..e584b17 --- /dev/null +++ b/Commands/Autonomous/Autonomous.h @@ -0,0 +1,18 @@ +#ifndef AUTONOMOUS_H +#define AUTONOMOUS_H + +#include "Commands/Command.h" +#include "../../CommandBase.h" +#include "../../DentRobot.h" +#include "WPILib.h" + +class Autonomous: public CommandGroup{ + public: + Autonomous(); + void Initialize(); + void Execute(); + bool IsFinished(); + void End(); + void Interrupted(); +}; +#endif From 095114b3a2eead23ad9ea01368bc095838a5a614 Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Fri, 6 Feb 2015 18:56:47 -0500 Subject: [PATCH 37/64] Fixed .env --- .env | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.env b/.env index b9c7e51..b4285c7 100644 --- a/.env +++ b/.env @@ -1,9 +1,9 @@ function mb(){ - ssh vagrant@127.0.0.1 -p 2222 -o Compression=yes -o DSAAuthentication=yes -o LogLevel=FATAL -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -i /home/stonewareslord/git/frc-cpp-vagrantfile/.vagrant/machines/default/virtualbox/private_key "cd /vagrant/src;make clean 2>&1 >/dev/null;make" + vagrant ssh -c "cd /vagrant/src;make clean 2>&1 >/dev/null;make" } function mc(){ - ssh vagrant@127.0.0.1 -p 2222 -o Compression=yes -o DSAAuthentication=yes -o LogLevel=FATAL -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -i /home/stonewareslord/git/frc-cpp-vagrantfile/.vagrant/machines/default/virtualbox/private_key "cd /vagrant/src;make clean" + vagrant ssh -c "cd /vagrant/src;make clean" } function mk(){ - ssh vagrant@127.0.0.1 -p 2222 -o Compression=yes -o DSAAuthentication=yes -o LogLevel=FATAL -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -i /home/stonewareslord/git/frc-cpp-vagrantfile/.vagrant/machines/default/virtualbox/private_key "cd /vagrant/src;make" + vagrant ssh -c "cd /vagrant/src;make" } From 32834cc28b391ad854cc089bd9d9aded9a0a69b3 Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Fri, 6 Feb 2015 20:17:26 -0500 Subject: [PATCH 38/64] Fixed drivetrain locking --- Commands/Drivetrain/Drive.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Commands/Drivetrain/Drive.cpp b/Commands/Drivetrain/Drive.cpp index 9d0e199..6d39788 100644 --- a/Commands/Drivetrain/Drive.cpp +++ b/Commands/Drivetrain/Drive.cpp @@ -9,14 +9,15 @@ void Drive::Initialize(){ void Drive::Execute(){ double x,y,z; //Code to lock the x axis when not holding button 1 - if (DentRobot::oi->GetLeftStick()->GetRawButton(1)){ - x = DentRobot::oi->GetLeftStick()->GetRawAxis(0); - x /= 1.3; - }else{ - x = 0; - } + x = DentRobot::oi->GetLeftStick()->GetRawAxis(0); z = DentRobot::oi->GetLeftStick()->GetRawAxis(2); y = DentRobot::oi->GetLeftStick()->GetRawAxis(1); + if (DentRobot::oi->GetLeftStick()->GetRawButton(1)){ + x=0; + } + if (DentRobot::oi->GetLeftStick()->GetRawButton(2)){ + y=0; + } if (DentRobot::oi->GetLeftStick()->GetRawAxis(3)<=0.5){ y /= 2; z /= 2; From 4494b9131a11bc58854507a948227fc8661dc3b3 Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Fri, 6 Feb 2015 20:38:02 -0500 Subject: [PATCH 39/64] Minor fixes (untested) --- Commands/Autonomous/AutoDrive.cpp | 1 + Commands/Collector/CollectTote.cpp | 1 + Commands/Collector/OpenCollector.cpp | 3 ++- Commands/Collector/ReleaseTote.cpp | 4 +++- Subsystems/Collector.cpp | 2 +- Subsystems/Collector.h | 2 +- 6 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Commands/Autonomous/AutoDrive.cpp b/Commands/Autonomous/AutoDrive.cpp index 01718f2..0eb43d6 100644 --- a/Commands/Autonomous/AutoDrive.cpp +++ b/Commands/Autonomous/AutoDrive.cpp @@ -1,6 +1,7 @@ #include "AutoDrive.h" #include #include "../../DentRobot.h" +// Drive for a short while then stop. Just for testing AutoDrive::AutoDrive() : Command("AutoDrive"){ Requires(DentRobot::drivetrain); SetTimeout(1.0); diff --git a/Commands/Collector/CollectTote.cpp b/Commands/Collector/CollectTote.cpp index 9780b39..e7fad0f 100644 --- a/Commands/Collector/CollectTote.cpp +++ b/Commands/Collector/CollectTote.cpp @@ -3,6 +3,7 @@ CollectTote::CollectTote() : Command("CollectTote"){ Requires(DentRobot::collector); } void CollectTote::Initialize(){ + SetTimeout(2.0); } void CollectTote::Execute(){ //TODO check this value to move the motors in the right direction diff --git a/Commands/Collector/OpenCollector.cpp b/Commands/Collector/OpenCollector.cpp index 54928c5..6e41cd4 100644 --- a/Commands/Collector/OpenCollector.cpp +++ b/Commands/Collector/OpenCollector.cpp @@ -3,10 +3,11 @@ OpenCollector::OpenCollector() : Command("OpenCollector"){ Requires(DentRobot::collector); } void OpenCollector::Initialize(){ + SetTimeout(0.5); } void OpenCollector::Execute(){ //TODO check this value to move the motors in the right direction - DentRobot::collector->MoveArms(-0.1); + DentRobot::collector->MoveArms(-0.1f); } bool OpenCollector::IsFinished(){ return DentRobot::collector->ArmSensor(); diff --git a/Commands/Collector/ReleaseTote.cpp b/Commands/Collector/ReleaseTote.cpp index 90ceaab..0ee9ce1 100644 --- a/Commands/Collector/ReleaseTote.cpp +++ b/Commands/Collector/ReleaseTote.cpp @@ -3,11 +3,13 @@ ReleaseTote::ReleaseTote() : Command("ReleaseTote"){ Requires(DentRobot::collector); } void ReleaseTote::Initialize(){ + SetTimeout(2.0); } void ReleaseTote::Execute(){ //TODO check this value to move the motors in the right direction printf("releasing tote\n"); - DentRobot::collector->MoveRollers((-DentRobot::oi->GetLeftStick()->GetRawAxis(3)+1.0)/2); + // 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); } bool ReleaseTote::IsFinished(){ return DentRobot::collector->BoxCollected(); diff --git a/Subsystems/Collector.cpp b/Subsystems/Collector.cpp index b05c76c..26dc2d7 100644 --- a/Subsystems/Collector.cpp +++ b/Subsystems/Collector.cpp @@ -10,7 +10,7 @@ Collector::Collector() : Subsystem("Collector") { } void Collector::InitDefaultCommand() { } -void Collector::MoveArms(float a){ +void Collector::MoveArms(double a){ windowMotorLeft->Set(a); windowMotorRight->Set(-a); } diff --git a/Subsystems/Collector.h b/Subsystems/Collector.h index ef5acf3..931744f 100644 --- a/Subsystems/Collector.h +++ b/Subsystems/Collector.h @@ -10,7 +10,7 @@ class Collector: public Subsystem public: Collector(); void InitDefaultCommand(); - void MoveArms(float); + void MoveArms(double); void MoveRollers(double); bool ArmSensor(); bool BoxCollected(); From f0632fe91fc12ad80756b0c2c7769b3467d6274f Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Fri, 6 Feb 2015 22:40:18 -0500 Subject: [PATCH 40/64] Updated .env --- .env | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.env b/.env index b4285c7..f4bc334 100644 --- a/.env +++ b/.env @@ -7,3 +7,9 @@ function mc(){ function mk(){ vagrant ssh -c "cd /vagrant/src;make" } +function md(){ + vagrant ssh -c "cd /vagrant/src;make deploy" +} +function ma(){ + vagrant ssh -c "cd /vagrant/src;make clean;make;make deploy" +} From d876abd78a75f89ad70cb8d4a27bcaaa955adc4d Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Fri, 6 Feb 2015 22:44:16 -0500 Subject: [PATCH 41/64] Updated defaults --- Commands/Collector/CloseCollector.cpp | 2 +- Commands/Collector/OpenCollector.cpp | 2 +- RobotMap.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Commands/Collector/CloseCollector.cpp b/Commands/Collector/CloseCollector.cpp index 5dc5e07..ffebfb3 100644 --- a/Commands/Collector/CloseCollector.cpp +++ b/Commands/Collector/CloseCollector.cpp @@ -6,7 +6,7 @@ void CloseCollector::Initialize(){ SetTimeout(0.5); } void CloseCollector::Execute(){ - DentRobot::collector->MoveArms(0.1f); + DentRobot::collector->MoveArms(0.2f); } bool CloseCollector::IsFinished(){ return DentRobot::collector->ArmSensor(); diff --git a/Commands/Collector/OpenCollector.cpp b/Commands/Collector/OpenCollector.cpp index 6e41cd4..27e94ed 100644 --- a/Commands/Collector/OpenCollector.cpp +++ b/Commands/Collector/OpenCollector.cpp @@ -7,7 +7,7 @@ void OpenCollector::Initialize(){ } void OpenCollector::Execute(){ //TODO check this value to move the motors in the right direction - DentRobot::collector->MoveArms(-0.1f); + DentRobot::collector->MoveArms(-0.2f); } bool OpenCollector::IsFinished(){ return DentRobot::collector->ArmSensor(); diff --git a/RobotMap.h b/RobotMap.h index bd596cf..90b38e1 100644 --- a/RobotMap.h +++ b/RobotMap.h @@ -17,7 +17,7 @@ #define COLLECTOR_WINDOW_RIGHT_CAN 7 #define COLLECTOR_LEFT_CAN 8 #define COLLECTOR_RIGHT_CAN 9 -#define COLLECTOR_BOXSWITCH_DIO 9 +#define COLLECTOR_CALIBRATOR_DIO 0 // Compressor #define COMPRESSOR_CAN 10 From e70dd861ed9be63126b46c6faab0e9454e67838a Mon Sep 17 00:00:00 2001 From: Adam Long Date: Sat, 7 Feb 2015 10:18:57 +0000 Subject: [PATCH 42/64] Fixed compile error with Collector.cpp --- Subsystems/Collector.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Subsystems/Collector.cpp b/Subsystems/Collector.cpp index 26dc2d7..a1fdee7 100644 --- a/Subsystems/Collector.cpp +++ b/Subsystems/Collector.cpp @@ -6,7 +6,7 @@ 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_BOXSWITCH_DIO); + boxSwitch=new DigitalInput(COLLECTOR_CALIBRATOR_DIO); } void Collector::InitDefaultCommand() { } From 4c9ce0b57b87a1dd3f94849a967680397774c5db Mon Sep 17 00:00:00 2001 From: Adam Long Date: Sat, 7 Feb 2015 10:37:19 +0000 Subject: [PATCH 43/64] Changed DIO Get if statement to a case --- Subsystems/DIO.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Subsystems/DIO.cpp b/Subsystems/DIO.cpp index d282e01..470bf3a 100644 --- a/Subsystems/DIO.cpp +++ b/Subsystems/DIO.cpp @@ -7,12 +7,15 @@ DIO::DIO(){ void DIO::InitDefaultCommand(){ } bool DIO::Get(e_dioSig dioSig){ - if(dioSig == ELEVATORTOP){ - // The top elevator digitalinput was triggered - return elevatorTop->Get(); - }else if(dioSig == ELEVATORBOTTOM){ - // The buttom elevator digitalinput was triggered - return elevatorBottom->Get(); + switch (dioSig){ + case ELEVATORTOP: + return elevatorTop->Get(); + break; + case ELEVATORBOTTOM: + return elevatorBottom->Get(); + break; + default: + return false; + break; } - return false; } From f682b272a6e848035403ff01117980ed02eef54a Mon Sep 17 00:00:00 2001 From: Adam Long Date: Sat, 7 Feb 2015 11:53:41 +0000 Subject: [PATCH 44/64] Updated Elevator to run until hall effect is triggered --- Commands/Elevator/Lower.cpp | 2 +- Commands/Elevator/Raise.cpp | 2 +- OI.cpp | 4 ++-- Subsystems/DIO.cpp | 2 ++ Subsystems/Elevator.cpp | 1 + 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Commands/Elevator/Lower.cpp b/Commands/Elevator/Lower.cpp index e33f3b2..d853678 100644 --- a/Commands/Elevator/Lower.cpp +++ b/Commands/Elevator/Lower.cpp @@ -8,7 +8,7 @@ void Lower::Execute(){ DentRobot::elevator->Run((-DentRobot::oi->GetLeftStick()->GetRawAxis(3)+1.0)/2); } bool Lower::IsFinished(){ - return false; + return !DentRobot::dio->Get(DentRobot::dio->ELEVATORBOTTOM); } void Lower::End(){ DentRobot::elevator->Run(0.0f); diff --git a/Commands/Elevator/Raise.cpp b/Commands/Elevator/Raise.cpp index ce1248f..8d556c5 100644 --- a/Commands/Elevator/Raise.cpp +++ b/Commands/Elevator/Raise.cpp @@ -9,7 +9,7 @@ void Raise::Execute(){ DentRobot::elevator->Run(-(-DentRobot::oi->GetLeftStick()->GetRawAxis(3)+1.0)/2); } bool Raise::IsFinished(){ - return false; + return !DentRobot::dio->Get(DentRobot::dio->ELEVATORTOP); } void Raise::End(){ DentRobot::elevator->Run(0.0f); diff --git a/OI.cpp b/OI.cpp index 4fc58f9..47a0a66 100644 --- a/OI.cpp +++ b/OI.cpp @@ -21,8 +21,8 @@ OI::OI() { left2->WhileHeld(new CloseCollector()); left3->WhileHeld(new CollectTote()); left4->WhileHeld(new ReleaseTote()); - left5->WhileHeld(new Raise()); - left6->WhileHeld(new Lower()); + left5->WhenPressed(new Raise()); + left6->WhenPressed(new Lower()); } Joystick* OI::GetRightStick(){ return rightStick; diff --git a/Subsystems/DIO.cpp b/Subsystems/DIO.cpp index 470bf3a..b845c3a 100644 --- a/Subsystems/DIO.cpp +++ b/Subsystems/DIO.cpp @@ -9,9 +9,11 @@ void DIO::InitDefaultCommand(){ bool DIO::Get(e_dioSig dioSig){ switch (dioSig){ case ELEVATORTOP: + printf("Hit top limit switch\n"); return elevatorTop->Get(); break; case ELEVATORBOTTOM: + printf("Hit top bottom switch\n"); return elevatorBottom->Get(); break; default: diff --git a/Subsystems/Elevator.cpp b/Subsystems/Elevator.cpp index d32943b..2df51dc 100644 --- a/Subsystems/Elevator.cpp +++ b/Subsystems/Elevator.cpp @@ -10,6 +10,7 @@ Elevator::Elevator()/* : PIDSubsystem("Elevator", kP_real, kI_real, 0.0)*/{ void Elevator::InitDefaultCommand(){ } void Elevator::Run(double power){ + printf("Elevator Power: %f\n",power); motor->Set(power); } void Elevator::SetOffset(double ht){ From 3b63c6ff1e99a9e364865cb3c66bd3e3e5d9d04c Mon Sep 17 00:00:00 2001 From: Adam Long Date: Sat, 7 Feb 2015 12:23:10 +0000 Subject: [PATCH 45/64] Added two second timeout to the elevator --- Commands/Elevator/Lower.cpp | 8 +++++++- Commands/Elevator/Raise.cpp | 9 +++++++-- DentRobot.cpp | 1 + Subsystems/DIO.cpp | 2 -- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Commands/Elevator/Lower.cpp b/Commands/Elevator/Lower.cpp index d853678..8d75a74 100644 --- a/Commands/Elevator/Lower.cpp +++ b/Commands/Elevator/Lower.cpp @@ -1,14 +1,20 @@ #include "Lower.h" #include "../../DentRobot.h" +#include "../../OI.h" Lower::Lower() : Command("Lower"){ } void Lower::Initialize(){ + SetTimeout(2.0); } void Lower::Execute(){ DentRobot::elevator->Run((-DentRobot::oi->GetLeftStick()->GetRawAxis(3)+1.0)/2); } bool Lower::IsFinished(){ - return !DentRobot::dio->Get(DentRobot::dio->ELEVATORBOTTOM); + if (!DentRobot::dio->Get(DentRobot::dio->ELEVATORBOTTOM) || IsTimedOut()){ + return true; + }else{ + return false; + } } void Lower::End(){ DentRobot::elevator->Run(0.0f); diff --git a/Commands/Elevator/Raise.cpp b/Commands/Elevator/Raise.cpp index 8d556c5..35372ea 100644 --- a/Commands/Elevator/Raise.cpp +++ b/Commands/Elevator/Raise.cpp @@ -1,15 +1,20 @@ #include "Raise.h" #include "../../DentRobot.h" #include "../../OI.h" -Raise::Raise(){ +Raise::Raise() : Command("Raise"){ } void Raise::Initialize(){ + SetTimeout(2.0); } void Raise::Execute(){ DentRobot::elevator->Run(-(-DentRobot::oi->GetLeftStick()->GetRawAxis(3)+1.0)/2); } bool Raise::IsFinished(){ - return !DentRobot::dio->Get(DentRobot::dio->ELEVATORTOP); + if (!DentRobot::dio->Get(DentRobot::dio->ELEVATORBOTTOM) || IsTimedOut()){ + return true; + }else{ + return false; + } } void Raise::End(){ DentRobot::elevator->Run(0.0f); diff --git a/DentRobot.cpp b/DentRobot.cpp index 0d9e4ab..819efba 100644 --- a/DentRobot.cpp +++ b/DentRobot.cpp @@ -15,6 +15,7 @@ DentRobot::DentRobot(){ printf("Initialized"); } void DentRobot::RobotInit(){ + SmartDashboard::PutNumber("CodeVersion",0.001); } void DentRobot::DisabledPeriodic(){ Scheduler::GetInstance()->Run(); diff --git a/Subsystems/DIO.cpp b/Subsystems/DIO.cpp index b845c3a..470bf3a 100644 --- a/Subsystems/DIO.cpp +++ b/Subsystems/DIO.cpp @@ -9,11 +9,9 @@ void DIO::InitDefaultCommand(){ bool DIO::Get(e_dioSig dioSig){ switch (dioSig){ case ELEVATORTOP: - printf("Hit top limit switch\n"); return elevatorTop->Get(); break; case ELEVATORBOTTOM: - printf("Hit top bottom switch\n"); return elevatorBottom->Get(); break; default: From e68dc00c21cc7ccb5e2281498b712ba3a688ca20 Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Sat, 7 Feb 2015 12:32:46 -0500 Subject: [PATCH 46/64] 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 47/64] 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 48/64] 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 49/64] 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 50/64] 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 51/64] 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 52/64] 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 53/64] 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 54/64] 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){ From 2951ddd321ec7a5df9135d982fa6a53dbed37870 Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Sun, 8 Feb 2015 11:52:17 -0500 Subject: [PATCH 55/64] Changed lower timeout --- Commands/Elevator/Lower.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Commands/Elevator/Lower.cpp b/Commands/Elevator/Lower.cpp index 35d2159..253ffd9 100644 --- a/Commands/Elevator/Lower.cpp +++ b/Commands/Elevator/Lower.cpp @@ -4,7 +4,7 @@ Lower::Lower() : Command("Lower"){ } void Lower::Initialize(){ - SetTimeout(1.0); + SetTimeout(2.0); } void Lower::Execute(){ DentRobot::elevator->Run(-1.0); From e265ac785e22b27c186ec3daf2cdc2dd42c2b223 Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Sun, 8 Feb 2015 12:19:39 -0500 Subject: [PATCH 56/64] Removed hhlib, added bottom collector --- .gitmodules | 3 --- RobotMap.h | 1 + Subsystems/Collector.cpp | 2 ++ Subsystems/Collector.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitmodules b/.gitmodules index daab3dd..e69de29 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +0,0 @@ -[submodule "src/hhlib"] - path = src/hhlib - url = git@github.com:team2059/hhlib.git diff --git a/RobotMap.h b/RobotMap.h index 3e866a5..cdabc04 100644 --- a/RobotMap.h +++ b/RobotMap.h @@ -22,6 +22,7 @@ #define COLLECTOR_WINDOW_LEFT_CAN 6 #define COLLECTOR_WINDOW_RIGHT_CAN 7 #define COLLECTOR_LEFT_CAN 8 +#define COLLECTOR_BOTTOM_CAN 10 #define COLLECTOR_RIGHT_CAN 9 #endif diff --git a/Subsystems/Collector.cpp b/Subsystems/Collector.cpp index 365809b..f569633 100644 --- a/Subsystems/Collector.cpp +++ b/Subsystems/Collector.cpp @@ -5,6 +5,7 @@ Collector::Collector() : Subsystem("Collector") { windowMotorLeft=new CANTalon(COLLECTOR_WINDOW_LEFT_CAN); windowMotorRight=new CANTalon(COLLECTOR_WINDOW_RIGHT_CAN); collectorMotorLeft=new CANTalon(COLLECTOR_LEFT_CAN); + collectorMotorBottom=new CANTalon(COLLECTOR_BOTTOM_CAN); collectorMotorRight=new CANTalon(COLLECTOR_RIGHT_CAN); } void Collector::InitDefaultCommand() { @@ -15,6 +16,7 @@ void Collector::MoveArms(double a){ } void Collector::MoveRollers(double a){ collectorMotorLeft->Set(a); + collectorMotorBottom->Set(a); collectorMotorRight->Set(-a); } bool Collector::ArmSensor(){ diff --git a/Subsystems/Collector.h b/Subsystems/Collector.h index 24dcc1d..d9cb6ff 100644 --- a/Subsystems/Collector.h +++ b/Subsystems/Collector.h @@ -5,7 +5,7 @@ class Collector: public Subsystem { private: - CANTalon *windowMotorLeft, *windowMotorRight, *collectorMotorLeft, *collectorMotorRight; + CANTalon *windowMotorLeft, *windowMotorRight, *collectorMotorLeft, *collectorMotorBottom, *collectorMotorRight; public: Collector(); void InitDefaultCommand(); From 4790c2d17b18f2eb13b0161441e61d9b293e593f Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Sun, 8 Feb 2015 12:26:15 -0500 Subject: [PATCH 57/64] Fixed vim modelines --- CommandBase.cpp | 2 +- CommandBase.h | 2 +- Commands/Autonomous/AutoDrive.cpp | 2 +- Commands/Autonomous/AutoDrive.h | 2 +- Commands/Autonomous/Autonomous.cpp | 2 +- Commands/Autonomous/Autonomous.h | 2 +- Commands/Collector/CloseCollector.cpp | 2 +- Commands/Collector/CloseCollector.h | 2 +- Commands/Collector/CollectTote.cpp | 2 +- Commands/Collector/CollectTote.h | 2 +- Commands/Collector/OpenCollector.cpp | 2 +- Commands/Collector/OpenCollector.h | 2 +- Commands/Collector/ReleaseTote.cpp | 2 +- Commands/Collector/ReleaseTote.h | 2 +- Commands/Drivetrain/Drive.cpp | 2 +- Commands/Drivetrain/Drive.h | 2 +- Commands/Elevator/Calibrate.cpp | 2 +- Commands/Elevator/Calibrate.h | 2 +- Commands/Elevator/Lower.cpp | 2 +- Commands/Elevator/Lower.h | 2 +- Commands/Elevator/Raise.cpp | 2 +- Commands/Elevator/Raise.h | 2 +- DentRobot.cpp | 2 +- OI.cpp | 2 +- OI.h | 2 +- RobotMap.h | 2 +- Subsystems/Collector.cpp | 2 +- Subsystems/Collector.h | 2 +- Subsystems/Drivetrain.cpp | 2 +- Subsystems/Drivetrain.h | 2 +- Subsystems/Elevator.cpp | 2 +- Subsystems/Elevator.h | 2 +- 32 files changed, 32 insertions(+), 32 deletions(-) diff --git a/CommandBase.cpp b/CommandBase.cpp index 90e3d27..b98ffac 100644 --- a/CommandBase.cpp +++ b/CommandBase.cpp @@ -16,4 +16,4 @@ void CommandBase::init(){ elevator = new Elevator(); oi = new OI(); } -// vim: ts2:sw=2:et +// vim: ts=2:sw=2:et diff --git a/CommandBase.h b/CommandBase.h index c1cb716..ca66699 100644 --- a/CommandBase.h +++ b/CommandBase.h @@ -19,4 +19,4 @@ class CommandBase: public Command { static OI *oi; }; #endif -// vim: ts2:sw=2:et +// vim: ts=2:sw=2:et diff --git a/Commands/Autonomous/AutoDrive.cpp b/Commands/Autonomous/AutoDrive.cpp index e7f85fc..b5e65df 100644 --- a/Commands/Autonomous/AutoDrive.cpp +++ b/Commands/Autonomous/AutoDrive.cpp @@ -20,4 +20,4 @@ void AutoDrive::End(){ void AutoDrive::Interrupted(){ End(); } -// vim: ts2:sw=2:et +// vim: ts=2:sw=2:et diff --git a/Commands/Autonomous/AutoDrive.h b/Commands/Autonomous/AutoDrive.h index eaab4a2..26f2aa3 100644 --- a/Commands/Autonomous/AutoDrive.h +++ b/Commands/Autonomous/AutoDrive.h @@ -16,4 +16,4 @@ class AutoDrive: public Command{ void Interrupted(); }; #endif -// vim: ts2:sw=2:et +// vim: ts=2:sw=2:et diff --git a/Commands/Autonomous/Autonomous.cpp b/Commands/Autonomous/Autonomous.cpp index 93aced5..33bfe6e 100644 --- a/Commands/Autonomous/Autonomous.cpp +++ b/Commands/Autonomous/Autonomous.cpp @@ -6,4 +6,4 @@ Autonomous::Autonomous(){ AddSequential(new AutoDrive()); AddSequential(new Raise()); } -// vim: ts2:sw=2:et +// vim: ts=2:sw=2:et diff --git a/Commands/Autonomous/Autonomous.h b/Commands/Autonomous/Autonomous.h index 88cf308..43ca69c 100644 --- a/Commands/Autonomous/Autonomous.h +++ b/Commands/Autonomous/Autonomous.h @@ -11,4 +11,4 @@ class Autonomous: public CommandGroup{ Autonomous(); }; #endif -// vim: ts2:sw=2:et +// vim: ts=2:sw=2:et diff --git a/Commands/Collector/CloseCollector.cpp b/Commands/Collector/CloseCollector.cpp index 3b7a866..cd95a99 100644 --- a/Commands/Collector/CloseCollector.cpp +++ b/Commands/Collector/CloseCollector.cpp @@ -17,4 +17,4 @@ void CloseCollector::End(){ void CloseCollector::Interrupted(){ End(); } -// vim: ts2:sw=2:et +// vim: ts=2:sw=2:et diff --git a/Commands/Collector/CloseCollector.h b/Commands/Collector/CloseCollector.h index 6be493a..cd26268 100644 --- a/Commands/Collector/CloseCollector.h +++ b/Commands/Collector/CloseCollector.h @@ -17,4 +17,4 @@ class CloseCollector: public Command{ }; #endif -// vim: ts2:sw=2:et +// vim: ts=2:sw=2:et diff --git a/Commands/Collector/CollectTote.cpp b/Commands/Collector/CollectTote.cpp index eca5210..13c5bcc 100644 --- a/Commands/Collector/CollectTote.cpp +++ b/Commands/Collector/CollectTote.cpp @@ -18,4 +18,4 @@ void CollectTote::End(){ void CollectTote::Interrupted(){ End(); } -// vim: ts2:sw=2:et +// vim: ts=2:sw=2:et diff --git a/Commands/Collector/CollectTote.h b/Commands/Collector/CollectTote.h index de2d7db..03074fd 100644 --- a/Commands/Collector/CollectTote.h +++ b/Commands/Collector/CollectTote.h @@ -17,4 +17,4 @@ class CollectTote: public Command{ }; #endif -// vim: ts2:sw=2:et +// vim: ts=2:sw=2:et diff --git a/Commands/Collector/OpenCollector.cpp b/Commands/Collector/OpenCollector.cpp index 1ec498e..93deb00 100644 --- a/Commands/Collector/OpenCollector.cpp +++ b/Commands/Collector/OpenCollector.cpp @@ -18,4 +18,4 @@ void OpenCollector::End(){ void OpenCollector::Interrupted(){ End(); } -// vim: ts2:sw=2:et +// vim: ts=2:sw=2:et diff --git a/Commands/Collector/OpenCollector.h b/Commands/Collector/OpenCollector.h index 47ae5f5..2686251 100644 --- a/Commands/Collector/OpenCollector.h +++ b/Commands/Collector/OpenCollector.h @@ -17,4 +17,4 @@ class OpenCollector: public Command{ }; #endif -// vim: ts2:sw=2:et +// vim: ts=2:sw=2:et diff --git a/Commands/Collector/ReleaseTote.cpp b/Commands/Collector/ReleaseTote.cpp index e751c35..744efcb 100644 --- a/Commands/Collector/ReleaseTote.cpp +++ b/Commands/Collector/ReleaseTote.cpp @@ -19,4 +19,4 @@ void ReleaseTote::End(){ void ReleaseTote::Interrupted(){ End(); } -// vim: ts2:sw=2:et +// vim: ts=2:sw=2:et diff --git a/Commands/Collector/ReleaseTote.h b/Commands/Collector/ReleaseTote.h index 521b7da..722680f 100644 --- a/Commands/Collector/ReleaseTote.h +++ b/Commands/Collector/ReleaseTote.h @@ -17,4 +17,4 @@ class ReleaseTote: public Command{ }; #endif -// vim: ts2:sw=2:et +// vim: ts=2:sw=2:et diff --git a/Commands/Drivetrain/Drive.cpp b/Commands/Drivetrain/Drive.cpp index dfa803b..3fe46f9 100644 --- a/Commands/Drivetrain/Drive.cpp +++ b/Commands/Drivetrain/Drive.cpp @@ -29,4 +29,4 @@ void Drive::End(){ void Drive::Interrupted(){ End(); } -// vim: ts2:sw=2:et +// vim: ts=2:sw=2:et diff --git a/Commands/Drivetrain/Drive.h b/Commands/Drivetrain/Drive.h index 17583fa..17e0ab8 100644 --- a/Commands/Drivetrain/Drive.h +++ b/Commands/Drivetrain/Drive.h @@ -16,4 +16,4 @@ class Drive: public Command{ void Interrupted(); }; #endif -// vim: ts2:sw=2:et +// vim: ts=2:sw=2:et diff --git a/Commands/Elevator/Calibrate.cpp b/Commands/Elevator/Calibrate.cpp index 87f2c25..a55c8c4 100644 --- a/Commands/Elevator/Calibrate.cpp +++ b/Commands/Elevator/Calibrate.cpp @@ -23,4 +23,4 @@ void Calibrate::End(){ void Calibrate::Interrupted(){ End(); } -// vim: ts2:sw=2:et +// vim: ts=2:sw=2:et diff --git a/Commands/Elevator/Calibrate.h b/Commands/Elevator/Calibrate.h index 5d70334..d2bb7b2 100644 --- a/Commands/Elevator/Calibrate.h +++ b/Commands/Elevator/Calibrate.h @@ -14,4 +14,4 @@ class Calibrate: public Command{ void Interrupted(); }; #endif -// vim: ts2:sw=2:et +// vim: ts=2:sw=2:et diff --git a/Commands/Elevator/Lower.cpp b/Commands/Elevator/Lower.cpp index 253ffd9..c29c16f 100644 --- a/Commands/Elevator/Lower.cpp +++ b/Commands/Elevator/Lower.cpp @@ -23,4 +23,4 @@ void Lower::End(){ void Lower::Interrupted(){ End(); } -// vim: ts2:sw=2:et +// vim: ts=2:sw=2:et diff --git a/Commands/Elevator/Lower.h b/Commands/Elevator/Lower.h index 3a83b57..92c8535 100644 --- a/Commands/Elevator/Lower.h +++ b/Commands/Elevator/Lower.h @@ -14,4 +14,4 @@ class Lower: public Command{ void Interrupted(); }; #endif -// vim: ts2:sw=2:et +// vim: ts=2:sw=2:et diff --git a/Commands/Elevator/Raise.cpp b/Commands/Elevator/Raise.cpp index 050b571..92eecc9 100644 --- a/Commands/Elevator/Raise.cpp +++ b/Commands/Elevator/Raise.cpp @@ -23,4 +23,4 @@ void Raise::End(){ void Raise::Interrupted(){ End(); } -// vim: ts2:sw=2:et +// vim: ts=2:sw=2:et diff --git a/Commands/Elevator/Raise.h b/Commands/Elevator/Raise.h index abc519b..b19f470 100644 --- a/Commands/Elevator/Raise.h +++ b/Commands/Elevator/Raise.h @@ -15,4 +15,4 @@ class Raise: public Command{ }; #endif -// vim: ts2:sw=2:et +// vim: ts=2:sw=2:et diff --git a/DentRobot.cpp b/DentRobot.cpp index 77c6a8f..d0399a6 100644 --- a/DentRobot.cpp +++ b/DentRobot.cpp @@ -38,4 +38,4 @@ void DentRobot::TeleopPeriodic(){ void DentRobot::TestPeriodic(){ } START_ROBOT_CLASS(DentRobot); -// vim: ts2:sw=2:et +// vim: ts=2:sw=2:et diff --git a/OI.cpp b/OI.cpp index 1a81fab..f2c7400 100644 --- a/OI.cpp +++ b/OI.cpp @@ -45,4 +45,4 @@ Joystick* OI::GetRightStick(){ Joystick* OI::GetLeftStick(){ return leftStick; } -// vim: ts2:sw=2:et +// vim: ts=2:sw=2:et diff --git a/OI.h b/OI.h index 6bdbe19..7f0929f 100644 --- a/OI.h +++ b/OI.h @@ -13,4 +13,4 @@ class OI Joystick* GetLeftStick(); }; #endif -// vim: ts2:sw=2:et +// vim: ts=2:sw=2:et diff --git a/RobotMap.h b/RobotMap.h index cdabc04..d0cc6e4 100644 --- a/RobotMap.h +++ b/RobotMap.h @@ -26,4 +26,4 @@ #define COLLECTOR_RIGHT_CAN 9 #endif -// vim: ts2:sw=2:et +// vim: ts=2:sw=2:et diff --git a/Subsystems/Collector.cpp b/Subsystems/Collector.cpp index f569633..fcc7959 100644 --- a/Subsystems/Collector.cpp +++ b/Subsystems/Collector.cpp @@ -27,4 +27,4 @@ bool Collector::BoxCollected(){ return false; //return boxSwitch->Get(); } -// vim: ts2:sw=2:et +// vim: ts=2:sw=2:et diff --git a/Subsystems/Collector.h b/Subsystems/Collector.h index d9cb6ff..92262ac 100644 --- a/Subsystems/Collector.h +++ b/Subsystems/Collector.h @@ -15,4 +15,4 @@ class Collector: public Subsystem bool BoxCollected(); }; #endif -// vim: ts2:sw=2:et +// vim: ts=2:sw=2:et diff --git a/Subsystems/Drivetrain.cpp b/Subsystems/Drivetrain.cpp index 7db8487..6440679 100644 --- a/Subsystems/Drivetrain.cpp +++ b/Subsystems/Drivetrain.cpp @@ -20,4 +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 +// vim: ts=2:sw=2:et diff --git a/Subsystems/Drivetrain.h b/Subsystems/Drivetrain.h index b4114b4..3ab69b3 100644 --- a/Subsystems/Drivetrain.h +++ b/Subsystems/Drivetrain.h @@ -13,4 +13,4 @@ class Drivetrain: public Subsystem{ void DriveArcade(float, float); }; #endif -// vim: ts2:sw=2:et +// vim: ts=2:sw=2:et diff --git a/Subsystems/Elevator.cpp b/Subsystems/Elevator.cpp index f0ff41e..e02c4ff 100644 --- a/Subsystems/Elevator.cpp +++ b/Subsystems/Elevator.cpp @@ -29,4 +29,4 @@ bool Elevator::GetElevatorBottom(){ bool Elevator::GetElevatorTop(){ return elevatorTop->Get(); } -// vim: ts2:sw=2:et +// vim: ts=2:sw=2:et diff --git a/Subsystems/Elevator.h b/Subsystems/Elevator.h index 44c57de..c6facaf 100644 --- a/Subsystems/Elevator.h +++ b/Subsystems/Elevator.h @@ -21,4 +21,4 @@ class Elevator{ bool GetElevatorBottom(); }; #endif -// vim: ts2:sw=2:et +// vim: ts=2:sw=2:et From 267a720b83d2245660d1f726b68006f5448e0ac8 Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Sun, 8 Feb 2015 16:51:35 -0500 Subject: [PATCH 58/64] Default value changes, more working on auto --- Commands/Autonomous/AutoDrive.cpp | 4 ++-- Commands/Autonomous/Autonomous.cpp | 17 +++++++++++++++-- Commands/Autonomous/Turn.cpp | 22 ++++++++++++++++++++++ Commands/Autonomous/Turn.h | 19 +++++++++++++++++++ Commands/Collector/CloseCollector.cpp | 14 +++++++++++--- Commands/Collector/CollectTote.cpp | 3 ++- Commands/Collector/OpenCollector.cpp | 7 ++++--- Commands/Drivetrain/Drive.cpp | 12 ++++++------ Commands/Elevator/Lower.cpp | 2 +- Commands/Elevator/Raise.cpp | 2 +- OI.cpp | 12 ++++++------ 11 files changed, 89 insertions(+), 25 deletions(-) create mode 100644 Commands/Autonomous/Turn.cpp create mode 100644 Commands/Autonomous/Turn.h diff --git a/Commands/Autonomous/AutoDrive.cpp b/Commands/Autonomous/AutoDrive.cpp index b5e65df..b7833ec 100644 --- a/Commands/Autonomous/AutoDrive.cpp +++ b/Commands/Autonomous/AutoDrive.cpp @@ -4,13 +4,13 @@ // Drive for a short while then stop. Just for testing AutoDrive::AutoDrive() : Command("AutoDrive"){ Requires(DentRobot::drivetrain); - SetTimeout(1.0); + SetTimeout(0.5); } void AutoDrive::Initialize(){ } void AutoDrive::Execute(){ //X axis, Y axis, Z axis, sensitivity, speed threshold (usually throttle), gyro - DentRobot::drivetrain->DriveMecanum(0.5,0,0,0.9,0); + DentRobot::drivetrain->DriveMecanum(0.0,-.75,0.0,0.9,0.0); } bool AutoDrive::IsFinished(){ return IsTimedOut(); diff --git a/Commands/Autonomous/Autonomous.cpp b/Commands/Autonomous/Autonomous.cpp index 33bfe6e..bc64654 100644 --- a/Commands/Autonomous/Autonomous.cpp +++ b/Commands/Autonomous/Autonomous.cpp @@ -1,9 +1,22 @@ #include "Autonomous.h" -#include "AutoDrive.h" #include "../../DentRobot.h" #include "../Elevator/Raise.h" +#include "../Elevator/Lower.h" +#include "AutoDrive.h" +#include "Turn.h" +#include "../Collector/CloseCollector.h" +#include "../Collector/OpenCollector.h" +#include "../Collector/CollectTote.h" Autonomous::Autonomous(){ - AddSequential(new AutoDrive()); + //AddSequential(new Raise()); + //AddSequential(new Lower()); + //AddSequential(new AutoDrive()); AddSequential(new Raise()); + AddSequential(new Lower()); + AddSequential(new Turn()); + AddParallel(new AutoDrive()); + AddParallel(new CloseCollector()); + AddParallel(new CollectTote()); + AddSequential(new Turn()); } // vim: ts=2:sw=2:et diff --git a/Commands/Autonomous/Turn.cpp b/Commands/Autonomous/Turn.cpp new file mode 100644 index 0000000..174f6cc --- /dev/null +++ b/Commands/Autonomous/Turn.cpp @@ -0,0 +1,22 @@ +#include "Turn.h" +#include "../../DentRobot.h" +// Drive for a short while then stop. Just for testing +Turn::Turn() : Command("Turn"){ + Requires(DentRobot::drivetrain); + SetTimeout(0.25); +} +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.5,0.9,0.0); +} +bool Turn::IsFinished(){ + return IsTimedOut(); +} +void Turn::End(){ +} +void Turn::Interrupted(){ + End(); +} +// vim: ts=2:sw=2:et diff --git a/Commands/Autonomous/Turn.h b/Commands/Autonomous/Turn.h new file mode 100644 index 0000000..2adc701 --- /dev/null +++ b/Commands/Autonomous/Turn.h @@ -0,0 +1,19 @@ +#ifndef TURN_H +#define TURN_H + +#include "Commands/Command.h" +#include "../../CommandBase.h" +#include "../../DentRobot.h" +#include "WPILib.h" + +class Turn: public Command{ + public: + Turn(); + void Initialize(); + void Execute(); + bool IsFinished(); + void End(); + void Interrupted(); +}; +#endif +// vim: ts=2:sw=2:et diff --git a/Commands/Collector/CloseCollector.cpp b/Commands/Collector/CloseCollector.cpp index cd95a99..2418732 100644 --- a/Commands/Collector/CloseCollector.cpp +++ b/Commands/Collector/CloseCollector.cpp @@ -3,13 +3,21 @@ CloseCollector::CloseCollector() : Command("CloseCollector"){ Requires(DentRobot::collector); } void CloseCollector::Initialize(){ - SetTimeout(0.5); + printf("Initialized collector: 0.5\n"); + SetTimeout(2.5); } void CloseCollector::Execute(){ - DentRobot::collector->MoveArms(0.2f); + //printf("Closing collector: -0.5f\n"); + DentRobot::collector->MoveArms(-0.5); + //DentRobot::collector->MoveArms(-(-DentRobot::oi->GetRightStick()->GetRawAxis(3)+1)/2*.3/.5); } bool CloseCollector::IsFinished(){ - return DentRobot::collector->ArmSensor(); + if(DentRobot::collector->ArmSensor()||IsTimedOut()){ + printf("Stopped Closing: %d, %d\n",DentRobot::collector->ArmSensor(), IsTimedOut()); + return true; + }else{ + return false; + } } void CloseCollector::End(){ DentRobot::collector->MoveArms(0.0f); diff --git a/Commands/Collector/CollectTote.cpp b/Commands/Collector/CollectTote.cpp index 13c5bcc..acabd4e 100644 --- a/Commands/Collector/CollectTote.cpp +++ b/Commands/Collector/CollectTote.cpp @@ -3,6 +3,7 @@ CollectTote::CollectTote() : Command("CollectTote"){ Requires(DentRobot::collector); } void CollectTote::Initialize(){ + printf("Initialized CollectTote\n"); SetTimeout(2.0); } void CollectTote::Execute(){ @@ -10,7 +11,7 @@ void CollectTote::Execute(){ DentRobot::collector->MoveRollers(-(-DentRobot::oi->GetLeftStick()->GetRawAxis(3)+1.0)/2); } bool CollectTote::IsFinished(){ - return DentRobot::collector->BoxCollected(); + return DentRobot::collector->BoxCollected()||IsTimedOut(); } void CollectTote::End(){ DentRobot::collector->MoveRollers(0.0); diff --git a/Commands/Collector/OpenCollector.cpp b/Commands/Collector/OpenCollector.cpp index 93deb00..5cebc3e 100644 --- a/Commands/Collector/OpenCollector.cpp +++ b/Commands/Collector/OpenCollector.cpp @@ -6,11 +6,12 @@ void OpenCollector::Initialize(){ SetTimeout(0.5); } void OpenCollector::Execute(){ - //TODO check this value to move the motors in the right direction - DentRobot::collector->MoveArms(-0.2f); + DentRobot::collector->MoveArms(0.35); + //DentRobot::collector->MoveArms((-DentRobot::oi->GetRightStick()->GetRawAxis(3)+1)/2*.3/.5); } bool OpenCollector::IsFinished(){ - return DentRobot::collector->ArmSensor(); + //return DentRobot::collector->ArmSensor(); + return IsTimedOut(); } void OpenCollector::End(){ DentRobot::collector->MoveArms(0.0f); diff --git a/Commands/Drivetrain/Drive.cpp b/Commands/Drivetrain/Drive.cpp index 3fe46f9..60fa59c 100644 --- a/Commands/Drivetrain/Drive.cpp +++ b/Commands/Drivetrain/Drive.cpp @@ -12,12 +12,12 @@ void Drive::Execute(){ x = DentRobot::oi->GetLeftStick()->GetRawAxis(0); z = DentRobot::oi->GetLeftStick()->GetRawAxis(2); y = DentRobot::oi->GetLeftStick()->GetRawAxis(1); - if (DentRobot::oi->GetLeftStick()->GetRawButton(1)){ - x=0; - } - if (DentRobot::oi->GetLeftStick()->GetRawButton(2)){ - y=0; - } + //if (DentRobot::oi->GetLeftStick()->GetRawButton(1)){ + // x=0; + //} + //if (DentRobot::oi->GetLeftStick()->GetRawButton(2)){ + // y=0; + //} //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 c29c16f..378156d 100644 --- a/Commands/Elevator/Lower.cpp +++ b/Commands/Elevator/Lower.cpp @@ -4,7 +4,7 @@ Lower::Lower() : Command("Lower"){ } void Lower::Initialize(){ - SetTimeout(2.0); + SetTimeout(2.5); } void Lower::Execute(){ DentRobot::elevator->Run(-1.0); diff --git a/Commands/Elevator/Raise.cpp b/Commands/Elevator/Raise.cpp index 92eecc9..6f900b4 100644 --- a/Commands/Elevator/Raise.cpp +++ b/Commands/Elevator/Raise.cpp @@ -4,7 +4,7 @@ Raise::Raise() : Command("Raise"){ } void Raise::Initialize(){ - SetTimeout(2.5); + SetTimeout(3.0); } void Raise::Execute(){ DentRobot::elevator->Run(1.0); diff --git a/OI.cpp b/OI.cpp index f2c7400..54c4212 100644 --- a/OI.cpp +++ b/OI.cpp @@ -13,12 +13,12 @@ OI::OI() { // 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()); + JoystickButton *left1=new JoystickButton(leftStick, 1); + JoystickButton *left2=new JoystickButton(leftStick, 2); + right1->WhileHeld(new CloseCollector()); + right2->WhileHeld(new OpenCollector()); + left1->WhileHeld(new CollectTote()); + left2->WhileHeld(new ReleaseTote()); // Elevator Raise* raise=new Raise(); Lower* lower=new Lower(); From 376305a5a7a800242e5da628564a401cfe9b0ae5 Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Sun, 8 Feb 2015 20:29:18 -0500 Subject: [PATCH 59/64] Removed cmath --- Commands/Autonomous/AutoDrive.cpp | 1 - Commands/Drivetrain/Drive.cpp | 1 - 2 files changed, 2 deletions(-) diff --git a/Commands/Autonomous/AutoDrive.cpp b/Commands/Autonomous/AutoDrive.cpp index b7833ec..4d46525 100644 --- a/Commands/Autonomous/AutoDrive.cpp +++ b/Commands/Autonomous/AutoDrive.cpp @@ -1,5 +1,4 @@ #include "AutoDrive.h" -#include #include "../../DentRobot.h" // Drive for a short while then stop. Just for testing AutoDrive::AutoDrive() : Command("AutoDrive"){ diff --git a/Commands/Drivetrain/Drive.cpp b/Commands/Drivetrain/Drive.cpp index 60fa59c..3b91bae 100644 --- a/Commands/Drivetrain/Drive.cpp +++ b/Commands/Drivetrain/Drive.cpp @@ -1,5 +1,4 @@ #include "Drive.h" -#include #include "../../DentRobot.h" Drive::Drive() : Command("Drive"){ Requires(DentRobot::drivetrain); From b832b2b647e412b5570ec822c386bb0393d75bdc Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Mon, 9 Feb 2015 18:47:53 -0500 Subject: [PATCH 60/64] Removed .env --- .env | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 .env diff --git a/.env b/.env deleted file mode 100644 index fe3ac67..0000000 --- a/.env +++ /dev/null @@ -1,15 +0,0 @@ -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 2>&1 >/dev/null" -} -function mk(){ - vagrant ssh -c "cd /vagrant/src;make" -} -function me(){ - vagrant ssh -c "cd /vagrant/src;make deploy" -} -function ma(){ - vagrant ssh -c "cd /vagrant/src;make clean 2>&1 >/dev/null;make;make deploy" -} From dd0b13c4a90a0f4b45007dfd1bf1b244d1be6528 Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Tue, 10 Feb 2015 20:12:41 -0500 Subject: [PATCH 61/64] Added binElevator (untested) --- CommandBase.cpp | 3 ++ CommandBase.h | 2 ++ Commands/BinElevator/BinLower.cpp | 26 +++++++++++++++ .../Calibrate.h => BinElevator/BinLower.h} | 8 ++--- Commands/BinElevator/BinRaise.cpp | 26 +++++++++++++++ Commands/BinElevator/BinRaise.h | 18 +++++++++++ Commands/Elevator/Calibrate.cpp | 26 --------------- DentRobot.cpp | 2 ++ DentRobot.h | 2 ++ Subsystems/BinElevator.cpp | 32 +++++++++++++++++++ Subsystems/BinElevator.h | 24 ++++++++++++++ 11 files changed, 139 insertions(+), 30 deletions(-) create mode 100644 Commands/BinElevator/BinLower.cpp rename Commands/{Elevator/Calibrate.h => BinElevator/BinLower.h} (68%) create mode 100644 Commands/BinElevator/BinRaise.cpp create mode 100644 Commands/BinElevator/BinRaise.h delete mode 100644 Commands/Elevator/Calibrate.cpp create mode 100644 Subsystems/BinElevator.cpp create mode 100644 Subsystems/BinElevator.h diff --git a/CommandBase.cpp b/CommandBase.cpp index b98ffac..c4defc3 100644 --- a/CommandBase.cpp +++ b/CommandBase.cpp @@ -2,9 +2,11 @@ #include "Subsystems/Drivetrain.h" #include "Subsystems/Collector.h" #include "Subsystems/Elevator.h" +#include "Subsystems/BinElevator.h" Drivetrain* CommandBase::drivetrain = NULL; Collector* CommandBase::collector = NULL; Elevator* CommandBase::elevator = NULL; +BinElevator* CommandBase::binElevator = NULL; OI* CommandBase::oi = NULL; CommandBase::CommandBase(char const *name) : Command(name) { } @@ -14,6 +16,7 @@ void CommandBase::init(){ drivetrain = new Drivetrain(); collector = new Collector(); elevator = new Elevator(); + binElevator = new BinElevator(); oi = new OI(); } // vim: ts=2:sw=2:et diff --git a/CommandBase.h b/CommandBase.h index ca66699..7443ebd 100644 --- a/CommandBase.h +++ b/CommandBase.h @@ -5,6 +5,7 @@ #include "Subsystems/Drivetrain.h" #include "Subsystems/Collector.h" #include "Subsystems/Elevator.h" +#include "Subsystems/BinElevator.h" #include "OI.h" #include "WPILib.h" @@ -16,6 +17,7 @@ class CommandBase: public Command { static Drivetrain *drivetrain; static Collector *collector; static Elevator *elevator; + static BinElevator *binElevator; static OI *oi; }; #endif diff --git a/Commands/BinElevator/BinLower.cpp b/Commands/BinElevator/BinLower.cpp new file mode 100644 index 0000000..158f98a --- /dev/null +++ b/Commands/BinElevator/BinLower.cpp @@ -0,0 +1,26 @@ +#include "BinLower.h" +#include "../../DentRobot.h" +#include "../../OI.h" +BinLower::BinLower() : Command("BinLower"){ +} +void BinLower::Initialize(){ + SetTimeout(2.5); +} +void BinLower::Execute(){ + DentRobot::binElevator->Run(-1.0); +} +bool BinLower::IsFinished(){ + if (!DentRobot::binElevator->GetElevatorBottom()||IsTimedOut()){ + printf("Robot stoped BinLowering. Sensor based? %d\n", !DentRobot::binElevator->GetElevatorBottom()); + return true; + }else{ + return false; + } +} +void BinLower::End(){ + DentRobot::binElevator->Run(0.0f); +} +void BinLower::Interrupted(){ + End(); +} +// vim: ts=2:sw=2:et diff --git a/Commands/Elevator/Calibrate.h b/Commands/BinElevator/BinLower.h similarity index 68% rename from Commands/Elevator/Calibrate.h rename to Commands/BinElevator/BinLower.h index d2bb7b2..a3504b4 100644 --- a/Commands/Elevator/Calibrate.h +++ b/Commands/BinElevator/BinLower.h @@ -1,12 +1,12 @@ -#ifndef CALIBRATE_H -#define CALIBRATE_H +#ifndef BINLOWER_H +#define BINLOWER_H #include "Commands/Command.h" #include "WPILib.h" -class Calibrate: public Command{ +class BinLower: public Command{ public: - Calibrate(); + BinLower(); void Initialize(); void Execute(); bool IsFinished(); diff --git a/Commands/BinElevator/BinRaise.cpp b/Commands/BinElevator/BinRaise.cpp new file mode 100644 index 0000000..aa765a4 --- /dev/null +++ b/Commands/BinElevator/BinRaise.cpp @@ -0,0 +1,26 @@ +#include "BinRaise.h" +#include "../../DentRobot.h" +#include "../../OI.h" +BinRaise::BinRaise() : Command("BinRaise"){ +} +void BinRaise::Initialize(){ + SetTimeout(3.0); +} +void BinRaise::Execute(){ + DentRobot::binElevator->Run(1.0); +} +bool BinRaise::IsFinished(){ + if (!DentRobot::binElevator->GetElevatorTop()||IsTimedOut()){ + printf("Robot stoped raising. Sensor based? %d\n", !DentRobot::binElevator->GetElevatorTop()); + return true; + }else{ + return false; + } +} +void BinRaise::End(){ + DentRobot::binElevator->Run(0.0f); +} +void BinRaise::Interrupted(){ + End(); +} +// vim: ts=2:sw=2:et diff --git a/Commands/BinElevator/BinRaise.h b/Commands/BinElevator/BinRaise.h new file mode 100644 index 0000000..ea73454 --- /dev/null +++ b/Commands/BinElevator/BinRaise.h @@ -0,0 +1,18 @@ +#ifndef BINRAISE_H +#define BINRAISE_H + +#include "Commands/Command.h" +#include "WPILib.h" + +class BinRaise: public Command{ + public: + BinRaise(); + void Initialize(); + void Execute(); + bool IsFinished(); + void End(); + void Interrupted(); +}; + +#endif +// vim: ts=2:sw=2:et diff --git a/Commands/Elevator/Calibrate.cpp b/Commands/Elevator/Calibrate.cpp deleted file mode 100644 index a55c8c4..0000000 --- a/Commands/Elevator/Calibrate.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "Calibrate.h" -#include "../../DentRobot.h" -// Lowers elevator until it hits the limit switch then sets the height of the elevator to the height of the limit switches -Calibrate::Calibrate() : Command("Calibrate"){ -} -void Calibrate::Initialize(){ -} -void Calibrate::Execute(){ - // Lower collector until End() - DentRobot::elevator->Run(-0.4f); -} -bool Calibrate::IsFinished(){ - if(DentRobot::elevator->GetElevatorBottom()){ - DentRobot::elevator->ResetEncoder(); - DentRobot::elevator->SetOffset(0.99); - return true; - } - return false; -} -void Calibrate::End(){ - DentRobot::elevator->Run(0.0f); -} -void Calibrate::Interrupted(){ - End(); -} -// vim: ts=2:sw=2:et diff --git a/DentRobot.cpp b/DentRobot.cpp index d0399a6..4588bf6 100644 --- a/DentRobot.cpp +++ b/DentRobot.cpp @@ -4,12 +4,14 @@ OI* DentRobot::oi=NULL; Collector* DentRobot::collector=NULL; Drivetrain* DentRobot::drivetrain=NULL; Elevator* DentRobot::elevator=NULL; +BinElevator* DentRobot::binElevator=NULL; CommandGroup* DentRobot::aut=NULL; DentRobot::DentRobot(){ oi=new OI(); collector=new Collector(); drivetrain=new Drivetrain(); elevator=new Elevator(); + binElevator=new BinElevator(); aut=new Autonomous(); printf("Initialized"); } diff --git a/DentRobot.h b/DentRobot.h index e089405..68b17ba 100644 --- a/DentRobot.h +++ b/DentRobot.h @@ -3,6 +3,7 @@ #include "WPILib.h" #include "OI.h" #include "Subsystems/Elevator.h" +#include "Subsystems/BinElevator.h" #include "Subsystems/Drivetrain.h" #include "Subsystems/Collector.h" #include "Commands/Autonomous/Autonomous.h" @@ -15,6 +16,7 @@ class DentRobot: public IterativeRobot { static Collector* collector; static Drivetrain* drivetrain; static Elevator* elevator; + static BinElevator* binElevator; static CommandGroup* aut; void RobotInit(); void DisabledPeriodic(); diff --git a/Subsystems/BinElevator.cpp b/Subsystems/BinElevator.cpp new file mode 100644 index 0000000..2ada4b9 --- /dev/null +++ b/Subsystems/BinElevator.cpp @@ -0,0 +1,32 @@ +#include "BinElevator.h" +#include "../RobotMap.h" +BinElevator::BinElevator(){ + motor=new CANTalon(ELEVATOR_CAN); + 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 BinElevator::InitDefaultCommand(){ +} +void BinElevator::Run(double power){ + motor->Set(power); +} +void BinElevator::SetOffset(double ht){ + offset=ht; +} +void BinElevator::ResetEncoder(){ + elevatorEncoder->Reset(); +} +double BinElevator::GetHeight(){ + return elevatorEncoder->Get()+offset; +} +bool BinElevator::GetElevatorBottom(){ + return elevatorBottom->Get(); +} +bool BinElevator::GetElevatorTop(){ + return elevatorTop->Get(); +} +// vim: ts=2:sw=2:et diff --git a/Subsystems/BinElevator.h b/Subsystems/BinElevator.h new file mode 100644 index 0000000..5e9e72d --- /dev/null +++ b/Subsystems/BinElevator.h @@ -0,0 +1,24 @@ +#ifndef BINELEVATOR_H +#define BINELEVATOR_H + +#include "WPILib.h" +#include "Commands/PIDSubsystem.h" +class BinElevator{ + private: + CANTalon *motor; + Encoder *elevatorEncoder; + static constexpr double kP_real=4, kI_real=.0f, kP_simulation=18, kI_simulation=.2; + double offset, height; + DigitalInput *elevatorBottom, *elevatorTop; + public: + BinElevator(); + void InitDefaultCommand(); + void Run(double); + void SetOffset(double); + void ResetEncoder(); + double GetHeight(); + bool GetElevatorTop(); + bool GetElevatorBottom(); +}; +#endif +// vim: ts=2:sw=2:et From c77ee7a548e26de638cbf2434a2d38fe2fdc25c8 Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Wed, 11 Feb 2015 18:34:38 -0500 Subject: [PATCH 62/64] Added camera, fixed binelevator (untested) --- DentRobot.cpp | 3 +++ RobotMap.h | 8 ++++++-- Subsystems/BinElevator.cpp | 6 +++--- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/DentRobot.cpp b/DentRobot.cpp index 4588bf6..d43ffb8 100644 --- a/DentRobot.cpp +++ b/DentRobot.cpp @@ -13,6 +13,9 @@ DentRobot::DentRobot(){ elevator=new Elevator(); binElevator=new BinElevator(); aut=new Autonomous(); + CameraServer::GetInstance()->SetQuality(50); + //the camera name (ex "cam0") can be found through the roborio web interface + CameraServer::GetInstance()->StartAutomaticCapture("cam0"); printf("Initialized"); } void DentRobot::RobotInit(){ diff --git a/RobotMap.h b/RobotMap.h index d0cc6e4..8a7a765 100644 --- a/RobotMap.h +++ b/RobotMap.h @@ -8,10 +8,14 @@ #define ELEVATOR_BOTTOM_DIO 0 #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 +// BinElevator +#define BINELEVATOR_CAN 11 +#define BINELEVATOR_BOTTOM_DIO 6 +#define BINELEVATOR_COLELCT_BIN_DIO 7 +#define BINELEVATOR_TOP_DIO 8 + // Drivetrain #define DRIVE_FRONT_LEFT_CAN 2 #define DRIVE_BACK_LEFT_CAN 3 diff --git a/Subsystems/BinElevator.cpp b/Subsystems/BinElevator.cpp index 2ada4b9..1692361 100644 --- a/Subsystems/BinElevator.cpp +++ b/Subsystems/BinElevator.cpp @@ -1,12 +1,12 @@ #include "BinElevator.h" #include "../RobotMap.h" BinElevator::BinElevator(){ - motor=new CANTalon(ELEVATOR_CAN); + motor=new CANTalon(BINELEVATOR_CAN); elevatorEncoder=new Encoder(0,1,false); offset=0; height=0; - elevatorBottom=new DigitalInput(ELEVATOR_BOTTOM_DIO); - elevatorTop=new DigitalInput(ELEVATOR_TOP_DIO); + elevatorBottom=new DigitalInput(BINELEVATOR_BOTTOM_DIO); + elevatorTop=new DigitalInput(BINELEVATOR_TOP_DIO); //SetAbsoluteTolerance(0.004); } void BinElevator::InitDefaultCommand(){ From 0831c1084bc5a537f58cd004008df7e351dc183e Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Wed, 11 Feb 2015 19:22:59 -0500 Subject: [PATCH 63/64] Camera works, untested binelevator changes --- DentRobot.cpp | 3 +-- RobotMap.h | 4 ++++ Subsystems/BinElevator.cpp | 2 +- Subsystems/Elevator.cpp | 10 ++-------- Subsystems/Elevator.h | 2 -- 5 files changed, 8 insertions(+), 13 deletions(-) diff --git a/DentRobot.cpp b/DentRobot.cpp index d43ffb8..f5eafec 100644 --- a/DentRobot.cpp +++ b/DentRobot.cpp @@ -13,8 +13,7 @@ DentRobot::DentRobot(){ elevator=new Elevator(); binElevator=new BinElevator(); aut=new Autonomous(); - CameraServer::GetInstance()->SetQuality(50); - //the camera name (ex "cam0") can be found through the roborio web interface + CameraServer::GetInstance()->SetQuality(25); CameraServer::GetInstance()->StartAutomaticCapture("cam0"); printf("Initialized"); } diff --git a/RobotMap.h b/RobotMap.h index 8a7a765..a3abe10 100644 --- a/RobotMap.h +++ b/RobotMap.h @@ -9,12 +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 // 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 // Drivetrain #define DRIVE_FRONT_LEFT_CAN 2 diff --git a/Subsystems/BinElevator.cpp b/Subsystems/BinElevator.cpp index 1692361..119bfb8 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(0,1,false); + elevatorEncoder=new Encoder(BINELEVATOR_ENCODERA,BINELEVATOR_ENCODERB,false); offset=0; height=0; elevatorBottom=new DigitalInput(BINELEVATOR_BOTTOM_DIO); diff --git a/Subsystems/Elevator.cpp b/Subsystems/Elevator.cpp index e02c4ff..9264b4a 100644 --- a/Subsystems/Elevator.cpp +++ b/Subsystems/Elevator.cpp @@ -2,26 +2,20 @@ #include "../RobotMap.h" Elevator::Elevator(){ motor=new CANTalon(ELEVATOR_CAN); - elevatorEncoder=new Encoder(0,1,false); - offset=0; - height=0; + elevatorEncoder=new Encoder(ELEVATOR_ENCODERA,ELEVATOR_ENCODERB,false); elevatorBottom=new DigitalInput(ELEVATOR_BOTTOM_DIO); elevatorTop=new DigitalInput(ELEVATOR_TOP_DIO); - //SetAbsoluteTolerance(0.004); } void Elevator::InitDefaultCommand(){ } void Elevator::Run(double power){ motor->Set(power); } -void Elevator::SetOffset(double ht){ - offset=ht; -} void Elevator::ResetEncoder(){ elevatorEncoder->Reset(); } double Elevator::GetHeight(){ - return elevatorEncoder->Get()+offset; + return elevatorEncoder->Get(); } bool Elevator::GetElevatorBottom(){ return elevatorBottom->Get(); diff --git a/Subsystems/Elevator.h b/Subsystems/Elevator.h index c6facaf..bdc0c8d 100644 --- a/Subsystems/Elevator.h +++ b/Subsystems/Elevator.h @@ -8,13 +8,11 @@ class Elevator{ CANTalon *motor; 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(); void Run(double); - void SetOffset(double); void ResetEncoder(); double GetHeight(); bool GetElevatorTop(); From e26b7e825c50a072468a97af96b8ea1a163a00d0 Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Wed, 11 Feb 2015 20:49:56 -0500 Subject: [PATCH 64/64] Updated binElevator --- Subsystems/BinElevator.cpp | 8 +------- Subsystems/BinElevator.h | 2 -- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/Subsystems/BinElevator.cpp b/Subsystems/BinElevator.cpp index 119bfb8..daff79b 100644 --- a/Subsystems/BinElevator.cpp +++ b/Subsystems/BinElevator.cpp @@ -3,25 +3,19 @@ BinElevator::BinElevator(){ motor=new CANTalon(BINELEVATOR_CAN); elevatorEncoder=new Encoder(BINELEVATOR_ENCODERA,BINELEVATOR_ENCODERB,false); - offset=0; - height=0; elevatorBottom=new DigitalInput(BINELEVATOR_BOTTOM_DIO); elevatorTop=new DigitalInput(BINELEVATOR_TOP_DIO); - //SetAbsoluteTolerance(0.004); } void BinElevator::InitDefaultCommand(){ } void BinElevator::Run(double power){ motor->Set(power); } -void BinElevator::SetOffset(double ht){ - offset=ht; -} void BinElevator::ResetEncoder(){ elevatorEncoder->Reset(); } double BinElevator::GetHeight(){ - return elevatorEncoder->Get()+offset; + return elevatorEncoder->Get(); } bool BinElevator::GetElevatorBottom(){ return elevatorBottom->Get(); diff --git a/Subsystems/BinElevator.h b/Subsystems/BinElevator.h index 5e9e72d..8814152 100644 --- a/Subsystems/BinElevator.h +++ b/Subsystems/BinElevator.h @@ -8,13 +8,11 @@ class BinElevator{ CANTalon *motor; Encoder *elevatorEncoder; static constexpr double kP_real=4, kI_real=.0f, kP_simulation=18, kI_simulation=.2; - double offset, height; DigitalInput *elevatorBottom, *elevatorTop; public: BinElevator(); void InitDefaultCommand(); void Run(double); - void SetOffset(double); void ResetEncoder(); double GetHeight(); bool GetElevatorTop();