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

Error when lane_id is not 0 but type is none #2

Open
aertssenaron opened this issue Aug 1, 2024 · 1 comment
Open

Error when lane_id is not 0 but type is none #2

aertssenaron opened this issue Aug 1, 2024 · 1 comment

Comments

@aertssenaron
Copy link

aertssenaron commented Aug 1, 2024

When I load an .xodr file where a right lane has as type 'none', and call RoadNetwork.get_roads(), I get the error:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/aron/.local/lib/python3.8/site-packages/pyxodr/road_objects/network.py", line 153, in get_roads
    self._link_roads()
  File "/home/aron/.local/lib/python3.8/site-packages/pyxodr/road_objects/network.py", line 123, in _link_roads
    road._link_lane_sections()
  File "/home/aron/.local/lib/python3.8/site-packages/pyxodr/road_objects/road.py", line 420, in _link_lane_sections
    lane_section._link_lanes()
  File "/home/aron/.local/lib/python3.8/site-packages/pyxodr/road_objects/lane_section.py", line 239, in _link_lanes
    for lane in self.lanes:
  File "/home/aron/.local/lib/python3.8/site-packages/pyxodr/road_objects/lane_section.py", line 170, in lanes
    lanes = self.left_lanes + self.right_lanes
  File "/usr/lib/python3.8/functools.py", line 967, in __get__
    val = self.func(instance)
  File "/home/aron/.local/lib/python3.8/site-packages/pyxodr/road_objects/lane_section.py", line 165, in right_lanes
    return self.__get_lanes_by_orientation(LaneOrientation.RIGHT)
  File "/home/aron/.local/lib/python3.8/site-packages/pyxodr/road_objects/lane_section.py", line 111, in __get_lanes_by_orientation
    if lane_obj.type not in self.ignored_lane_types:
TypeError: 'in <string>' requires string as left operand, not NoneType

EDIT: This only happens when I set ignored_lane_types='shoulder', if I do not specify lanes to ignore this is no issue.
The specification of this lane in the xodr file is given below, and if I change the type from "none" to something, the error is not given. The xodr file is generated by Matlab RoadRunner, so I guess this is an artefact on that side. I have solved it for now by ignoring the lane when it's type is None, but I'm not sure how this influences the outcome.

<lane id="-1" type="none" level="false">
<width sOffset="0.0000000000000000e+0" a="5.0000000000000001e-3" b="0.0000000000000000e+0" c="0.0000000000000000e+0" d="0.0000000000000000e+0"/>
<width sOffset="1.0977543679446107e+1" a="5.0000000000000001e-3" b="0.0000000000000000e+0" c="0.0000000000000000e+0" d="0.0000000000000000e+0"/>
<roadMark sOffset="0.0000000000000000e+0" type="none" material="standard" color="white" laneChange="none"/>
<roadMark sOffset="2.0061081095444564e+0" type="none" material="standard" color="white" laneChange="none"/>
<roadMark sOffset="1.0034897775404445e+1" type="none" material="standard" color="white" laneChange="none"/>
<speed sOffset="0.0000000000000000e+0" max="3.5000000000000000e+1" unit="mph"/>
<userData code="vectorLane">
<vectorLane sOffset="0.0000000000000000e+0" laneId="{afee3bff-c14b-4b80-8c5a-5c42e23b817e}" travelDir="undirected"/>
<vectorLane sOffset="1.0977543679446107e+1" laneId="{b47e6813-9b35-408b-a61f-782177cf7f9c}" travelDir="undirected"/>
</userData>
</lane>
@moonstarsky37
Copy link
Owner

@aertssenaron Sorry for late, as I haven’t worked on this project for quite a while.

In this project, the issue you mentioned about ignored_lane_types is indeed something that hasn’t been fully addressed in the OpenScenario (1.0.0) & OpenDrive format files (1.6). So, encountering such issues is expected. The solution you implemented is also a method I used in the earlier stages.

From what I observed using visualization software back then, the impact seemed minimal. However, there are a few key points you may want to check:

  • Impact on Road Geometry: Ignoring lanes marked as 'none' should not affect the computation of usable lanes, but it might impact the overall geometry if these lanes contribute to lane widths or road markings.
  • Road Markings: Road markings (if present) associated with these lanes might also be skipped, which could be relevant depending on your use case.
  • Lane Linking: In cases where the 'none' lanes form boundaries or are used for linking lanes, this may affect how lanes are connected, potentially leading to unexpected gaps or breaks in the road network.

To resolve this issue, you may want to check if ASAM OpenDRIVE has any updates or fixes (I only have the old version linked in my README.md).

Alternatively, a possible workaround is to modify the compiled Python script, similar to the following:

def __get_lanes_by_orientation(self, orientation):
    lanes = []
    for lane_obj in self._lanes:
        if lane_obj.orientation == orientation:
            # Only process if the lane type is not 'none' and respects the ignored types.
            if lane_obj.type is not None and lane_obj.type not in self.ignored_lane_types:
                lanes.append(lane_obj)
    return lanes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants