2
0
mirror of https://github.com/team2059/Dent synced 2024-12-28 21:02:30 -05:00
dent/Commands/Drivetrain/Drive.cpp

38 lines
937 B
C++
Raw Normal View History

2015-01-17 12:55:51 -05:00
#include "Drive.h"
#include "../../DentRobot.h"
2015-07-31 12:52:15 -04:00
Drive::Drive(): Command("Drive") {
2015-02-02 20:43:22 -05:00
Requires(DentRobot::drivetrain);
2015-01-17 12:55:51 -05:00
}
2015-07-31 12:52:15 -04:00
void Drive::Initialize() {
2015-01-17 12:55:51 -05:00
}
2015-07-31 12:52:15 -04:00
void Drive::Execute() {
double x, y, z;
2015-02-06 20:17:26 -05:00
x = DentRobot::oi->GetLeftStick()->GetRawAxis(0);
2015-02-27 16:42:11 -05:00
y = -DentRobot::oi->GetLeftStick()->GetRawAxis(1);
2015-01-19 12:08:25 -05:00
z = DentRobot::oi->GetLeftStick()->GetRawAxis(2);
2015-03-07 13:27:11 -05:00
// Lock the x axis when not holding button 1
2015-03-09 07:25:11 -04:00
//if(DentRobot::oi->GetLeftStick()->GetRawButton(1)){
2015-03-23 10:52:02 -04:00
// x = 0;
//}
2015-03-09 07:25:11 -04:00
//if(DentRobot::oi->GetLeftStick()->GetRawButton(2)){
2015-03-23 10:52:02 -04:00
// y = 0;
//}
2015-03-10 20:14:38 -04:00
//X axis, Y axis, Z axis, sensitivity, speed threshold (usually throttle)
2015-07-31 12:52:15 -04:00
if(DentRobot::oi->GetLeftStick()->GetRawButton(11)) {
2015-03-20 09:11:23 -04:00
x = -x;
y = -y;
}
printf("X:%d\n",x);
printf("Y:%d\n",y);
2015-09-17 15:59:58 -04:00
DentRobot::drivetrain->DriveArcade(x, y, z, 0.9);
2015-01-17 12:55:51 -05:00
}
2015-07-31 12:52:15 -04:00
bool Drive::IsFinished() {
2015-02-14 16:16:03 -05:00
return IsTimedOut();
2015-01-17 12:55:51 -05:00
}
2015-07-31 12:52:15 -04:00
void Drive::End() {
2015-01-17 12:55:51 -05:00
}
2015-07-31 12:52:15 -04:00
void Drive::Interrupted() {
2015-02-02 20:08:04 -05:00
End();
2015-01-17 12:55:51 -05:00
}
2015-02-08 12:26:15 -05:00
// vim: ts=2:sw=2:et