diff --git a/Commands/Elevator/CloseArm.cpp b/Commands/Elevator/CloseArm.cpp new file mode 100644 index 0000000..d898cd0 --- /dev/null +++ b/Commands/Elevator/CloseArm.cpp @@ -0,0 +1,18 @@ +#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/CloseArm.h b/Commands/Elevator/CloseArm.h new file mode 100644 index 0000000..d173efd --- /dev/null +++ b/Commands/Elevator/CloseArm.h @@ -0,0 +1,46 @@ +#ifndef CLOSEARM_H +#define CLOSEARM_H + +#include "Commands/Command.h" +#include "WPILib.h" + +/** + * @brief Opens bin arms (unused) + */ +class CloseArm: public Command { + public: + /** + * @brief Constructs CloseArm + * + * @param timeout Timeout in seconds + */ + CloseArm(double timeout); + /** + * @brief Constructs CloseArm + */ + CloseArm(); + /** + * @brief Initializes the class + */ + void Initialize(); + /** + * @brief Sets the solenoid to open the arms + */ + void Execute(); + /** + * @brief Returns true to prevent solenoid damage + * + * @return True + */ + bool IsFinished(); + /** + * @brief Ends the command + */ + void End(); + /** + * @brief Calls End() + */ + void Interrupted(); +}; +#endif +// vim: ts=2:sw=2:et diff --git a/Commands/Elevator/OpenArm.cpp b/Commands/Elevator/OpenArm.cpp new file mode 100644 index 0000000..845af3b --- /dev/null +++ b/Commands/Elevator/OpenArm.cpp @@ -0,0 +1,18 @@ +#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/Commands/Elevator/OpenArm.h b/Commands/Elevator/OpenArm.h new file mode 100644 index 0000000..59d0253 --- /dev/null +++ b/Commands/Elevator/OpenArm.h @@ -0,0 +1,46 @@ +#ifndef OPENARM_H +#define OPENARM_H + +#include "Commands/Command.h" +#include "WPILib.h" + +/** + * @brief Opens bin arms (unused) + */ +class OpenArm: public Command { + public: + /** + * @brief Constructs OpenArm + * + * @param timeout Timeout in seconds + */ + OpenArm(double timeout); + /** + * @brief Constructs OpenArm + */ + OpenArm(); + /** + * @brief Initializes the class + */ + void Initialize(); + /** + * @brief Sets the solenoid to open the arms + */ + void Execute(); + /** + * @brief Returns true to prevent solenoid damage + * + * @return True + */ + bool IsFinished(); + /** + * @brief Ends the command + */ + void End(); + /** + * @brief Calls End() + */ + void Interrupted(); +}; +#endif +// vim: ts=2:sw=2:et diff --git a/OI.cpp b/OI.cpp index 81c3c8d..19f3e1c 100644 --- a/OI.cpp +++ b/OI.cpp @@ -1,6 +1,8 @@ #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" @@ -29,12 +31,16 @@ OI::OI() { raise = new Raise(3.5); lower = new Lower(3.0); cycle = new ElevatorCycle(); + JoystickButton *left11 = new JoystickButton(leftStick, 11); + JoystickButton *left12 = new JoystickButton(leftStick, 12); JoystickButton *right4 = new JoystickButton(rightStick, 4); JoystickButton *right6 = new JoystickButton(rightStick, 6); JoystickButton *right7 = new JoystickButton(rightStick, 7); JoystickButton *right10 = new JoystickButton(rightStick, 10); JoystickButton *right11 = new JoystickButton(rightStick, 11); JoystickButton *right12 = new JoystickButton(rightStick, 12); + left11->WhenPressed(new OpenArm(2)); + left12->WhenPressed(new CloseArm(2)); right4->WhileHeld(lower); right6->WhileHeld(raise); right7->WhenPressed(cycle); diff --git a/Subsystems/Pneumatics.cpp b/Subsystems/Pneumatics.cpp index 1b4ca18..c66a226 100644 --- a/Subsystems/Pneumatics.cpp +++ b/Subsystems/Pneumatics.cpp @@ -15,7 +15,7 @@ void Pneumatics::SetArmsOpen(bool state) { solenoid2->Set(!state); armState=state; } -void Pneumatics::SetBinArm(bool state){ +void Pneumatics::SetElevatorArmOpen(bool state){ solenoid3->Set(state); solenoid4->Set(!state); } diff --git a/Subsystems/Pneumatics.h b/Subsystems/Pneumatics.h index 332613b..7d64705 100644 --- a/Subsystems/Pneumatics.h +++ b/Subsystems/Pneumatics.h @@ -37,11 +37,11 @@ class Pneumatics: public Subsystem { */ void SetCompressorEnabled(bool state); /** - * @brief Sets the state of the bin arm + * @brief Sets the state of the elevator arm * * @param state State of the arm */ - void SetBinArm(bool state); + void SetElevatorArmOpen(bool state); /** * @brief Gets the state of the arms *