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

Fixes bug at ToRoadPosition query. #174

Merged
merged 4 commits into from
Sep 14, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions maliput_malidrive/src/maliput_malidrive/base/lane.cc
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ void Lane::DoToLanePositionBackend(const maliput::math::Vector3& backend_pos, ma
const maliput::math::Vector3 unconstrained_prh{BackendFrameToLaneFrame(backend_pos)};
MALIDRIVE_IS_IN_RANGE(unconstrained_prh[0], p0_, p1_);
const double s = s_from_p_(unconstrained_prh[0]);
const maliput::api::RBounds segment_boundaries = segment_bounds(s);
const double r = maliput::math::saturate(unconstrained_prh[1], segment_boundaries.min(), segment_boundaries.max());
const maliput::api::RBounds lane_boundaries = lane_bounds(s);
const double r = maliput::math::saturate(unconstrained_prh[1], lane_boundaries.min(), lane_boundaries.max());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, look at the following https://github.com/ToyotaResearchInstitute/maliput/blob/main/maliput/include/maliput/api/road_geometry.h#L85-L93

Quoted here:

  /// The map from RoadGeometry to the `Inertial`-frame is not onto (as a bounded
  /// RoadGeometry cannot completely cover the unbounded Cartesian universe).
  /// If @p inertial_position does represent a point contained within the volume
  /// of the RoadGeometry, then result distance is guaranteed to be less
  /// than or equal to `linear_tolerance()`.
  ///
  /// The map from RoadGeometry to `Inertial`-frame is not necessarily one-to-one.
  /// Different `(s,r,h)` coordinates from different Lanes, potentially from
  /// different Segments, may map to the same `(x,y,z)` `Inertial`-frame location.

I think using segment_bounds() is correct because when doing ToLanePosition() you can map the entire Segment volume.

If an INERTIAL Frame point falls within the Segment volume it is expected that all RoadPositions (one per RoadPositions in the Segment) have distance close to zero. RoadGeometry::ToRoadGeometry should return the one that minimizes (closer to zero) the r-coordinate.

By looking at #173 , the mapping to lane 1_0_1 yields r = -1.97309e-10 and that's the minimum. The algorithm should return that instead of any other lane in the Segment.

Copy link
Collaborator Author

@francocipollone francocipollone Sep 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know what you think about 26f8b7c.

It matches API definition and complies with both issues:

( I had missed pressing the "comment" button)

const maliput::api::HBounds elevation_boundaries = elevation_bounds(s, r);
const double h =
maliput::math::saturate(unconstrained_prh[2], elevation_boundaries.min(), elevation_boundaries.max());
Expand Down