-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSwingTurnToLine.cpp
More file actions
43 lines (35 loc) · 1.06 KB
/
SwingTurnToLine.cpp
File metadata and controls
43 lines (35 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
/** Command to perform a swing turn until the linesensor
* detects the line
* @author Jordan Burklund
* @date Oct. 2015
**/
#include "SwingTurnToLine.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
**/
SwingTurnToLine::SwingTurnToLine(float turn) : PausableCommand("SwingTurnToLine") {
_turn = turn;
curie = Robot::getInstance();
}
void SwingTurnToLine::initialize() {}
void SwingTurnToLine::execute() {
curie->drivetrain->pointTurn(_turn);
onLine = (abs(curie->lineTracker->lineError()) > 8) | onLine;
}
void SwingTurnToLine::end() {
curie->drivetrain->stop();
}
/** Command is done when the line sensor detects the line,
* and did not previously detect the line
**/
bool SwingTurnToLine::isFinished() {
return (curie->lineTracker->centerOnLine() && onLine);
}
/** Stop the drivetrain while paused **/
void SwingTurnToLine::onPause() {
curie->drivetrain->stop();
}
/** Nothing special on resume **/
void SwingTurnToLine::onResume() {}