Skip to content

Conversation

dmoszynski
Copy link
Contributor

@dmoszynski dmoszynski commented Dec 5, 2024

Description

Important

Right before merging this PR, please change the target branch of #1479 to master.

Otherwise that PR (which is next in line to be merged) will be closed automatically.

Abstract

This is the second PR of 6 related to the HdMapUtils refactor (for the first one, see #1472).
For a full overview of changes that all 6 PRs will introduce, please see the Abstract of the first PR.

Background

The lanelet_wrapper namespace contains:

These static methods are used by the sub-namespaces of lanelet_wrapper.
lanelet_wrapper namespace consist of 6 sub-namespaces:

As a result of the merge of this PR 2/6, the namespaces lanelet_wrapper::lanelet_map, lanelet_wrapper::distance, lanelet_wrapper::route and lanelet_wrapper::traffic_lights were added to the project. But most importantly, the ::distance from utils is adapted for its use.
In addition to this, PR is making several other improvements to the code, see below for details.

Details

The distance namespace in lanelet_wrapper and only the strictly necessary parts of route and traffic_lights are developed.

Important

By moving from HdMapUtils, we mean moving the entire member function to lanelet_wrapper - making it a free function.
This is accessible to traffic_simulator through free functions in utils namespace.

Before these changes the structure looked like this:

<HdMapUtils member function name>

After the changes structure looks like this:

<utils namespace and function name><lanelet_wrapper namespace and function name>

Below is the list of moved function (member functions transformed to free functions)

Tip

Most functions that have been removed from HdMapUtils have been renamed in such a way that the get prefix has been removed and thus the first letter of the new function name has been made lower case.

Example of such name change can be the following

HdMapUtils::getLateralDistancelanelet_wrapper::distance::lateralDistance

Old name New name
HdMapUtils::getLateralDistance distance::lateralDistancelanelet_wrapper::distance::lateralDistance
HdMapUtils::getLongitudinalDistance distance::longitudinalDistancelanelet_wrapper::distance::longitudinalDistance
HdMapUtils::getDistanceToStopLine distance::distanceToStopLinelanelet_wrapper::distance::distanceToStopLine
HdMapUtils::getDistanceToTrafficLightStopLine distance::distanceToTrafficLightStopLinelanelet_wrapper::distance::distanceToTrafficLightStopLine
HdMapUtils::getDistanceToCrosswalk distance::distanceToCrosswalklanelet_wrapper::distance::distanceToCrosswalk
HdMapUtils::getLeftBound lanelet_wrapper::lanelet_map::leftBound
HdMapUtils::getRightBound lanelet_wrapper::lanelet_map::rightBound
HdMapUtils::getLaneletPolygon lanelet_wrapper::lanelet_map::laneletPolygon
HdMapUtils::getStopLinePolygon lanelet_wrapper::lanelet_map::stopLinePolygon
HdMapUtils::toPolygon lanelet_wrapper::lanelet_map::toPolygon
HdMapUtils::getRightOfWayLaneletIds lanelet_wrapper::lanelet_map::rightOfWayLaneletIds
HdMapUtils::getTrafficSignRegulatoryElementsOnPath lanelet_wrapper::lanelet_map::trafficSignsOnPath
HdMapUtils::getStopLinesOnPath lanelet_wrapper::lanelet_map::stopLinesOnPath
HdMapUtils::getStopLineIdsOnPath lanelet_wrapper::lanelet_map::stopLineIdsOnPath
HdMapUtils::getRoute route::routelanelet_wrapper::route::route
HdMapUtils::getTrafficLightStopLinesPoints lanelet_wrapper::traffic_lights::trafficLightStopLinesPoints
HdMapUtils::getTrafficLightIdsOnPath lanelet_wrapper::traffic_lights::trafficLightStopLinesPoints
HdMapUtils::getTrafficLights lanelet_wrapper::traffic_lights::toAutowareTrafficLights
HdMapUtils::getTrafficLightRegulatoryElementsOnPath lanelet_wrapper::traffic_lights::autowareTrafficLightsOnPath

Additionally, distance::distanceToYieldStop function has been separated from ActionNode::getYieldStopDistance in order to improve readability and to maintain the division of functionality.

Note

Some of the functions copied from HdMapUtils class have been slightly modified. The modifications are small improvements of things like removing storing of unnecessary values.
One such change is in function distanceToStopLine where instead of adding all values to std::set and in the end using the first one, only the smallest value is stored.
Before:

if (collision_point) {
collision_points.insert(collision_point.value());
}
}
if (collision_points.empty()) {
return std::nullopt;
}
return *collision_points.begin();

After:
if (const auto & collision_point = route_spline.getCollisionPointIn2D(stop_line_points)) {
if (not min_distance.has_value() or collision_point.value() < min_distance.value()) {
min_distance = collision_point;
}
}
}
return min_distance;

Copyright

It has been notices that in some files the copyright date is wrong (other than 2015), thus the date has been fixed both in files added or modified by this PR and any other files where the incorrect copyright date has been noticed.

References

INTERNAL LINK

Destructive Changes

Known Limitations

dmoszynski and others added 13 commits December 5, 2024 13:10
…ecessary parts of ::route, ::lanelet_map, ::traffic_lights
…): use ::distance from lanelet_wrapper instead of hdmap_utils
…ref/RJD-1387-hdmap-utils-to-lanelet-wrapper-distance
…ref/RJD-1387-hdmap-utils-to-lanelet-wrapper-distance
…ref/RJD-1387-hdmap-utils-to-lanelet-wrapper-distance
…let-wrapper-pose' into ref/RJD-1387-hdmap-utils-to-lanelet-wrapper-distance
…let-wrapper-pose' into ref/RJD-1387-hdmap-utils-to-lanelet-wrapper-distance
@dmoszynski dmoszynski self-assigned this Dec 10, 2024
@dmoszynski dmoszynski changed the title HdMapUtils refactor (PR 2/X) - extend lanelet_wrapper: add ::distance and necessary parts of ::route, ::lanelet_map, ::traffic_lights HdMapUtils refactor (PR 2/6) - extend lanelet_wrapper: add ::distance and necessary parts of ::route, ::lanelet_map, ::traffic_lights Dec 11, 2024
dmoszynski and others added 5 commits December 11, 2024 17:33
…ref/RJD-1387-hdmap-utils-to-lanelet-wrapper-distance
…let-wrapper-pose' into ref/RJD-1387-hdmap-utils-to-lanelet-wrapper-distance
…ref/RJD-1387-hdmap-utils-to-lanelet-wrapper-distance
…let-wrapper-pose' into ref/RJD-1387-hdmap-utils-to-lanelet-wrapper-distance

Signed-off-by: Mateusz Palczuk <[email protected]>
@TauTheLepton TauTheLepton self-assigned this Jan 9, 2025
TauTheLepton and others added 9 commits January 15, 2025 13:53
…let-wrapper-pose' into ref/RJD-1387-hdmap-utils-to-lanelet-wrapper-distance

Signed-off-by: Mateusz Palczuk <[email protected]>
…ref/RJD-1387-hdmap-utils-to-lanelet-wrapper-distance
…ref/RJD-1387-hdmap-utils-to-lanelet-wrapper-distance
…ref/RJD-1387-hdmap-utils-to-lanelet-wrapper-distance
… memory in `std::vector`

Signed-off-by: Mateusz Palczuk <[email protected]>
… overhead in distance to stop line calculation functions

Signed-off-by: Mateusz Palczuk <[email protected]>
Copy link
Collaborator

@hakuturu583 hakuturu583 left a comment

Choose a reason for hiding this comment

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

LGTM waiting for regression test result.

@hakuturu583 hakuturu583 added bump major If this pull request merged, bump major version of the scenario_simulator_v2 wait for regression test and removed bump minor If this pull request merged, bump minor version of the scenario_simulator_v2 labels Aug 7, 2025
Copy link
Collaborator

@hakuturu583 hakuturu583 left a comment

Choose a reason for hiding this comment

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

Copy link

sonarqubecloud bot commented Aug 8, 2025

@hakuturu583
Copy link
Collaborator

@TauTheLepton This PR was degraded.
Please check and fix problems.

@hakuturu583
Copy link
Collaborator

@TauTheLepton I will conform and fix this pull request.

Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bump major If this pull request merged, bump major version of the scenario_simulator_v2 refactor wait for regression test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants