Skip to content

Commit

Permalink
Add speed mode to update speed on sumo (#564)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gamenot authored Feb 11, 2021
1 parent 0303d35 commit 248f9e7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions smarts/core/sumo_traffic_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,8 @@ def sync(self, provider_state: ProviderState):
for vehicle_id in external_vehicles_that_have_joined:
dimensions = provider_vehicles[vehicle_id].dimensions
self._create_vehicle(vehicle_id, dimensions)
no_checks = 0b00000
self._traci_conn.vehicle.setSpeedMode(vehicle_id, no_checks)

# update the state of all current managed vehicles
for vehicle_id in self._non_sumo_vehicle_ids:
Expand Down Expand Up @@ -426,6 +428,8 @@ def sync(self, provider_state: ProviderState):
)

for vehicle_id in vehicles_that_have_become_external:
no_checks = 0b00000
self._traci_conn.vehicle.setSpeedMode(vehicle_id, no_checks)
self._traci_conn.vehicle.setColor(
vehicle_id, SumoTrafficSimulation._social_agent_vehicle_color()
)
Expand All @@ -437,6 +441,9 @@ def sync(self, provider_state: ProviderState):
)
self._non_sumo_vehicle_ids.remove(vehicle_id)
# Let sumo take over speed again
# For setSpeedMode look at: https://sumo.dlr.de/docs/TraCI/Change_Vehicle_State.html#speed_mode_0xb3
all_checks = 0b11111
self._traci_conn.vehicle.setSpeedMode(vehicle_id, all_checks)
self._traci_conn.vehicle.setSpeed(vehicle_id, -1)

if self._endless_traffic:
Expand Down

0 comments on commit 248f9e7

Please sign in to comment.