mirror of
https://github.com/team2059/Dent
synced 2024-12-18 20:52:29 -05:00
added openarm and closearm commands
This commit is contained in:
parent
a53f4ef5ff
commit
eb1fefef47
18
Commands/Elevator/CloseArm.cpp
Normal file
18
Commands/Elevator/CloseArm.cpp
Normal file
@ -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
|
46
Commands/Elevator/CloseArm.h
Normal file
46
Commands/Elevator/CloseArm.h
Normal file
@ -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
|
18
Commands/Elevator/OpenArm.cpp
Normal file
18
Commands/Elevator/OpenArm.cpp
Normal file
@ -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
|
46
Commands/Elevator/OpenArm.h
Normal file
46
Commands/Elevator/OpenArm.h
Normal file
@ -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
|
6
OI.cpp
6
OI.cpp
@ -1,6 +1,8 @@
|
|||||||
#include "OI.h"
|
#include "OI.h"
|
||||||
#include "Commands/Elevator/Lower.h"
|
#include "Commands/Elevator/Lower.h"
|
||||||
#include "Commands/Elevator/Raise.h"
|
#include "Commands/Elevator/Raise.h"
|
||||||
|
#include "Commands/Elevator/OpenArm.h"
|
||||||
|
#include "Commands/Elevator/CloseArm.h"
|
||||||
#include "Commands/Elevator/ElevatorCycle.h"
|
#include "Commands/Elevator/ElevatorCycle.h"
|
||||||
#include "Commands/Collector/RollIn.h"
|
#include "Commands/Collector/RollIn.h"
|
||||||
#include "Commands/Collector/RollOut.h"
|
#include "Commands/Collector/RollOut.h"
|
||||||
@ -29,12 +31,16 @@ OI::OI() {
|
|||||||
raise = new Raise(3.5);
|
raise = new Raise(3.5);
|
||||||
lower = new Lower(3.0);
|
lower = new Lower(3.0);
|
||||||
cycle = new ElevatorCycle();
|
cycle = new ElevatorCycle();
|
||||||
|
JoystickButton *left11 = new JoystickButton(leftStick, 11);
|
||||||
|
JoystickButton *left12 = new JoystickButton(leftStick, 12);
|
||||||
JoystickButton *right4 = new JoystickButton(rightStick, 4);
|
JoystickButton *right4 = new JoystickButton(rightStick, 4);
|
||||||
JoystickButton *right6 = new JoystickButton(rightStick, 6);
|
JoystickButton *right6 = new JoystickButton(rightStick, 6);
|
||||||
JoystickButton *right7 = new JoystickButton(rightStick, 7);
|
JoystickButton *right7 = new JoystickButton(rightStick, 7);
|
||||||
JoystickButton *right10 = new JoystickButton(rightStick, 10);
|
JoystickButton *right10 = new JoystickButton(rightStick, 10);
|
||||||
JoystickButton *right11 = new JoystickButton(rightStick, 11);
|
JoystickButton *right11 = new JoystickButton(rightStick, 11);
|
||||||
JoystickButton *right12 = new JoystickButton(rightStick, 12);
|
JoystickButton *right12 = new JoystickButton(rightStick, 12);
|
||||||
|
left11->WhenPressed(new OpenArm(2));
|
||||||
|
left12->WhenPressed(new CloseArm(2));
|
||||||
right4->WhileHeld(lower);
|
right4->WhileHeld(lower);
|
||||||
right6->WhileHeld(raise);
|
right6->WhileHeld(raise);
|
||||||
right7->WhenPressed(cycle);
|
right7->WhenPressed(cycle);
|
||||||
|
@ -15,7 +15,7 @@ void Pneumatics::SetArmsOpen(bool state) {
|
|||||||
solenoid2->Set(!state);
|
solenoid2->Set(!state);
|
||||||
armState=state;
|
armState=state;
|
||||||
}
|
}
|
||||||
void Pneumatics::SetBinArm(bool state){
|
void Pneumatics::SetElevatorArmOpen(bool state){
|
||||||
solenoid3->Set(state);
|
solenoid3->Set(state);
|
||||||
solenoid4->Set(!state);
|
solenoid4->Set(!state);
|
||||||
}
|
}
|
||||||
|
@ -37,11 +37,11 @@ class Pneumatics: public Subsystem {
|
|||||||
*/
|
*/
|
||||||
void SetCompressorEnabled(bool state);
|
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
|
* @param state State of the arm
|
||||||
*/
|
*/
|
||||||
void SetBinArm(bool state);
|
void SetElevatorArmOpen(bool state);
|
||||||
/**
|
/**
|
||||||
* @brief Gets the state of the arms
|
* @brief Gets the state of the arms
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user