huawei-noah / SMARTS

Scalable Multi-Agent RL Training School for Autonomous Driving
MIT License
951 stars 190 forks source link

Map Conversion Error #1684

Closed yuant95 closed 2 years ago

yuant95 commented 2 years ago

High Level Description I'm trying to convert the map in the scenarios from SUMO Tto CommonRoad and then to Lanelet2 so I can use this map to generate more training data.

Desired SMARTS version 0.6.1

Operating System Ubuntu 20.04

Problems I'm using this converter https://gitlab.lrz.de/tum-cps/commonroad-scenario-designer to do the conversion. However, other than the smarts/scenarios/straight/3lane_cruise_single_agent/map.net.xml can be converted successfully, all other maps such as smarts/scenarios/intersection/1_to_1lane_left_turn_c/map.net.xml etc failled. The exception raised was as below.

/home/yuant426/commonroad-scenario-designer/crdesigner/map_conversion/sumo_map/cr2sumo/converter.py:34: UserWarning: Unable to import commonroad_dc.pycrccosy, converting static scenario into interactive is not supported!
  warnings.warn(
Warning: Could not write OpenDRIVE geoReference. Only unshifted Coordinate systems are supported (offset=-630882.85,-4856133.12)
/home/yuant426/miniconda3/envs/csdEnv/lib/python3.8/site-packages/commonroad/scenario/lanelet.py:1254: ShapelyDeprecationWarning: STRtree will be changed in 2.0.0 and will not be compatible with versions < 2.
  self._strtee = STRtree(list(self._buffered_polygons.values()))
Traceback (most recent call last):
  File "converter.py", line 12, in <module>
    scenario = sumo_to_commonroad(input_file)
  File "/home/yuant426/commonroad-scenario-designer/crdesigner/map_conversion/map_conversion_interface.py", line 105, in sumo_to_commonroad
    return convert_net_to_cr(input_file)
  File "/home/yuant426/commonroad-scenario-designer/crdesigner/map_conversion/sumo_map/sumo2cr.py", line 41, in convert_net_to_cr
    scenario = road_network.export_commonroad_scenario()
  File "/home/yuant426/commonroad-scenario-designer/crdesigner/map_conversion/opendrive/opendrive_conversion/network.py", line 225, in export_commonroad_scenario
    scenario.add_objects(
  File "/home/yuant426/miniconda3/envs/csdEnv/lib/python3.8/site-packages/commonroad/scenario/scenario.py", line 637, in add_objects
    self._mark_object_id_as_used(inc.incoming_id)
  File "/home/yuant426/miniconda3/envs/csdEnv/lib/python3.8/site-packages/commonroad/scenario/scenario.py", line 1174, in _mark_object_id_as_used
    raise ValueError("ID %s is already used." % object_id)
ValueError: ID 21 is already used.

I'm not too familar with the map format. Is there some formatting issue in the other maps that may cause this problem? Any help is appreciated!

Gamenot commented 2 years ago

@yuant95 I am not sure how I missed this. We cannot be clear on why this might be a problem. In theory, commonroad should be able to convert the maps to OpenDRIVE and then to Lanelet2.

Potential fix for repeating ids issue (likely source of problem)

It looks like the converter met the same incoming road id multiple times. I am unsure quite exactly why this would be the case but it might be that we included junctions and they split in a way that can have duplicate ids. That is what might be suggested here:

-> self._mark_object_id_as_used(inc.incoming_id)
--> raise ValueError("ID %s is already used." % object_id)

The conversion to get rid of the internal junctions links would be:

1) netedit smarts/scenarios/intersection/1_to_1lane_left_turn_c/map.net.xml 2) Processing -> Options -> Junctions -> [x] no-internal-links (check) 3) Processing -> Compute Junctions with volitile options 4) Save

Dealing with the warning (unlikely to be the root cause)

A warning you posted mentions that the map has shifted coordinates:

Warning: Could not write OpenDRIVE geoReference. Only unshifted Coordinate systems are supported (offset=-630882.85,-4856133.12)

I believe this refers to netOffset as seen here: https://sumo.dlr.de/docs/Networks/SUMO_Road_Networks.html#coordinates_and_alignment. It should be possible to open up the sumo *.net.xml and set "netOffset" back to (0,0). Generally, you would use netconvert to fix it properly.

...
<net ...>
<location netOffset="0.00,0.00" .../>
...
</net>

I hope this helps.

Gamenot commented 2 years ago

@yuant95 To follow up it is possible to use neconvert to change no-internal-links using --no-internal-links as noted here: https://sumo.dlr.de/docs/netconvert.html#junctions

yuant95 commented 2 years ago

@Gamenot Thanks for getting back to me! To clarify, I should first use neconvert to convert the SUMO map to get rid of the internal junctions links, and then feed the new map to the CommonRoad Scenario Designer to convert the SUMO map to other format?

Gamenot commented 2 years ago

@Gamenot Thanks for getting back to me! To clarify, I should first use neconvert to convert the SUMO map to get rid of the internal junctions links, and then feed the new map to the CommonRoad Scenario Designer to convert the SUMO map to other format?

@yuant95 Sorry for the late reply on this. My intention was as you stated.