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 3 commits
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
18 changes: 13 additions & 5 deletions maliput_malidrive/src/maliput_malidrive/base/road_geometry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,19 @@ namespace {
bool IsNewRoadPositionResultCloser(const maliput::api::RoadPositionResult& new_road_position_result,
const maliput::api::RoadPositionResult& road_position_result) {
const double delta = new_road_position_result.distance - road_position_result.distance;
if (delta > malidrive::constants::kStrictLinearTolerance) {
return false;
}
if (delta < -malidrive::constants::kStrictLinearTolerance) {
return true;
const bool different_segment = road_position_result.road_position.lane->segment()->id() !=
new_road_position_result.road_position.lane->segment()->id();

// When lanes belong to the same segment is expected that the distance value is almost equal so we can't use the
// distance as main condition. When lanes doesn't belong to the same segment we can use the distance as main
francocipollone marked this conversation as resolved.
Show resolved Hide resolved
// condition.
if (different_segment) {
if (delta < -malidrive::constants::kStrictLinearTolerance) {
return true;
}
if (delta >= malidrive::constants::kStrictLinearTolerance) {
return false;
}
}

auto is_within_lane_bounds = [](double r, const maliput::api::RBounds& lane_bounds) {
Expand Down