2
0
mirror of https://github.com/team2059/Dent synced 2025-01-07 22:14:14 -05:00
dent/OI.cpp

65 lines
2.2 KiB
C++
Raw Normal View History

#include "OI.h"
#include "Commands/Elevator/Lower.h"
#include "Commands/Elevator/Raise.h"
2015-02-13 19:40:23 -05:00
#include "Commands/Collector/RollIn.h"
#include "Commands/Collector/RollOut.h"
2015-03-21 10:24:33 -04:00
#include "Commands/Collector/RollVar.h"
2015-02-13 21:41:38 -05:00
#include "Commands/BinElevator/BinLower.h"
#include "Commands/BinElevator/BinRaise.h"
2015-02-21 13:43:19 +00:00
#include "Commands/BinElevator/BinCloseArms.h"
#include "Commands/BinElevator/BinOpenArms.h"
#include "Commands/Autonomous/CollectTote.h"
#include "Commands/Autonomous/ReleaseTote.h"
2015-03-09 07:25:11 -04:00
OI::OI(){
2015-02-07 17:04:16 -05:00
// Joysticks
2015-01-17 12:21:16 -05:00
leftStick=new Joystick(0);
rightStick=new Joystick(1);
2015-02-07 17:04:16 -05:00
// Collector
2015-03-22 14:03:32 -04:00
JoystickButton *left10=new JoystickButton(leftStick, 10);
JoystickButton *left12=new JoystickButton(leftStick, 12);
JoystickButton *left9=new JoystickButton(leftStick, 9);
left10->WhileHeld(new RollIn(GetLeftThrottle()));
left12->WhileHeld(new RollOut(2.0));
2015-03-21 10:24:33 -04:00
// 0.8 is the multiplier, so they roll at 80% power
2015-03-22 14:03:32 -04:00
left9->WhileHeld(new RollVar(0.8));
2015-02-07 17:04:16 -05:00
// Elevator
raise=new Raise(3.5);
lower=new Lower(3.0);
2015-03-22 14:03:32 -04:00
JoystickButton *right9=new JoystickButton(rightStick, 9);
JoystickButton *right11=new JoystickButton(rightStick, 11);
right9->WhenPressed(lower);
right9->CancelWhenPressed(raise);
right11->WhenPressed(raise);
right11->CancelWhenPressed(lower);
2015-02-13 21:41:38 -05:00
// BinElevator
2015-03-22 14:03:32 -04:00
JoystickButton *right10=new JoystickButton(rightStick, 10);
JoystickButton *right12=new JoystickButton(rightStick, 12);
2015-02-26 13:01:05 +00:00
//JoystickButton *right7=new JoystickButton(rightStick, 7);
//JoystickButton *right8=new JoystickButton(rightStick, 8);
//right7->WhenPressed(new BinOpenArms());
//right8->WhenPressed(new BinCloseArms());
binRaise=new BinRaise(3.0);
binLower=new BinLower(2.0);
2015-03-22 14:03:32 -04:00
right10->WhileHeld(binLower);
right10->CancelWhenPressed(binRaise);
right12->WhileHeld(binRaise);
right12->CancelWhenPressed(binLower);
// Cancel
2015-03-22 14:03:32 -04:00
JoystickButton *right16=new JoystickButton(rightStick, 16);
right16->CancelWhenPressed(raise);
right16->CancelWhenPressed(lower);
2015-01-17 12:21:16 -05:00
}
Joystick* OI::GetRightStick(){
return rightStick;
}
Joystick* OI::GetLeftStick(){
return leftStick;
}
2015-02-15 17:10:20 -05:00
double OI::GetRightThrottle(){
return (-rightStick->GetRawAxis(3)+1.0)/2;
}
double OI::GetLeftThrottle(){
return (-leftStick->GetRawAxis(3)+1.0)/2;
}
2015-02-08 12:26:15 -05:00
// vim: ts=2:sw=2:et