-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLineFollowToCrossLine.cpp
More file actions
39 lines (31 loc) · 1.06 KB
/
LineFollowToCrossLine.cpp
File metadata and controls
39 lines (31 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
/** Line follow to an intersection between two lines
* @author Hans Johnson
* @date Oct. 2015
**/
#include "LineFollowToCrossLine.h"
/* Constructor */
LineFollowToCrossLine::LineFollowToCrossLine(float speed) : PausableCommand("LineFollowToCrossLine"){
_speed = speed;
curie = Robot::getInstance();
}
void LineFollowToCrossLine::initialize() {}
/**
* Commands the robot to follow the line at the specified speed
*@param speed Speed that the robot should line follow at
**/
void LineFollowToCrossLine::execute() {
curie->drivetrain->drive(_speed, 0.08*curie->lineTracker->lineError());
}
void LineFollowToCrossLine::end() {
curie->drivetrain->stop();
}
/** Command is done when the LineTracker detects a cross **/
bool LineFollowToCrossLine::isFinished() {
return curie->lineTracker->isAtCross(); // Is finished if outer sensors are on black (only happens if on a cross line)
}
/** Stop the drivetrain while paused **/
void LineFollowToCrossLine::onPause() {
curie->drivetrain->stop();
}
/** Do nothing special on resume **/
void LineFollowToCrossLine::onResume() {}