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

HdMapUtils refactor (PR 1/6) - create lanelet_wrapper: use ::lanelet_map and ::pose #1472

Open
wants to merge 30 commits into
base: master
Choose a base branch
from

Conversation

dmoszynski
Copy link
Contributor

@dmoszynski dmoszynski commented Dec 3, 2024

Description

The non-regression is evidenced here.

Abstract

This is the first PR of 6 related to the HdMapUtils refactor - a class that allows you to get access to lanelet data - from an *.osm file.

The refactor is implemented in accordance with the proposal presented in the report WP11_Q2_2023: shared here.

As a result of merging all 6 PRs, HdMapUtils will no longer exist in the source code - it will be replaced by the LaneletWrapper and its namespace lanelet_wrapper - see a diagram below.

hdmaputils_refactor_init drawio

Background

The lanelet_wrapper namespace contains:

Main class LaneletWrapper is developed in the singleton pattern, and contains the activate(<path_to_lanelet_file>) method. LaneletWrapper uses static methods from the LaneletLoader class to load data from a *.osm file. This namespace also contains RouteCache, CenterPointsCache and LaneletLengthCache classes which are analogous to those in HdMapUtils. LaneletWrapper allows access to map data, graphs, rules and caches via static methods:

static auto activate(const std::string & lanelet_map_path) -> void;
[[nodiscard]] static auto map() -> lanelet::LaneletMapPtr;
[[nodiscard]] static auto routingGraph(const RoutingGraphType type)
-> lanelet::routing::RoutingGraphConstPtr;
[[nodiscard]] static auto trafficRules(const RoutingGraphType type)
-> lanelet::traffic_rules::TrafficRulesPtr;
[[nodiscard]] static auto routeCache(const RoutingGraphType type) -> RouteCache &;
[[nodiscard]] static auto centerPointsCache() -> CenterPointsCache &;
[[nodiscard]] static auto laneletLengthCache() -> LaneletLengthCache &;

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 1/6, the necessary source code for LaneletWrapper as a singleton and its activation in the required places is added to the project. As well as the first and second namespaces: lanelet_wrapper::lanelet_map, lanelet_wrapper::pose are added, But most importantly, the ::pose 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

LaneletWrapper is added and the lanelet_map namespace in utils is developed.
Now, in order to access the lanelet data, there is no need to create HdMapUtils, just call lanelet_map::activate() in a single instance of the program - passing the path to the *.osm map.

Currently, LaneletWrapper is activated in:

Note: By moving from HdMapUtils, we mean moving the entire method to lanelet_wrapper (as a free function), which traffic_simulator has access to via free functions from utils. Sample of the relationship between utils and lanelet_wrapper after changes: <HdMapUtils method name> to <utils namespace and function name> -> <lanelet_wrapper namespace and function name>.

Moved from HdMapUtils to lanelet_wrapper namespaces - used by lanelet_map and pose from utils:

  • getLaneletLength to lanelet_map::laneletLength -> lanelet_wrapper::lanelet_map::laneletLength

  • getLaneletAltitude to lanelet_map::laneletAltitude -> lanelet_wrapper::lanelet_map::laneletAltitude

  • getCenterPoints to lanelet_wrapper::lanelet_map::centerPoints - this has been copied, the original will be deleted soon

  • canonicalizeLaneletPose to pose::canonicalize() -> lanelet_wrapper::pose::canonicalizeLaneletPose

  • getAllCanonicalizedLaneletPoses to pose::alternativeLaneletPoses -> lanelet_wrapper::pose::alternativeLaneletPoses

  • getAlongLaneletPose to pose::alongLaneletPose -> lanelet_wrapper::pose::alongLaneletPose

  • getLeftLaneletIds to pose::leftLaneletIds -> lanelet_wrapper::pose::leftLaneletIds

  • getRightLaneletIds to pose::rightLaneletIds -> lanelet_wrapper::pose::rightLaneletIds

  • getNextLaneletIds to pose::nextLaneletIds -> lanelet_wrapper::pose::nextLaneletIds

  • getPreviousLaneletIds to pose::previousLaneletIds -> lanelet_wrapper::pose::previousLaneletIds

  • toMapPose to pose::toMapPose -> lanelet_wrapper::pose::toMapPose

  • matchToLane to pose::matchToLane -> lanelet_wrapper::pose::matchToLane

  • toLaneletPose to pose::toLaneletPose -> lanelet_wrapper::pose::toLaneletPose

  • toLaneletPoses to pose::toLaneletPoses -> lanelet_wrapper::pose::toLaneletPoses

  • isAltitudeMatching to pose::isAltitudeMatching -> lanelet_wrapper::pose::isAltitudeMatching

Thanks to this, the passing of HdMapUtils ptr has been removed from functions:

  • CanonicalizedEntityStatus::set
  • pose::canonicalize
  • pose::toCanonicalizedLaneletPose
  • pose::toMapPose
  • pose::pedestrian::transformToCanonicalizedLaneletPose
  • CanonicalizedLaneletPose contructor
  • helper::constructCanonicalizedLaneletPose
  • helper::constructLaneletPose

In addition:

  • Adapted:
    • test_hdmap_utils - to use functions from lanelet_wrapper - in the next PRs this file will be broken down so that tests for each sub-namespace of lanelet_wrapper will be separated file.
    • helper_functions and other files from the test/* folder to lanelet_wrapper.
    • Returned type and the definition of pose::canonicalize() - now it returns LaneletPose and throws an exception - which is in harmony with the name and expectations. Whenever CanonicalizedLaneletPose is needed, the pose::toCanonicalizedLaneletPose() function is used. In addition, there is no longer a CanonicalizedLaneletPose::canonicalize() method - common pose::canonicalize is used there.
    • Configuration constructor and its use in cpp_scenario_node and openscenario_interpreter.
  • Fixed
    • Distance along lanelet calculation in follow_trajectory_action - previously the orientation was not taken into account leading to failures in some scenarios,
  • Simplified:
  • Added:
    • math::geometry::convertDirectionToQuaternion - i.e. an assistant function to convert a direction vector into an orientation in a quaternion
    • CanonicalizedLaneletPose::getAltitude()
    • CanonicalizedLaneletPose::getLaneletId()
    • CanonicalziedLaneletPose::alignOrientationtoLanelet()
    • pose::isInLanelet -> lanelet_wrapper::pose::isInLanelet - with argument type of geometry_msgs::msg::Point

References

Internal Jira Link

Destructive Changes

None

Known Limitations

None

Copy link

github-actions bot commented Dec 3, 2024

Checklist for reviewers ☑️

All references to "You" in the following text refer to the code reviewer.

  • Is this pull request written in a way that is easy to read from a third-party perspective?
  • Is there sufficient information (background, purpose, specification, algorithm description, list of disruptive changes, and migration guide) in the description of this pull request?
  • If this pull request contains a destructive change, does this pull request contain the migration guide?
  • Labels of this pull request are valid?
  • All unit tests/integration tests are included in this pull request? If you think adding test cases is unnecessary, please describe why and cross out this line.
  • The documentation for this pull request is enough? If you think adding documents for this pull request is unnecessary, please describe why and cross out this line.

@dmoszynski dmoszynski added wait for regression test refactor bump minor If this pull request merged, bump minor version of the scenario_simulator_v2 labels Dec 4, 2024
@dmoszynski dmoszynski changed the title ref(traffic_simulator, behavior_tree_plugin): hdmap_utils refactor - create lanelet_wrapper, use ::lanelet_map and ::pose HdMapUtils refactor (PR 1/X) - create lanelet_wrapper: use lanelet_map:: and pose:: Dec 5, 2024
@dmoszynski dmoszynski changed the title HdMapUtils refactor (PR 1/X) - create lanelet_wrapper: use lanelet_map:: and pose:: HdMapUtils refactor (PR 1/X) - create lanelet_wrapper: use ::lanelet_map and ::pose Dec 5, 2024
@dmoszynski dmoszynski force-pushed the ref/RJD-1387-hdmap-utils-to-lanelet-wrapper-pose branch from 768b84e to 8fa1f2b Compare December 10, 2024 15:01
@dmoszynski dmoszynski self-assigned this Dec 10, 2024
@dmoszynski dmoszynski changed the title HdMapUtils refactor (PR 1/X) - create lanelet_wrapper: use ::lanelet_map and ::pose HdMapUtils refactor (PR 1/6) - create lanelet_wrapper: use ::lanelet_map and ::pose Dec 11, 2024
@dmoszynski dmoszynski marked this pull request as ready for review January 8, 2025 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bump minor If this pull request merged, bump minor version of the scenario_simulator_v2 refactor wait for regression test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant