Multi Ego Vehicle Support

I was wondering if there is support to include control of multiple vehicles on the interactive SUMO interface. I understand that simulate_with_planner() function has an option to include an ego vehicle by using create_ego_obstacle. Is it possible to include more than just one ego obstacle?

Thanks

Hi, the interactive scenario supports multi ego vehicles, you can simply pass in a scenario with multiple planning problems. But the current version needs a minor fix to enable that. We can update that in coming weeks. In case you need it rather soon, here is how you can do the fix:

  1. in path/to/python/python3.7/site-packages/sumocr-2020.2-py3.7.egg/sumocr/interface/sumo_simulation.py (can be accessed by this trace of functions: simulate_with_planner->simulate_scenario->sumo_sim.initialize), replace near line 228 with the following code, as well as change the _create_sumo_id function:


  2. in simulation/simulation.py, change line 371 to suffix=SimulationOption.MOTION_PLANNER.value + str(idx + 1)) (this allows plotting trajectory of all ego vehicles).

With the above changes, the package simulates with multi ego vehicles and plots their respective trajectories. In the next update we will modify the create_gif function so that it plots all ego vehicles in one GIF file.

Now in the motion planner part you can use a = -5.0 if idx == 1 else -2.0 to brake the ego of the first planning problem with -2.0 and the second with -5.0.

To add a planning problem, you can edit the scenario directly, e.g. open USA_US101-26_2_I-1-1.cr.xml and duplicate the fields for planningProblem, but remember to assign a different id to the new planning problem.