scenario_simulator_v2 C++ API
lanelet_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__DATA_TYPE__LANELET_POSE_HPP_
16 #define TRAFFIC_SIMULATOR__DATA_TYPE__LANELET_POSE_HPP_
17 
19 
20 namespace traffic_simulator
21 {
23 
24 inline namespace lanelet_pose
25 {
27 {
28 public:
29  explicit CanonicalizedLaneletPose(
30  const LaneletPose & maybe_non_canonicalized_lanelet_pose,
31  const std::shared_ptr<hdmap_utils::HdMapUtils> & hdmap_utils);
32  explicit CanonicalizedLaneletPose(
33  const LaneletPose & maybe_non_canonicalized_lanelet_pose,
34  const std::shared_ptr<hdmap_utils::HdMapUtils> & hdmap_utils,
35  const lanelet::Ids & route_lanelets);
36  explicit operator LaneletPose() const noexcept { return lanelet_pose_; }
37  explicit operator geometry_msgs::msg::Pose() const noexcept { return map_pose_; }
38  bool hasAlternativeLaneletPose() const { return lanelet_poses_.size() > 1; }
40  LaneletPose from, const std::shared_ptr<hdmap_utils::HdMapUtils> & hdmap_utils,
41  bool allow_lane_change = false) const -> std::optional<LaneletPose>;
42 
48 #define DEFINE_COMPARISON_OPERATOR(OPERATOR) \
49  bool operator OPERATOR(const CanonicalizedLaneletPose & rhs) const \
50  { \
51  if ( \
52  static_cast<LaneletPose>(*this).lanelet_id == static_cast<LaneletPose>(rhs).lanelet_id && \
53  static_cast<LaneletPose>(*this).s OPERATOR static_cast<LaneletPose>(rhs).s) { \
54  return true; \
55  } \
56  return false; \
57  }
58 
63 #undef DEFINE_COMPARISON_OPERATOR
64 
65 private:
66  auto canonicalize(
67  const LaneletPose & may_non_canonicalized_lanelet_pose,
68  const std::shared_ptr<hdmap_utils::HdMapUtils> & hdmap_utils) -> LaneletPose;
69  auto canonicalize(
70  const LaneletPose & may_non_canonicalized_lanelet_pose,
71  const std::shared_ptr<hdmap_utils::HdMapUtils> & hdmap_utils,
72  const lanelet::Ids & route_lanelets) -> LaneletPose;
74  const std::vector<LaneletPose> lanelet_poses_;
75  const geometry_msgs::msg::Pose map_pose_;
76 };
77 } // namespace lanelet_pose
78 
80 bool isSameLaneletId(const CanonicalizedLaneletPose &, const lanelet::Id lanelet_id);
81 } // namespace traffic_simulator
82 
83 #endif // TRAFFIC_SIMULATOR__DATA_TYPE__LANELET_POSE_HPP_
Definition: lanelet_pose.hpp:27
const std::vector< LaneletPose > lanelet_poses_
Definition: lanelet_pose.hpp:74
auto canonicalize(const LaneletPose &may_non_canonicalized_lanelet_pose, const std::shared_ptr< hdmap_utils::HdMapUtils > &hdmap_utils, const lanelet::Ids &route_lanelets) -> LaneletPose
Definition: lanelet_pose.cpp:42
CanonicalizedLaneletPose(const LaneletPose &maybe_non_canonicalized_lanelet_pose, const std::shared_ptr< hdmap_utils::HdMapUtils > &hdmap_utils)
Definition: lanelet_pose.cpp:22
const LaneletPose lanelet_pose_
Definition: lanelet_pose.hpp:73
const geometry_msgs::msg::Pose map_pose_
Definition: lanelet_pose.hpp:75
bool hasAlternativeLaneletPose() const
Definition: lanelet_pose.hpp:38
DEFINE_COMPARISON_OPERATOR(<=) DEFINE_COMPARISON_OPERATOR(<) DEFINE_COMPARISON_OPERATOR(>
auto getAlternativeLaneletPoseBaseOnShortestRouteFrom(LaneletPose from, const std::shared_ptr< hdmap_utils::HdMapUtils > &hdmap_utils, bool allow_lane_change=false) const -> std::optional< LaneletPose >
Definition: lanelet_pose.cpp:83
Definition: cache.hpp:46
Definition: cache.hpp:27
Definition: api.hpp:48
bool isSameLaneletId(const CanonicalizedEntityStatus &, const CanonicalizedEntityStatus &)
Definition: entity_status.cpp:128
traffic_simulator_msgs::msg::LaneletPose LaneletPose
Definition: lanelet_pose.hpp:22