-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLineFollowToSwitch.cpp
More file actions
45 lines (37 loc) · 1.21 KB
/
LineFollowToSwitch.cpp
File metadata and controls
45 lines (37 loc) · 1.21 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
/** Line follows until the limit switch in the slot on the front of the robot
* is triggered
* @author Hans Johnson
* @date Oct. 2015
**/
#include "LineFollowToSwitch.h"
/** Constructor
* @param speed Linefollowing speed
* @param drive Drivetrain object to use for driving, must be initialized
**/
LineFollowToSwitch::LineFollowToSwitch(float speed) : PausableCommand("LineFollowToSwitch") {
_speed = speed;
curie = Robot::getInstance();
}
/** Nothing to do for initialization **/
void LineFollowToSwitch::initialize() {
}
/**
* Commands the robot to follow the line at the specified speed
*@param speed Speed that the robot should line follow at
**/
void LineFollowToSwitch::execute() {
curie->drivetrain->drive(_speed, 0.08*curie->lineTracker->lineError());
}
void LineFollowToSwitch::end() {
curie->drivetrain->stop();
}
/** Command is done when the alignment switch detects the post **/
bool LineFollowToSwitch::isFinished() {
return curie->alignmentDetector->isAligned(); // Is finished if limit switch is triggered
}
/** Stop the drivetrain while paused **/
void LineFollowToSwitch::onPause() {
curie->drivetrain->stop();
}
/** Nothing special when resuming **/
void LineFollowToSwitch::onResume() {}