-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEnsureRodInserted.cpp
More file actions
48 lines (40 loc) · 1.37 KB
/
EnsureRodInserted.cpp
File metadata and controls
48 lines (40 loc) · 1.37 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
46
47
48
/** Command to attempt to insert the rod if the robot missed the storage tube
* @author Hans Johnson
* @date Oct. 2015
**/
#include "EnsureRodInserted.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
**/
EnsureRodInserted::EnsureRodInserted(float speed, bool sideA) : PausableCommand("EnsureRodInserted") {
_speed = speed;
_sideA = sideA;
curie = Robot::getInstance();
}
/** Check if the supply tube indicates that it was inserted **/
void EnsureRodInserted::initialize() {
_bitmask = curie->reactorLink->getSupplyAvailabilityByte();
closestStorage = curie->tubeProcessor->getFreshRodTube(_bitmask, _sideA);
}
/** Push the rod in **/
void EnsureRodInserted::execute() {
curie->drivetrain->drive(_speed, 0.0);
curie->roller->spit();
}
void EnsureRodInserted::end() {
curie->drivetrain->stop();
curie->roller->stop();
}
/** Command is finished if the rod is detected to be fully inserted,
* or if the robot as driven up to the alignment post
**/
bool EnsureRodInserted::isFinished() {
return curie->alignmentDetector->isAligned() || ((curie->currentPos-closestStorage) != 0);
}
/** Stop the drivetrain while paused **/
void EnsureRodInserted::onPause() {
curie->drivetrain->stop();
}
/** Do nothing special on resume **/
void EnsureRodInserted::onResume() {}