Skip to content

Commit e41ffa0

Browse files
matejm42dorn-gerhardwentasah
authored
Fix waypoints next and previous when connecting two lines with opposite directions (#7137)
* Update semantic labels (changed from version 0.9.13 -> 0.9.14) * Add "Other" Label description in ref_sensors.md * Revert "Add "Other" Label description in ref_sensors.md" This reverts commit 3958e35. * Revert "Update semantic labels (changed from version 0.9.13 -> 0.9.14)" This reverts commit 6ee572e. * Fix waypoints next and previous when connecting two lines with opposite dirrections. Fixing issue #7136 Probably not the best solution, but works for our case. The waypoint that would cause conflict when calling next from it is not returned. * Update CHANGELOG.md * Update CHANGELOG.md Co-authored-by: Michal Sojka <michal.sojka@cvut.cz> --------- Co-authored-by: Gerhard Dorn <67096719+dorn-gerhard@users.noreply.github.com> Co-authored-by: Michal Sojka <michal.sojka@cvut.cz>
1 parent e8947a4 commit e41ffa0

2 files changed

Lines changed: 33 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
## Latest Changes
2+
* Fixed waypoint.next and .previous causing loops when two opposite-direction lanes follow each other in the map.
23
* Fixed a bug that caused navigation information not to be loaded when switching maps
34
* Prevent from segfault on failing SignalReference identification when loading OpenDrive files
45
* Added vehicle doors to the recorder

LibCarla/source/carla/road/Map.cpp

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -582,10 +582,23 @@ namespace road {
582582
successor.road_id != waypoint.road_id ||
583583
successor.section_id != waypoint.section_id ||
584584
successor.lane_id != waypoint.lane_id);
585-
result = ConcatVectors(result, GetNext(successor, distance - remaining_lane_length));
586-
}
585+
// Fix situations, when next waypoint is in the opposite dirrection and
586+
// this waypoint is his successor, so this function would end up in a loop
587+
bool is_broken = false;
588+
for (const auto &future_succcessor : GetSuccessors(successor)) {
589+
if (future_succcessor.road_id == waypoint.road_id
590+
&& future_succcessor.lane_id == waypoint.lane_id
591+
&& future_succcessor.section_id == waypoint.section_id){
592+
is_broken = true;
593+
break;
594+
}
595+
} // end inner for
596+
if (!is_broken){
597+
result = ConcatVectors(result, GetNext(successor, distance - remaining_lane_length));
598+
}
599+
} // end outer for
587600
return result;
588-
}
601+
} // end GetNext
589602

590603
std::vector<Waypoint> Map::GetPrevious(
591604
const Waypoint waypoint,
@@ -618,10 +631,23 @@ namespace road {
618631
successor.road_id != waypoint.road_id ||
619632
successor.section_id != waypoint.section_id ||
620633
successor.lane_id != waypoint.lane_id);
621-
result = ConcatVectors(result, GetPrevious(successor, distance - remaining_lane_length));
622-
}
634+
// Fix situations, when next waypoint is in the opposite dirrection and
635+
// this waypoint is his predeccessor, so this function would end up in a loop
636+
bool is_broken = false;
637+
for (const auto &future_predecessor : GetPredecessors(successor)) {
638+
if (future_predecessor.road_id == waypoint.road_id
639+
&& future_predecessor.lane_id == waypoint.lane_id
640+
&& future_predecessor.section_id == waypoint.section_id){
641+
is_broken = true;
642+
break;
643+
}
644+
} // end inner for
645+
if (!is_broken){
646+
result = ConcatVectors(result, GetPrevious(successor, distance - remaining_lane_length));
647+
}
648+
} // end outer for
623649
return result;
624-
}
650+
} // end GetPrevious
625651

626652
boost::optional<Waypoint> Map::GetRight(Waypoint waypoint) const {
627653
RELEASE_ASSERT(waypoint.lane_id != 0);

0 commit comments

Comments
 (0)