Skip to content

Commit

Permalink
Add costs for car u-turn
Browse files Browse the repository at this point in the history
  • Loading branch information
hbruch committed Jul 25, 2024
1 parent df3bdae commit 5567b4c
Showing 1 changed file with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ public int getMaxLeftTurnAngle() {
return 315;
}

public int getMinUTurnAngle() {
return 170;
}

public int getMaxUTurnAngle() {
return 190;
}

/**
* Expected time it takes to make a right at a light.
*/
Expand All @@ -77,13 +85,27 @@ public double getExpectedLeftAtLightTimeSec() {
return 15.0;
}

/**
* Expected time it perform a U-turn at a light.
*/
public double getExpectedUTurnAtLightTimeSec() {
return 20.0;
}

/**
* Expected time it takes to make a right without a stop light.
*/
public double getExpectedRightNoLightTimeSec() {
return 8.0;
}

/**
* Expected time it takes to make a u-turn without a stop light.
*/
public double getExpectedUTurnNoLightTimeSec() {
return 40.0;
}

/**
* Expected time it takes to continue straight without a stop light. This used to be higher, but
* it caused unrealistically slow car travel.
Expand Down Expand Up @@ -159,6 +181,8 @@ private double computeDrivingTraversalDuration(
return getExpectedRightAtLightTimeSec();
} else if (isTurnAcrossTraffic(turnAngle)) {
return getExpectedLeftAtLightTimeSec();
} else if (isUTurn(turnAngle)) {
return getExpectedUTurnAtLightTimeSec();
} else {
return getExpectedStraightAtLightTimeSec();
}
Expand All @@ -173,6 +197,8 @@ private double computeDrivingTraversalDuration(
return getExpectedRightNoLightTimeSec();
} else if (isTurnAcrossTraffic(turnAngle)) {
return getExpectedLeftNoLightTimeSec();
} else if (isUTurn(turnAngle)) {
return getExpectedUTurnNoLightTimeSec();
} else {
return getExpectedStraightNoLightTimeSec();
}
Expand Down Expand Up @@ -218,4 +244,8 @@ private boolean isLeftTurn(int turnAngle) {
private boolean isRightTurn(int turnAngle) {
return turnAngle >= getMinRightTurnAngle() && turnAngle < getMaxRightTurnAngle();
}

private boolean isUTurn(int turnAngle) {
return turnAngle >= getMinUTurnAngle() && turnAngle < getMaxUTurnAngle();
}
}

0 comments on commit 5567b4c

Please sign in to comment.