-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDrive.cpp
More file actions
46 lines (38 loc) · 1.06 KB
/
Drive.cpp
File metadata and controls
46 lines (38 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/** Command to drive the robot at the given speed
* and turn rate for a given amount of time
* @author Hans Johnson
* @date Sept. 2015
**/
#include "Drive.h"
/* Constructor */
/**
* @param speed Speed that the robot should drive at
* @param turn Turning rate of robot -1.0 is full left turn, 1.0 is full right. 0.0 is straight ahead
* @param duration Length of time in milliseconds to drive for
**/
Drive::Drive(float speed, float turn, int duration) : PausableCommand("Drive") {
_speed = speed;
_turn = turn;
_duration = duration;
curie = Robot::getInstance();
}
void Drive::initialize() {}
/** Drive the drivetrain with the given
* speed and turn rate parameters
**/
void Drive::execute() {
curie->drivetrain->drive(_speed, _turn);
}
void Drive::end() {
curie->drivetrain->stop();
}
/** Command is finished when enough time has elapsed **/
bool Drive::isFinished() {
return getTime() > _duration;
}
/** Stop the drivetrain when paused **/
void Drive::onPause() {
curie->drivetrain->stop();
}
/** Do nothing special on resume **/
void Drive::onResume() {}