Closed francocipollone closed 1 year ago
I am happy to have this sample road to evaluate it. I'll think of this and get back with a proposal.
I have another proposal that deserves exploration.
We can compute the lane bounds and segment bounds by using the orientation at p of the centerline. That should give us the roll, pitch, yaw angles required to go from the centerline at p to both extents. We could compute the r_hat vector and intersect it to the left and right LineStrings of the lane or the segment.
PROs:
CONs:
I think we should push down a bit the information and do a mapping between the sections of each line that have certain reciprocity.
For example, in the S shape road, we could apply the scaling fro the C and inverted C, with different scaling functions. Thoughts @francocipollone ?
I like the general idea and I think that it is an improvement to what we have nowadays. However:
We can compute the lane bounds and segment bounds by using the orientation at p of the centerline. That should give us the roll, pitch, yaw angles required to go from the centerline at p to both extents.
Nowadays the orientation's rolling value is being computed using a scaling factor.(superelevation). We would need to tackled that first then. Actually the base of the issue is the same.
https://github.com/maliput/maliput_sparse/blob/c4663c98604f54d478e2b390ad72f4089240340a/src/geometry/lane_geometry.cc#L98 Check also https://github.com/maliput/maliput_sparse/issues/15#issuecomment-1250683237
We could compute the r_hat vector and intersect it to the left and right LineStrings of the lane or the segment.
We are in R3 and the centerline may not be in the same plane as the left and rigthstring so the intersection could not happen. Maybe intersecting a plane formed by a point in the centerline and the normal with the left/right string could work.
So the issue, besides the lane bounds or orientation, gets reduced to how we could obtain correctly the equivalent p for the left and right strings. Does it make sense to try to calculate this in the XY plane in order to get the equivalent p? We could obtain the 2dtagent at the centerline and from there calculate the r_hat(2d) to intersect with the boundaries. It has its flaws indeed but it is still an improvement.
Sorry for the long delay here.
I took a look at the code and I think we can define "lane sections" when building the centerline from the left and right linestrings. Each new point that would build the centerline linestrings is made out of two points in the left and right linestrings as well. Some points in the left and in the right linestrings might be omitted when selecting the best candidate, thus we could define the extent at which each point will map to the left and to the right.
There are some extreme cases in which one of the side iterators does not advance to the next point. This case is not an exception, but it will degenerate to a side with length zero.
The picture belows how we should map to each side the p mapping. These lane sections would consolidate the path length up to the lane section under the mapping and then do a linear scaling to the sides. We would make sure to advance the necessary path length on each side this way and get the right mapping. Note that this method reduces the impact on the r_hat direction as it does not leave behind the path length distance on each side (or each linestring).
From a code point of view, everything could be handed by the LaneGeometry class. When computing the centerline, we could also make sure to create another structure that keeps track of the points in the left and right linestring that define the quadrilateral of the lane section under that yields two consecutive points in the centerline. Then, every time we are required to compute the lane boundaries, we could do so by implementing the method described above. The key change will be in the prototype and implementation of LineString3d ComputeCenterline3d(const LineString3d& left, const LineString3d& right)
. We would be required to return some compound object with a LineString3d and the reference waypoints for each other side. We could opt to return a vector of iterators for each other LineString, a copy of the points or a LineString itself.
As discussed F2F:
Some issues:
Perhaps we could do some post processing after computing the centerline for finding the lane sections:
Summary
Context
When calculating the RBounds at a given
p
, it is required to obtain the equivalentp
in the left and right boundary in order to obtain the boundaries of the lane correctly. For doing so, we'd decided to follow a simple scaling approximation, as the situation escalates quickly when trying to get something more accurate:https://github.com/maliput/maliput_sparse/blob/0d6611bf5a26588010b238b3b9f3a9c397d94be4/src/geometry/lane_geometry.cc#L122-L145
This works correctly in some simple geometries:
However, this causes some undesired values when having geometries that from the start to the end don't maintain a linear proportion between the length between the left and right linestring (if that makes sense): For example
Because of this situation, the final lane that is loaded (for example using maliput_osm backend) shows a wider lane as reaching the middle of the road.
For the record this is the flat-s-shape road used: lanelet2_s_shape_road.zip