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 8, 2024
1 parent 9554487 commit 64420c7
Showing 1 changed file with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ 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 +83,27 @@ public double getExpectedLeftAtLightTimeSec() {
return 15.0;
}

/**
* Expected time it perform a U-turn at a light.
*/
public double getExpectedUTurnAtLightTimeSec() {
return 15.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 20.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 +179,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 +195,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 +242,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 64420c7

Please sign in to comment.