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

29 lines
772 B
C++
Raw Normal View History

2015-02-06 13:45:01 -05:00
#include "AutoDrive.h"
#include "../../DentRobot.h"
2015-02-06 20:38:02 -05:00
// Drive for a short while then stop. Just for testing
2015-03-17 16:33:25 -04:00
AutoDrive::AutoDrive(double duration, double xtmp, double ytmp, double ztmp, bool useGyro): Command("AutoDrive"){
2015-02-06 13:45:01 -05:00
Requires(DentRobot::drivetrain);
2015-02-21 08:43:19 -05:00
SetTimeout(duration);
2015-03-23 10:52:02 -04:00
x = xtmp;
y = ytmp;
z = ztmp;
gyro = useGyro;
2015-02-06 13:45:01 -05:00
}
void AutoDrive::Initialize(){
DentRobot::drivetrain->ResetGyro();
2015-02-06 13:45:01 -05:00
}
void AutoDrive::Execute(){
2015-03-10 20:14:38 -04:00
//X axis, Y axis, Z axis, sensitivity, speed threshold (usually throttle)
2015-03-17 16:33:25 -04:00
DentRobot::drivetrain->DriveMecanum(x, y, z, 0.9, gyro);
2015-02-06 13:45:01 -05:00
}
bool AutoDrive::IsFinished(){
2015-02-07 17:04:16 -05:00
return IsTimedOut();
2015-02-06 13:45:01 -05:00
}
void AutoDrive::End(){
2015-03-10 20:14:38 -04:00
DentRobot::drivetrain->DriveMecanum(0.0, 0.0, 0.0, 0.9);
2015-02-06 13:45:01 -05:00
}
void AutoDrive::Interrupted(){
End();
}
2015-02-08 12:26:15 -05:00
// vim: ts=2:sw=2:et