Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(sumo): LaneChangeMode.OFF should do no lane changes at all #383

Merged
merged 5 commits into from
Mar 22, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat(sumo): new lane change mode "FOLLOW_ROUTE"
kschrab committed Mar 18, 2024
commit a7259fe6c743716576a470b1a9c08bee877b3eb9
Original file line number Diff line number Diff line change
@@ -739,7 +739,7 @@ private synchronized void receiveInteraction(VehicleLaneChange vehicleLaneChange
log.warn("VehicleLaneChange failed: unsupported lane change mode.");
return;
}
bridge.getVehicleControl().changeLane(vehicleLaneChange.getVehicleId(), targetLaneId, vehicleLaneChange.getDuration());
bridge.getVehicleControl().changeLane(vehicleLaneChange.getVehicleId(), Math.max(0, targetLaneId), vehicleLaneChange.getDuration());

if (sumoConfig.highlights.contains(CSumo.HIGHLIGHT_CHANGE_LANE)) {
VehicleData vehicleData = bridge.getSimulationControl().getLastKnownVehicleData(vehicleLaneChange.getVehicleId());
Original file line number Diff line number Diff line change
@@ -38,32 +38,28 @@ public static SumoLaneChangeMode translateFromEnum(final LaneChangeMode laneChan
switch (laneChangeMode) {
case OFF:
mode.setSublaneChanges(false, false);
mode.setStrategicChanges(true, true);
mode.setRespectOtherDrivers(RESPECT_SPEED_GAPS_OF_OTHER_DRIVERS_ADAPT_SPEED);
break;
// For strategic lane changes (change lanes to continue the route),
// we always let SUMO overwrite requested lane changes (overrideTraci = true)
case FOLLOW_ROUTE:
mode.setSublaneChanges(false, false);
mode.setStrategicChanges(true, false);
mode.setRespectOtherDrivers(RESPECT_SPEED_GAPS_OF_OTHER_DRIVERS_ADAPT_SPEED);
break;
case AGGRESSIVE:
mode.setStrategicChanges(true, true);
mode.setStrategicChanges(true, false);
mode.setSpeedChanges(true, false);
break;
case CAUTIOUS:
mode.setStrategicChanges(true, true);
mode.setStrategicChanges(true, false);
mode.setCooperativeChanges(true, false);
mode.setSpeedChanges(true, false);
mode.setRightDriveChanges(true, true);
mode.setRightDriveChanges(true, false);
mode.setRespectOtherDrivers(RESPECT_SPEED_GAPS_OF_OTHER_DRIVERS_DO_NOT_ADAPT_SPEED);
break;
case PASSIVE:
schwepmo marked this conversation as resolved.
Show resolved Hide resolved
mode.setStrategicChanges(true, true);
mode.setCooperativeChanges(true, false);
mode.setSpeedChanges(true, false);
mode.setRightDriveChanges(true, true);
mode.setRespectOtherDrivers(RESPECT_SPEED_GAPS_OF_OTHER_DRIVERS_ADAPT_SPEED);
break;
case COOPERATIVE:
case DEFAULT:
mode.setStrategicChanges(true, true);
mode.setStrategicChanges(true, false);
mode.setCooperativeChanges(true, false);
mode.setSpeedChanges(true, false);
mode.setRightDriveChanges(true, false);
Original file line number Diff line number Diff line change
@@ -90,12 +90,13 @@ public void testGetAsInteger_overrideTraci() {

@Test
public void testTranslateFromEnum() {
assertEquals(1622, SumoLaneChangeMode.translateFromEnum(LaneChangeMode.DEFAULT).getAsInteger());
assertEquals(514, SumoLaneChangeMode.translateFromEnum(LaneChangeMode.OFF).getAsInteger());
assertEquals(1042, SumoLaneChangeMode.translateFromEnum(LaneChangeMode.AGGRESSIVE).getAsInteger());
assertEquals(1622, SumoLaneChangeMode.translateFromEnum(LaneChangeMode.COOPERATIVE).getAsInteger());
assertEquals(1942, SumoLaneChangeMode.translateFromEnum(LaneChangeMode.CAUTIOUS).getAsInteger());
assertEquals(1686, SumoLaneChangeMode.translateFromEnum(LaneChangeMode.PASSIVE).getAsInteger());
assertEquals(1621, SumoLaneChangeMode.translateFromEnum(LaneChangeMode.DEFAULT).getAsInteger());
assertEquals(512, SumoLaneChangeMode.translateFromEnum(LaneChangeMode.OFF).getAsInteger());
assertEquals(513, SumoLaneChangeMode.translateFromEnum(LaneChangeMode.FOLLOW_ROUTE).getAsInteger());
assertEquals(1041, SumoLaneChangeMode.translateFromEnum(LaneChangeMode.AGGRESSIVE).getAsInteger());
assertEquals(1621, SumoLaneChangeMode.translateFromEnum(LaneChangeMode.COOPERATIVE).getAsInteger());
assertEquals(1877, SumoLaneChangeMode.translateFromEnum(LaneChangeMode.CAUTIOUS).getAsInteger());
assertEquals(1621, SumoLaneChangeMode.translateFromEnum(LaneChangeMode.PASSIVE).getAsInteger());
}

}
Original file line number Diff line number Diff line change
@@ -17,9 +17,10 @@

public enum LaneChangeMode {
DEFAULT, // == COOPERATIVE
OFF, // no lane changes except strategic (514 in SUMO)
CAUTIOUS, //strategic, cooperative, speed changes, keep right, no speed adaption when changing lanes (917 in SUMO)
COOPERATIVE, //strategic, cooperative, speed changes, keep right, avoid collisions (597 in SUMO)
AGGRESSIVE, //strategic, no cooperative, speed changes, stay left, do not respect other drivers (17 in SUMO)
PASSIVE //strategic, no cooperative, speed changes, stay right, do not respect other drivers (661 in SUMO)
OFF, // no lane changes at all, only by explicit calls of changeLane
FOLLOW_ROUTE, // no lane changes except strategic
CAUTIOUS, //strategic, cooperative, speed changes, keep right, no speed adaption when changing lanes
COOPERATIVE, //strategic, cooperative, speed changes, keep right, avoid collisions
AGGRESSIVE, //strategic, no cooperative, speed changes, stay left, do not respect other drivers
PASSIVE //strategic, no cooperative, speed changes, stay right, do not respect other drivers
}