-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPointTurnToLine.cpp
More file actions
41 lines (33 loc) · 1 KB
/
PointTurnToLine.cpp
File metadata and controls
41 lines (33 loc) · 1 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
/** Turn the robot with a zero turn radius to a line
* @author Hans Johnson
* @date Oct. 2015
**/
#include "PointTurnToLine.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
**/
PointTurnToLine::PointTurnToLine(float turn) : PausableCommand("PointTurnToLine") {
_turn = turn;
curie = Robot::getInstance();
}
void PointTurnToLine::initialize() {}
void PointTurnToLine::execute() {
curie->drivetrain->pointTurn(_turn);
onLine = (abs(curie->lineTracker->lineError()) > 8) | onLine;
}
void PointTurnToLine::end() {
curie->drivetrain->stop();
}
/** Command is finished when the line tracker is on the
* center of the line
**/
bool PointTurnToLine::isFinished() {
return curie->lineTracker->centerOnLine() && onLine;
}
/** Stop the drivetrain while paused **/
void PointTurnToLine::onPause() {
curie->drivetrain->stop();
}
/** Nothing special on resume **/
void PointTurnToLine::onResume() {}