2015-01-17 12:55:51 -05:00
|
|
|
#include "Drive.h"
|
2015-01-17 13:28:27 -05:00
|
|
|
#include <cmath>
|
2015-02-03 15:55:11 -05:00
|
|
|
#include "../../DentRobot.h"
|
2015-01-17 12:55:51 -05:00
|
|
|
Drive::Drive() : Command("Drive"){
|
2015-02-02 20:43:22 -05:00
|
|
|
Requires(DentRobot::drivetrain);
|
2015-01-17 12:55:51 -05:00
|
|
|
}
|
|
|
|
void Drive::Initialize(){
|
|
|
|
}
|
|
|
|
void Drive::Execute(){
|
2015-01-19 12:08:25 -05:00
|
|
|
double x,y,z;
|
|
|
|
//Code to lock the x axis when not holding button 1
|
2015-02-06 20:17:26 -05:00
|
|
|
x = DentRobot::oi->GetLeftStick()->GetRawAxis(0);
|
2015-01-19 12:08:25 -05:00
|
|
|
z = DentRobot::oi->GetLeftStick()->GetRawAxis(2);
|
|
|
|
y = DentRobot::oi->GetLeftStick()->GetRawAxis(1);
|
2015-02-06 20:17:26 -05:00
|
|
|
if (DentRobot::oi->GetLeftStick()->GetRawButton(1)){
|
|
|
|
x=0;
|
|
|
|
}
|
|
|
|
if (DentRobot::oi->GetLeftStick()->GetRawButton(2)){
|
|
|
|
y=0;
|
|
|
|
}
|
2015-01-19 12:08:25 -05:00
|
|
|
if (DentRobot::oi->GetLeftStick()->GetRawAxis(3)<=0.5){
|
2015-02-02 20:43:22 -05:00
|
|
|
y /= 2;
|
|
|
|
z /= 2;
|
2015-01-19 12:08:25 -05:00
|
|
|
}
|
|
|
|
//X axis, Y axis, Z axis, sensitivity, speed threshold (usually throttle), gyro
|
|
|
|
DentRobot::drivetrain->DriveMecanum(x,y,z,0.9,0);
|
2015-01-17 12:55:51 -05:00
|
|
|
}
|
|
|
|
bool Drive::IsFinished(){
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
void Drive::End(){
|
|
|
|
}
|
|
|
|
void Drive::Interrupted(){
|
2015-02-02 20:08:04 -05:00
|
|
|
End();
|
2015-01-17 12:55:51 -05:00
|
|
|
}
|
2015-02-07 13:28:08 -05:00
|
|
|
// vim: ts2:sw=2:et
|