From e2a614de8748459e1176a7e3fb3edd3cce5a1d65 Mon Sep 17 00:00:00 2001 From: Adam Long Date: Fri, 23 Oct 2015 18:45:39 +0000 Subject: [PATCH] changed names, set claw open by default, changed buttons for claw --- Commands/BinCollector/BinCloseClaw.cpp | 18 +++++++++++++++++ .../OpenArm.h => BinCollector/BinCloseClaw.h} | 20 ++++++++----------- Commands/BinCollector/BinOpenClaw.cpp | 18 +++++++++++++++++ .../CloseArm.h => BinCollector/BinOpenClaw.h} | 20 ++++++++----------- Commands/Elevator/CloseArm.cpp | 18 ----------------- Commands/Elevator/OpenArm.cpp | 18 ----------------- DentRobot.cpp | 2 +- OI.cpp | 12 +++++------ Subsystems/Pneumatics.cpp | 13 ++++++++---- Subsystems/Pneumatics.h | 14 +++++++------ 10 files changed, 76 insertions(+), 77 deletions(-) create mode 100644 Commands/BinCollector/BinCloseClaw.cpp rename Commands/{Elevator/OpenArm.h => BinCollector/BinCloseClaw.h} (59%) create mode 100644 Commands/BinCollector/BinOpenClaw.cpp rename Commands/{Elevator/CloseArm.h => BinCollector/BinOpenClaw.h} (58%) delete mode 100644 Commands/Elevator/CloseArm.cpp delete mode 100644 Commands/Elevator/OpenArm.cpp diff --git a/Commands/BinCollector/BinCloseClaw.cpp b/Commands/BinCollector/BinCloseClaw.cpp new file mode 100644 index 0000000..efbbc6b --- /dev/null +++ b/Commands/BinCollector/BinCloseClaw.cpp @@ -0,0 +1,18 @@ +#include "BinCloseClaw.h" +#include "../../DentRobot.h" +#include "../../OI.h" +BinCloseClaw::BinCloseClaw(double timeout): Command("BinCloseClaw") { + SetTimeout(timeout); +} +void BinCloseClaw::Initialize() {} +void BinCloseClaw::Execute() { + DentRobot::pneumatics->SetClawOpen(false); +} +bool BinCloseClaw::IsFinished() { + return true; +} +void BinCloseClaw::End() {} +void BinCloseClaw::Interrupted() { + End(); +} +// vim: ts=2:sw=2:et diff --git a/Commands/Elevator/OpenArm.h b/Commands/BinCollector/BinCloseClaw.h similarity index 59% rename from Commands/Elevator/OpenArm.h rename to Commands/BinCollector/BinCloseClaw.h index 3da9260..53df4d6 100644 --- a/Commands/Elevator/OpenArm.h +++ b/Commands/BinCollector/BinCloseClaw.h @@ -1,30 +1,26 @@ -#ifndef OPENARM_H -#define OPENARM_H +#ifndef BINCLOSECLAW_H +#define BINCLOSECLAW_H #include "Commands/Command.h" #include "WPILib.h" /** - * @brief Opens bin retaining arm + * @brief Closes BinElevatorArms */ -class OpenArm: public Command { +class BinCloseClaw: public Command { public: /** - * @brief Constructs OpenArm + * @brief Constructs BinCloseClaw * - * @param timeout Timeout in seconds + * @param timeout Timeout in seconds (default: 0.5) */ - OpenArm(double timeout); - /** - * @brief Constructs OpenArm - */ - OpenArm(); + BinCloseClaw(double timeout = 0.5); /** * @brief Initializes the class */ void Initialize(); /** - * @brief Sets the solenoid to open the arm + * @brief Sets the solenoid to close the claw */ void Execute(); /** diff --git a/Commands/BinCollector/BinOpenClaw.cpp b/Commands/BinCollector/BinOpenClaw.cpp new file mode 100644 index 0000000..24b53b8 --- /dev/null +++ b/Commands/BinCollector/BinOpenClaw.cpp @@ -0,0 +1,18 @@ +#include "BinOpenClaw.h" +#include "../../DentRobot.h" +#include "../../OI.h" +BinOpenClaw::BinOpenClaw(double timeout): Command("BinOpenClaw") { + SetTimeout(timeout); +} +void BinOpenClaw::Initialize() {} +void BinOpenClaw::Execute() { + DentRobot::pneumatics->SetClawOpen(true); +} +bool BinOpenClaw::IsFinished() { + return true; +} +void BinOpenClaw::End() {} +void BinOpenClaw::Interrupted() { + End(); +} +// vim: ts=2:sw=2:et diff --git a/Commands/Elevator/CloseArm.h b/Commands/BinCollector/BinOpenClaw.h similarity index 58% rename from Commands/Elevator/CloseArm.h rename to Commands/BinCollector/BinOpenClaw.h index 865fd70..4c594da 100644 --- a/Commands/Elevator/CloseArm.h +++ b/Commands/BinCollector/BinOpenClaw.h @@ -1,30 +1,26 @@ -#ifndef CLOSEARM_H -#define CLOSEARM_H +#ifndef BINOPENCLAW_H +#define BINOPENCLAW_H #include "Commands/Command.h" #include "WPILib.h" /** - * @brief Closes bin retaining arm + * @brief Closes BinElevatorArms */ -class CloseArm: public Command { +class BinOpenClaw: public Command { public: /** - * @brief Constructs CloseArm + * @brief Constructs BinOpenClaw * - * @param timeout Timeout in seconds + * @param timeout Timeout in seconds (default: 0.5) */ - CloseArm(double timeout); - /** - * @brief Constructs CloseArm - */ - CloseArm(); + BinOpenClaw(double timeout = 0.5); /** * @brief Initializes the class */ void Initialize(); /** - * @brief Sets the solenoid to close the arm + * @brief Sets the solenoid to open the claw */ void Execute(); /** diff --git a/Commands/Elevator/CloseArm.cpp b/Commands/Elevator/CloseArm.cpp deleted file mode 100644 index d898cd0..0000000 --- a/Commands/Elevator/CloseArm.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "CloseArm.h" -#include "../../DentRobot.h" -#include "../../OI.h" -CloseArm::CloseArm(double timeout): Command("CloseArm") { - SetTimeout(timeout); -} -void CloseArm::Initialize() {} -void CloseArm::Execute() { - DentRobot::pneumatics->SetElevatorArmOpen(false); -} -bool CloseArm::IsFinished() { - return true; -} -void CloseArm::End() {} -void CloseArm::Interrupted() { - End(); -} -// vim: ts=2:sw=2:et diff --git a/Commands/Elevator/OpenArm.cpp b/Commands/Elevator/OpenArm.cpp deleted file mode 100644 index 845af3b..0000000 --- a/Commands/Elevator/OpenArm.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "OpenArm.h" -#include "../../DentRobot.h" -#include "../../OI.h" -OpenArm::OpenArm(double timeout): Command("OpenArm") { - SetTimeout(timeout); -} -void OpenArm::Initialize() {} -void OpenArm::Execute() { - DentRobot::pneumatics->SetElevatorArmOpen(true); -} -bool OpenArm::IsFinished() { - return true; -} -void OpenArm::End() {} -void OpenArm::Interrupted() { - End(); -} -// vim: ts=2:sw=2:et diff --git a/DentRobot.cpp b/DentRobot.cpp index d1b35c8..04987b5 100644 --- a/DentRobot.cpp +++ b/DentRobot.cpp @@ -50,7 +50,7 @@ void DentRobot::RobotInit() { SmartDashboard::PutNumber("Gyro kP", -0.02); printf("Starting compressor\n"); pneumatics->SetCompressorEnabled(true); - pneumatics->SetElevatorArmOpen(false); + pneumatics->SetClawOpen(true); } void DentRobot::DisabledPeriodic() { Scheduler::GetInstance()->Run(); diff --git a/OI.cpp b/OI.cpp index 2603343..97c6ad0 100644 --- a/OI.cpp +++ b/OI.cpp @@ -1,8 +1,6 @@ #include "OI.h" #include "Commands/Elevator/Lower.h" #include "Commands/Elevator/Raise.h" -#include "Commands/Elevator/OpenArm.h" -#include "Commands/Elevator/CloseArm.h" #include "Commands/Elevator/ElevatorCycle.h" #include "Commands/Collector/RollIn.h" #include "Commands/Collector/RollOut.h" @@ -11,6 +9,8 @@ #include "Commands/BinElevator/BinRaise.h" #include "Commands/BinCollector/BinCloseArms.h" #include "Commands/BinCollector/BinOpenArms.h" +#include "Commands/BinCollector/BinCloseClaw.h" +#include "Commands/BinCollector/BinOpenClaw.h" #include "Commands/BinCollector/BinIn.h" #include "Commands/BinCollector/BinOut.h" #include "Commands/Autonomous/CollectTote.h" @@ -38,12 +38,12 @@ OI::OI() { left10->WhenPressed(new BinCloseArms(2)); // Elevator + 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 *right11 = new JoystickButton(rightStick, 11); - JoystickButton *right12 = new JoystickButton(rightStick, 12); //Full speed lift right3->WhileHeld(new Lower(3.5,false,0.5)); @@ -52,8 +52,8 @@ OI::OI() { right4->WhileHeld(new RollIn(1)); right6->WhileHeld(new Raise(3.5,false,-1)); - right11->WhenPressed(new OpenArm(2)); - right12->WhenPressed(new CloseArm(2)); + right1->WhenPressed(new BinOpenClaw(2)); + right2->WhenPressed(new BinCloseClaw(2)); } Joystick* OI::GetRightStick() { return rightStick; diff --git a/Subsystems/Pneumatics.cpp b/Subsystems/Pneumatics.cpp index c66a226..086327d 100644 --- a/Subsystems/Pneumatics.cpp +++ b/Subsystems/Pneumatics.cpp @@ -8,16 +8,18 @@ Pneumatics::Pneumatics(): Subsystem("Pneumatics") { solenoid3 = new Solenoid(COMPRESSOR_PCM_CAN, BINELEVATOR_SOLENOID_THREE); solenoid4 = new Solenoid(COMPRESSOR_PCM_CAN, BINELEVATOR_SOLENOID_FOUR); armState = false; + clawState = true; } void Pneumatics::InitDefaultCommand() {} void Pneumatics::SetArmsOpen(bool state) { - solenoid1->Set(state); - solenoid2->Set(!state); - armState=state; + solenoid1->Set(state); + solenoid2->Set(!state); + armState=state; } -void Pneumatics::SetElevatorArmOpen(bool state){ +void Pneumatics::SetClawOpen(bool state){ solenoid3->Set(state); solenoid4->Set(!state); + clawState=state; } void Pneumatics::SetCompressorEnabled(bool state) { compressor->SetClosedLoopControl(state); @@ -25,6 +27,9 @@ void Pneumatics::SetCompressorEnabled(bool state) { bool Pneumatics::GetArmsOpen() { return armState; } +bool Pneumatics::GetClawOpen() { + return clawState; +} bool Pneumatics::GetCompressorEnabled() { return compressor->Enabled(); } diff --git a/Subsystems/Pneumatics.h b/Subsystems/Pneumatics.h index 7d64705..f18cd85 100644 --- a/Subsystems/Pneumatics.h +++ b/Subsystems/Pneumatics.h @@ -14,7 +14,8 @@ class Pneumatics: public Subsystem { *solenoid2, //