-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSwingTurn.cpp
More file actions
39 lines (31 loc) · 893 Bytes
/
SwingTurn.cpp
File metadata and controls
39 lines (31 loc) · 893 Bytes
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
/** Command to execute a swing turn with the robot where only the outer wheel spins
* for a given amount of time
* @author Hans Johnson
* @date Oct. 2015
**/
#include "SwingTurn.h"
/** Constructor
* @param turn Turning rate of robot -1.0 is full left turn, 1.0 is full right
* @param duration Length of time in milliseconds to turn for
**/
SwingTurn::SwingTurn(float turn, int duration) : PausableCommand("SwingTurn") {
_turn = turn;
_duration = duration;
curie = Robot::getInstance();
}
void SwingTurn::initialize() {}
void SwingTurn::execute() {
curie->drivetrain->swingTurn(_turn);
}
void SwingTurn::end() {
curie->drivetrain->stop();
}
bool SwingTurn::isFinished() {
return getTime() > _duration;
}
/** Stop the drivetrain when paused **/
void SwingTurn::onPause() {
curie->drivetrain->stop();
}
/** Nothing special on resume **/
void SwingTurn::onResume() {}