Computation of lane width

hi all,

I would like to ask whether there exist some methods/functions to compute the lane width in the Commonroad scenario.

Now I use the distance between vertices as follows. But I’m not sure if this is valid for different lane configurations.

scenario.lanelet_network.lanelets[0].left_vertices[0][1]-scenario.lanelet_network.lanelets[0].right_vertices[0][1]

Thanks in advance and best regards,
Yuanfei

Hi Yuanfei,

currently, such a function is not integrated in CommonRoad-io.
We will consider it for future releases.

In case of your solution, you have to consider the Euclidean distance between two points. You are only consider the y-position.

Note that the width can change between two “indices” of the polyline. Depending on what you want to do, you have to interpolate the position on the polyline.

Best,
Sebastian

Hi Sebastian,

thanks for the tips! It now makes sense. :slight_smile:

best regards,
Yuanfei

Hi Yuanfei,

One possible option would be creating road polygons with the function boundary.create_road_polygons, like in the specified example:

create_road_polygons(scenario, method = ‘lane_polygons’, resample=1, buffer=1, triangulate=True)

https://commonroad.in.tum.de/docs/commonroad-drivability-checker/sphinx/api_boundary.html

Then it would be possible to operate with the corresponding pycrcc polygons that are contained in the returned pycrcc.ShapeGroup, one polygon for each lane. A way to determine the width of the resulting triangulated lane polygon is adding it into a pycrcc.CollisionChecker object and calling the CollisionChecker.raytrace function for that polygon. It would allow you to measure the lane width like with a ruler, at any desired position or angle. See tutorial 1 and tutorial 3 for more details.

https://commonroad.in.tum.de/drivability_checker