Skip to content
This repository was archived by the owner on Jul 25, 2022. It is now read-only.

Commit 70a5870

Browse files
committed
Added lock to move but backwards in case bumper is pressed.
1 parent a247b38 commit 70a5870

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

robot-control-src/robot-control-src.ino

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,17 @@ void loop()
160160
}
161161
if(newTarget.isTargetNew)
162162
{
163-
if(newTarget.newDrive!=0)
163+
const bool bumperIsPressed = digitalRead(board::leftBumper) == LOW || digitalRead(board::rightBumper) == LOW;
164+
if(newTarget.newDrive!=0 && (!newTarget.forward || !bumperIsPressed))
164165
{
165166
drives::driveCounter(newTarget.newDrive, drives::cruiseSpeed, !newTarget.forward);
167+
newTarget = { };
166168
}
167-
else if(newTarget.newRotate!=0)
169+
else if(newTarget.newRotate!=0 && !bumperIsPressed)
168170
{
169171
drives::rotateCounter(newTarget.newRotate, drives::cruiseSpeed, newTarget.clockwise);
172+
newTarget = { };
170173
}
171-
newTarget = { };
172174
}
173175
}
174176
}

0 commit comments

Comments
 (0)