scenario_simulator_v2 C++ API
pose.hpp
Go to the documentation of this file.
1 // Copyright 2015 TIER IV, Inc. All rights reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef TRAFFIC_SIMULATOR__LANELET_WRAPPER_POSE_HPP_
16 #define TRAFFIC_SIMULATOR__LANELET_WRAPPER_POSE_HPP_
17 
18 #include <lanelet2_matching/LaneletMatching.h>
19 
21 
22 namespace traffic_simulator
23 {
24 namespace lanelet_wrapper
25 {
26 namespace pose
27 {
30 constexpr static double DEFAULT_MATCH_TO_LANE_REDUCTION_RATIO = 0.8;
31 
32 /*
33  Using a fixed `ALTITUDE_THRESHOLD` value of 1.0 [m] is justified because the
34  entity's Z-position is always relative to its base. This eliminates the
35  need to dynamically adjust the threshold based on the entity's dimensions,
36  ensuring consistent altitude matching regardless of the entity type.
37 
38  The position of the entity is defined relative to its base, typically
39  the center of the rear axle projected onto the ground in the case of vehicles.
40 
41  There is no technical basis for this value; it was determined based on
42  experiments.
43 */
44 constexpr static double ALTITUDE_THRESHOLD = 1.0;
45 
46 auto toMapPose(const LaneletPose & lanelet_pose, const bool fill_pitch = true) -> PoseStamped;
47 
48 auto isAltitudeWithinThreshold(const double current_altitude, const double target_altitude) -> bool;
49 
51  const double current_altitude, const double min_altitude, const double max_altitude) -> bool;
52 
53 auto toLaneletPose(
54  const Pose & map_pose, const lanelet::Id lanelet_id, const double matching_distance = 1.0)
55  -> std::optional<LaneletPose>;
56 
57 auto toLaneletPose(
58  const Pose & map_pose, const lanelet::Ids & lanelet_ids, const double matching_distance = 1.0)
59  -> std::optional<LaneletPose>;
60 
61 auto toLaneletPose(
62  const Pose & map_pose, const bool include_crosswalk, const double matching_distance = 1.0)
63  -> std::optional<LaneletPose>;
64 
65 auto toLaneletPose(
66  const Pose & map_pose, const BoundingBox & bounding_box, const bool include_crosswalk,
67  const double matching_distance = 1.0,
68  const RoutingGraphType type = RoutingConfiguration().routing_graph_type)
69  -> std::optional<LaneletPose>;
70 
71 auto toLaneletPoses(
72  const Pose & map_pose, const lanelet::Id lanelet_id, const double matching_distance = 5.0,
73  const bool include_opposite_direction = true,
74  const RoutingGraphType type = RoutingConfiguration().routing_graph_type)
75  -> std::vector<LaneletPose>;
76 
95 auto alternativeLaneletPoses(const LaneletPose & reference_lanelet_pose)
96  -> std::vector<LaneletPose>;
97 
98 auto alongLaneletPose(
99  const LaneletPose & from_pose, const lanelet::Ids & route_lanelets, const double distance)
100  -> LaneletPose;
101 
102 auto alongLaneletPose(
103  const LaneletPose & from_pose, const double distance,
104  const RoutingGraphType type = RoutingConfiguration().routing_graph_type) -> LaneletPose;
105 
106 auto canonicalizeLaneletPose(const LaneletPose & lanelet_pose)
107  -> std::tuple<std::optional<LaneletPose>, std::optional<lanelet::Id>>;
108 
109 auto canonicalizeLaneletPose(const LaneletPose & lanelet_pose, const lanelet::Ids & route_lanelets)
110  -> std::tuple<std::optional<LaneletPose>, std::optional<lanelet::Id>>;
111 
112 auto findMatchingLanes(
114  const bool include_crosswalk, const double matching_distance = 1.0,
115  const double reduction_ratio = DEFAULT_MATCH_TO_LANE_REDUCTION_RATIO,
117  traffic_simulator::RoutingConfiguration().routing_graph_type)
118  -> std::optional<std::set<std::pair<double, lanelet::Id>>>;
119 
120 auto matchToLane(
121  const Pose & map_pose, const BoundingBox & bounding_box, const bool include_crosswalk,
122  const double matching_distance = 1.0,
123  const double reduction_ratio = DEFAULT_MATCH_TO_LANE_REDUCTION_RATIO,
124  const RoutingGraphType type = RoutingConfiguration().routing_graph_type)
125  -> std::optional<lanelet::Id>;
126 
127 auto leftLaneletIds(
128  const lanelet::Id lanelet_id, const RoutingGraphType type, const bool include_opposite_direction)
129  -> lanelet::Ids;
130 
131 auto rightLaneletIds(
132  const lanelet::Id lanelet_id, const RoutingGraphType type, const bool include_opposite_direction)
133  -> lanelet::Ids;
134 } // namespace pose
135 } // namespace lanelet_wrapper
136 } // namespace traffic_simulator
137 #endif // TRAFFIC_SIMULATOR__LANELET_WRAPPER_POSE_HPP_
auto distance(const geometry_msgs::Pose &pose1, const geometry_msgs::Pose &pose2)
Definition: detection_sensor.cpp:45
auto isAltitudeWithinThreshold(const double current_altitude, const double target_altitude) -> bool
Definition: pose.cpp:69
auto canonicalizeLaneletPose(const LaneletPose &lanelet_pose) -> std::tuple< std::optional< LaneletPose >, std::optional< lanelet::Id >>
Canonicalizes a given LaneletPose by adjusting the longitudinal position (s) to ensure it lies within...
Definition: pose.cpp:343
auto isAltitudeWithinRange(const double current_altitude, const double min_altitude, const double max_altitude) -> bool
Definition: pose.cpp:74
auto toLaneletPose(const Pose &map_pose, const lanelet::Id lanelet_id, const double matching_distance=1.0) -> std::optional< LaneletPose >
Definition: pose.cpp:81
auto alongLaneletPose(const LaneletPose &from_pose, const lanelet::Ids &route_lanelets, const double distance) -> LaneletPose
Definition: pose.cpp:302
auto matchToLane(const Pose &map_pose, const BoundingBox &bounding_box, const bool include_crosswalk, const double matching_distance=1.0, const double reduction_ratio=DEFAULT_MATCH_TO_LANE_REDUCTION_RATIO, const RoutingGraphType type=RoutingConfiguration().routing_graph_type) -> std::optional< lanelet::Id >
Definition: pose.cpp:453
auto toLaneletPoses(const Pose &map_pose, const lanelet::Id lanelet_id, const double matching_distance=5.0, const bool include_opposite_direction=true, const RoutingGraphType type=RoutingConfiguration().routing_graph_type) -> std::vector< LaneletPose >
Definition: pose.cpp:184
auto findMatchingLanes(const geometry_msgs::msg::Pose &, const traffic_simulator_msgs::msg::BoundingBox &, const bool include_crosswalk, const double matching_distance=1.0, const double reduction_ratio=DEFAULT_MATCH_TO_LANE_REDUCTION_RATIO, const traffic_simulator::RoutingGraphType type=traffic_simulator::RoutingConfiguration().routing_graph_type) -> std::optional< std::set< std::pair< double, lanelet::Id >>>
Definition: pose.cpp:402
auto alternativeLaneletPoses(const LaneletPose &reference_lanelet_pose) -> std::vector< LaneletPose >
Retrieves alternative lanelet poses based on the reference lanelet pose.
Definition: pose.cpp:205
auto rightLaneletIds(const lanelet::Id lanelet_id, const RoutingGraphType type, const bool include_opposite_direction) -> lanelet::Ids
Definition: pose.cpp:486
auto leftLaneletIds(const lanelet::Id lanelet_id, const RoutingGraphType type, const bool include_opposite_direction) -> lanelet::Ids
Definition: pose.cpp:472
auto toMapPose(const LaneletPose &lanelet_pose, const bool fill_pitch=true) -> PoseStamped
Definition: pose.cpp:32
geometry_msgs::msg::Pose Pose
Definition: lanelet_wrapper.hpp:66
traffic_simulator_msgs::msg::BoundingBox BoundingBox
Definition: lanelet_wrapper.hpp:62
traffic_simulator_msgs::msg::LaneletPose LaneletPose
Definition: lanelet_wrapper.hpp:64
geometry_msgs::msg::PoseStamped PoseStamped
Definition: lanelet_wrapper.hpp:67
RoutingGraphType
Definition: routing_graph_type.hpp:24
Definition: api.hpp:32
Definition: routing_configuration.hpp:24