2
0
mirror of https://github.com/team2059/Dent synced 2024-12-18 20:52:29 -05:00

Added BinElevator commands

This commit is contained in:
Austen Adler 2015-02-13 21:41:38 -05:00
parent dc593a3282
commit 79b635d554
9 changed files with 82 additions and 6 deletions

View File

@ -4,12 +4,22 @@
AutoDrive::AutoDrive(double wait) : Command("AutoDrive"){ AutoDrive::AutoDrive(double wait) : Command("AutoDrive"){
Requires(DentRobot::drivetrain); Requires(DentRobot::drivetrain);
SetTimeout(wait); SetTimeout(wait);
power=NULL;
}
AutoDrive::AutoDrive(double wait, double p) : Command("AutoDrive"){
Requires(DentRobot::drivetrain);
SetTimeout(wait);
*power=p;
} }
void AutoDrive::Initialize(){ void AutoDrive::Initialize(){
} }
void AutoDrive::Execute(){ void AutoDrive::Execute(){
//X axis, Y axis, Z axis, sensitivity, speed threshold (usually throttle), gyro //X axis, Y axis, Z axis, sensitivity, speed threshold (usually throttle), gyro
DentRobot::drivetrain->DriveMecanum(0.0,-.75,0.0,0.9,0.0); if(power==NULL){
DentRobot::drivetrain->DriveMecanum(0.0,-.75,0.0,0.9,0.0);
}else{
DentRobot::drivetrain->DriveMecanum(0.0,*power,0.0,0.9,0.0);
}
} }
bool AutoDrive::IsFinished(){ bool AutoDrive::IsFinished(){
return IsTimedOut(); return IsTimedOut();

View File

@ -7,8 +7,11 @@
#include "WPILib.h" #include "WPILib.h"
class AutoDrive: public Command{ class AutoDrive: public Command{
private:
double *power;
public: public:
AutoDrive(double); AutoDrive(double);
AutoDrive(double, double);
void Initialize(); void Initialize();
void Execute(); void Execute();
bool IsFinished(); bool IsFinished();

View File

@ -0,0 +1,11 @@
#include "CollectTote.h"
#include "../../DentRobot.h"
#include "../Autonomous/AutoDrive.h"
#include "RollIn.h"
#include "CloseCollector.h"
CollectTote::CollectTote(){
AddParallel(new RollIn());
AddParallel(new AutoDrive(0.5, -0.75));
AddSequential(new CloseCollector());
}
// vim: ts=2:sw=2:et

View File

@ -0,0 +1,14 @@
#ifndef COLLECTTOTE_H
#define COLLECTTOTE_H
#include "Commands/CommandGroup.h"
#include "../../CommandBase.h"
#include "../../DentRobot.h"
#include "WPILib.h"
class CollectTote: public CommandGroup{
public:
CollectTote();
};
#endif
// vim: ts=2:sw=2:et

View File

@ -0,0 +1,11 @@
#include "ReleaseTote.h"
#include "../../DentRobot.h"
#include "RollOut.h"
#include "../Autonomous/AutoDrive.h"
#include "CloseCollector.h"
ReleaseTote::ReleaseTote(){
AddParallel(new RollOut());
AddParallel(new AutoDrive(0.5, 0.75));
AddSequential(new CloseCollector());
}
// vim: ts=2:sw=2:et

View File

@ -0,0 +1,14 @@
#ifndef RELEASETOTE_H
#define RELEASETOTE_H
#include "Commands/CommandGroup.h"
#include "../../CommandBase.h"
#include "../../DentRobot.h"
#include "WPILib.h"
class ReleaseTote: public CommandGroup{
public:
ReleaseTote();
};
#endif
// vim: ts=2:sw=2:et

13
OI.cpp
View File

@ -5,6 +5,8 @@
#include "Commands/Collector/CloseCollector.h" #include "Commands/Collector/CloseCollector.h"
#include "Commands/Collector/RollIn.h" #include "Commands/Collector/RollIn.h"
#include "Commands/Collector/RollOut.h" #include "Commands/Collector/RollOut.h"
#include "Commands/BinElevator/BinLower.h"
#include "Commands/BinElevator/BinRaise.h"
OI::OI() { OI::OI() {
// Joysticks // Joysticks
@ -34,10 +36,21 @@ OI::OI() {
right6->WhenPressed(raise); right6->WhenPressed(raise);
right5->CancelWhenPressed(lower); right5->CancelWhenPressed(lower);
right6->CancelWhenPressed(lower); right6->CancelWhenPressed(lower);
// BinElevator
binRaise=new BinRaise();
binLower=new BinLower();
JoystickButton *right7=new JoystickButton(rightStick, 7);
JoystickButton *right8=new JoystickButton(rightStick, 8);
right7->WhenPressed(binLower);
right7->CancelWhenPressed(binRaise);
right8->WhenPressed(binRaise);
right8->CancelWhenPressed(binLower);
// Cancel // Cancel
JoystickButton *right12=new JoystickButton(rightStick, 12); JoystickButton *right12=new JoystickButton(rightStick, 12);
right12->CancelWhenPressed(raise); right12->CancelWhenPressed(raise);
right12->CancelWhenPressed(lower); right12->CancelWhenPressed(lower);
right12->CancelWhenPressed(binRaise);
right12->CancelWhenPressed(binLower);
} }
Joystick* OI::GetRightStick(){ Joystick* OI::GetRightStick(){
return rightStick; return rightStick;

2
OI.h
View File

@ -12,7 +12,7 @@ class OI
OI(); OI();
Joystick* GetRightStick(); Joystick* GetRightStick();
Joystick* GetLeftStick(); Joystick* GetLeftStick();
Command *raise, *lower; Command *raise, *lower, *binLower, *binRaise;
}; };
#endif #endif
// vim: ts=2:sw=2:et // vim: ts=2:sw=2:et

View File

@ -9,16 +9,16 @@
#define ELEVATOR_COLELCT_TOTE_DIO 1 #define ELEVATOR_COLELCT_TOTE_DIO 1
#define ELEVATOR_READY_TOTE_DIO 2 #define ELEVATOR_READY_TOTE_DIO 2
#define ELEVATOR_TOP_DIO 5 #define ELEVATOR_TOP_DIO 5
#define ELEVATOR_ENCODERA 0 #define ELEVATOR_ENCODERA 4
#define ELEVATOR_ENCODERB 1 #define ELEVATOR_ENCODERB 9
// BinElevator // BinElevator
#define BINELEVATOR_CAN 11 #define BINELEVATOR_CAN 11
#define BINELEVATOR_BOTTOM_DIO 6 #define BINELEVATOR_BOTTOM_DIO 6
#define BINELEVATOR_COLELCT_BIN_DIO 7 #define BINELEVATOR_COLELCT_BIN_DIO 7
#define BINELEVATOR_TOP_DIO 8 #define BINELEVATOR_TOP_DIO 8
#define BINELEVATOR_ENCODERA 2 #define BINELEVATOR_ENCODERA 10
#define BINELEVATOR_ENCODERB 3 #define BINELEVATOR_ENCODERB 11
// Drivetrain // Drivetrain
#define DRIVE_FRONT_LEFT_CAN 2 #define DRIVE_FRONT_LEFT_CAN 2