go straight on intersections
This commit is contained in:
parent
cbf38e4fd6
commit
d3b9bd3ae5
2 changed files with 7 additions and 12 deletions
|
@ -49,15 +49,5 @@ float LineSensor::CalcError(void)
|
|||
|
||||
bool LineSensor::CheckIntersection(void)
|
||||
{
|
||||
bool retVal = false;
|
||||
|
||||
bool isLeftDark = analogRead(leftSensorPin) > DARK_THRESHOLD;
|
||||
bool isRightDark = analogRead(rightSensorPin) > DARK_THRESHOLD;
|
||||
|
||||
bool onIntersection = isLeftDark && isRightDark;
|
||||
if(onIntersection && !prevOnIntersection) retVal = true;
|
||||
|
||||
prevOnIntersection = onIntersection;
|
||||
|
||||
return retVal;
|
||||
}
|
||||
return AverageReflectance() > INTERSECTION_THRESHOLD;
|
||||
}
|
||||
|
|
|
@ -118,6 +118,11 @@ void Robot::LineFollowingUpdate(void)
|
|||
|
||||
speed *= 1 - (abs(rollingTurnRate) * KTurnRate);
|
||||
|
||||
if (lineSensor.CheckIntersection()) {
|
||||
turnEffort = 0;
|
||||
speed *= 0.8;
|
||||
}
|
||||
|
||||
if (!lineSensor.LineDetected()) {
|
||||
lineLostFrames -= 1;
|
||||
if (lineLostFrames < 0) {
|
||||
|
|
Loading…
Reference in a new issue