Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
4624a23
feat(traffic_simulator): expand lanelet_wrapper: add ::distance and n…
dmoszynski Dec 5, 2024
a83b14d
feat(traffic_simulator, behavior_tree_plugin, openscenario_intepreter…
dmoszynski Dec 5, 2024
5921ecf
feat(traffic_simulator): adapt test for lanelet_wrapper
dmoszynski Dec 5, 2024
91f6ad3
reftraffic_simulator): use lanelet_wrapper in hdmap_utils, remove sep…
dmoszynski Dec 5, 2024
4b3a45c
ref(traffic_simulator): little lanelet_wrapper refactor
dmoszynski Dec 5, 2024
b418a3a
ref(clang): revert undesired changes
dmoszynski Dec 5, 2024
44d4896
Trigger CI pipeline
dmoszynski Dec 9, 2024
c447c53
Merge branch 'ref/RJD-1387-hdmap-utils-to-lanelet-wrapper-pose' into …
dmoszynski Dec 9, 2024
24cb803
Merge branch 'ref/RJD-1387-hdmap-utils-to-lanelet-wrapper-pose' into …
dmoszynski Dec 9, 2024
2f5132e
Merge branch 'ref/RJD-1387-hdmap-utils-to-lanelet-wrapper-pose' into …
dmoszynski Dec 10, 2024
768b84e
ref(traffic_simulator): improve hdmaputils::countLaneChanges
dmoszynski Dec 10, 2024
c33adff
Merge remote-tracking branch 'origin/ref/RJD-1387-hdmap-utils-to-lane…
dmoszynski Dec 10, 2024
fa0acce
Merge remote-tracking branch 'origin/ref/RJD-1387-hdmap-utils-to-lane…
dmoszynski Dec 10, 2024
ab01032
Merge branch 'ref/RJD-1387-hdmap-utils-to-lanelet-wrapper-pose' into …
dmoszynski Dec 11, 2024
318cfcf
Merge remote-tracking branch 'origin/ref/RJD-1387-hdmap-utils-to-lane…
dmoszynski Dec 18, 2024
0394908
fix(traffic_simulator): fix after merge
dmoszynski Dec 18, 2024
1539dd9
Merge branch 'ref/RJD-1387-hdmap-utils-to-lanelet-wrapper-pose' into …
dmoszynski Jan 7, 2025
9b0b06e
Merge remote-tracking branch 'origin/ref/RJD-1387-hdmap-utils-to-lane…
TauTheLepton Jan 7, 2025
e7896f4
Merge remote-tracking branch 'origin/ref/RJD-1387-hdmap-utils-to-lane…
TauTheLepton Jan 15, 2025
bb85f13
Merge branch 'ref/RJD-1387-hdmap-utils-to-lanelet-wrapper-pose' into …
dmoszynski Jan 21, 2025
be5cac9
Merge branch 'ref/RJD-1387-hdmap-utils-to-lanelet-wrapper-pose' into …
TauTheLepton Jan 22, 2025
90b3446
Utilize other overloads and add named constexpr parameters
TauTheLepton Jan 22, 2025
f3b3782
Use vector instead of set when many values are inserted and search is…
TauTheLepton Jan 22, 2025
a642982
Merge branch 'ref/RJD-1387-hdmap-utils-to-lanelet-wrapper-pose' into …
TauTheLepton Jan 23, 2025
f80a5f4
Code improvement: change `emplace_back` to `push_back` where emplacin…
TauTheLepton Jan 23, 2025
ff3ed61
Code improvement: add const reference wherever applicable and reserve…
TauTheLepton Jan 23, 2025
cd884fb
Code improvement: avoid unnecessary storage of data and computational…
TauTheLepton Jan 23, 2025
ee60f4c
Code improvement: add missing check in one overload of function `lane…
TauTheLepton Jan 23, 2025
56dfddd
Code improvement(lanelet_wrapper::traffic_lights): minor improvements
TauTheLepton Jan 23, 2025
3b32dcd
Code improvement(lanelet_wrapper::traffic_lights): avoid adding the s…
TauTheLepton Jan 23, 2025
f235ada
Code improvement(lanelet_wrapper::traffic_lights): add const ref to l…
TauTheLepton Jan 23, 2025
03ba3ce
Sort before std::unique, so that all duplicates are removed correctly
TauTheLepton Jan 29, 2025
e21760c
Return const ref to a vector from `CenterPointsCache::centerPoints` a…
TauTheLepton Jan 29, 2025
d28d911
Trigger CI
TauTheLepton Jan 29, 2025
c803a87
Fix typo
TauTheLepton Jan 29, 2025
5d76858
Merge branch 'ref/RJD-1387-hdmap-utils-to-lanelet-wrapper-distance-st…
TauTheLepton Jan 29, 2025
dd67e63
Merge remote-tracking branch 'tier4/master' into ref/RJD-1387-hdmap-u…
TauTheLepton Jan 30, 2025
952c87a
Merge branch 'master' into ref/RJD-1387-hdmap-utils-to-lanelet-wrappe…
TauTheLepton Jan 31, 2025
73189e9
Revert "Sort before std::unique, so that all duplicates are removed c…
TauTheLepton Jan 31, 2025
7321812
Add note with the intention
TauTheLepton Jan 31, 2025
c4bc79e
Change copyright date to 2015
TauTheLepton Feb 3, 2025
a22057b
Implement Sonar suggestions
TauTheLepton Feb 3, 2025
1d2453b
Code improvement: avoid unnecessary storage of data in some distance …
TauTheLepton Feb 3, 2025
2c3430e
Merge remote-tracking branch 'tier4/master' into ref/RJD-1387-hdmap-u…
TauTheLepton Feb 4, 2025
92f2cf2
Merge remote-tracking branch 'tier4/master' into ref/RJD-1387-hdmap-u…
TauTheLepton Feb 5, 2025
a7e12f3
Trigger SonarCloud
TauTheLepton Feb 5, 2025
dfced8b
Merge branch 'master' into ref/RJD-1387-hdmap-utils-to-lanelet-wrappe…
TauTheLepton Feb 6, 2025
f4c8343
Merge remote-tracking branch 'tier4/master' into ref/RJD-1387-hdmap-u…
TauTheLepton Feb 11, 2025
78b6dd1
Merge branch 'master' into ref/RJD-1387-hdmap-utils-to-lanelet-wrappe…
TauTheLepton Feb 12, 2025
95be978
Merge branch 'master' into ref/RJD-1387-hdmap-utils-to-lanelet-wrappe…
TauTheLepton Feb 13, 2025
03553ad
Merge branch 'master' into ref/RJD-1387-hdmap-utils-to-lanelet-wrappe…
yamacir-kit Feb 17, 2025
e17a8ed
Merge branch 'master' into ref/RJD-1387-hdmap-utils-to-lanelet-wrappe…
TauTheLepton Feb 18, 2025
86e2876
Merge remote-tracking branch 'tier4/master' into ref/RJD-1387-hdmap-u…
TauTheLepton Feb 20, 2025
1716b33
Merge tag '12.0.2' into ref/RJD-1387-hdmap-utils-to-lanelet-wrapper-d…
robomic Mar 4, 2025
848adf0
Merge branch 'master' into ref/RJD-1387-hdmap-utils-to-lanelet-wrappe…
robomic Mar 5, 2025
bdfebae
Merge branch 'master' into ref/RJD-1387-hdmap-utils-to-lanelet-wrappe…
TauTheLepton Mar 11, 2025
2b87378
Merge branch 'master' into ref/RJD-1387-hdmap-utils-to-lanelet-wrappe…
TauTheLepton Mar 12, 2025
12e3ef0
Merge branch 'master' into ref/RJD-1387-hdmap-utils-to-lanelet-wrappe…
TauTheLepton Mar 13, 2025
a315f0c
Merge remote-tracking branch 'tier4/master' into ref/RJD-1387-hdmap-u…
TauTheLepton Mar 25, 2025
6ee4bd2
Merge branch 'master' into ref/RJD-1387-hdmap-utils-to-lanelet-wrappe…
TauTheLepton Mar 26, 2025
94e0c9e
Merge branch 'master' into ref/RJD-1387-hdmap-utils-to-lanelet-wrappe…
TauTheLepton Mar 27, 2025
5dfa5ed
Merge branch 'master' into ref/RJD-1387-hdmap-utils-to-lanelet-wrappe…
dmoszynski Mar 31, 2025
9a2fae2
Merge remote-tracking branch 'tier4/master' into ref/RJD-1387-hdmap-u…
TauTheLepton Apr 1, 2025
38841d0
Merge branch 'master' into ref/RJD-1387-hdmap-utils-to-lanelet-wrappe…
TauTheLepton Apr 2, 2025
8ebf396
Merge branch 'master' into ref/RJD-1387-hdmap-utils-to-lanelet-wrappe…
TauTheLepton Apr 8, 2025
fc97569
Merge branch 'master' into ref/RJD-1387-hdmap-utils-to-lanelet-wrappe…
TauTheLepton Apr 9, 2025
33f7c71
Merge branch 'master' into ref/RJD-1387-hdmap-utils-to-lanelet-wrappe…
TauTheLepton Apr 10, 2025
25f0608
Merge branch 'master' into ref/RJD-1387-hdmap-utils-to-lanelet-wrappe…
TauTheLepton Apr 15, 2025
205ea86
Merge branch 'master' into ref/RJD-1387-hdmap-utils-to-lanelet-wrappe…
TauTheLepton Apr 16, 2025
f378bcb
Merge branch 'master' into ref/RJD-1387-hdmap-utils-to-lanelet-wrappe…
TauTheLepton Apr 16, 2025
773a380
Merge branch 'master' into ref/RJD-1387-hdmap-utils-to-lanelet-wrappe…
hakuturu583 Apr 17, 2025
dabd46d
Merge branch 'master' into ref/RJD-1387-hdmap-utils-to-lanelet-wrappe…
TauTheLepton Apr 22, 2025
0067dba
Merge branch 'master' into ref/RJD-1387-hdmap-utils-to-lanelet-wrappe…
TauTheLepton Apr 23, 2025
718de3a
Merge branch 'master' into ref/RJD-1387-hdmap-utils-to-lanelet-wrappe…
TauTheLepton Apr 24, 2025
cb63448
Merge remote-tracking branch 'tier4/master' into ref/RJD-1387-hdmap-u…
TauTheLepton Apr 29, 2025
bb4d8c2
Merge branch 'master' into ref/RJD-1387-hdmap-utils-to-lanelet-wrappe…
TauTheLepton May 6, 2025
4cda1aa
Add comment why include_opposite_direction was changed
TauTheLepton May 8, 2025
7942d31
Merge branch 'master' into ref/RJD-1387-hdmap-utils-to-lanelet-wrappe…
TauTheLepton May 12, 2025
c9e669f
Merge branch 'master' into ref/RJD-1387-hdmap-utils-to-lanelet-wrappe…
hakuturu583 May 13, 2025
327be86
Merge branch 'master' into ref/RJD-1387-hdmap-utils-to-lanelet-wrappe…
TauTheLepton May 14, 2025
34298a3
Merge branch 'master' into ref/RJD-1387-hdmap-utils-to-lanelet-wrappe…
TauTheLepton May 15, 2025
49af9d2
Merge branch 'master' into ref/RJD-1387-hdmap-utils-to-lanelet-wrappe…
TauTheLepton May 20, 2025
807a7f3
Merge remote-tracking branch 'tier4/master' into ref/RJD-1387-hdmap-u…
TauTheLepton May 27, 2025
6c86722
Merge branch 'master' into ref/RJD-1387-hdmap-utils-to-lanelet-wrappe…
TauTheLepton May 28, 2025
6019f80
Merge branch 'master' into ref/RJD-1387-hdmap-utils-to-lanelet-wrappe…
TauTheLepton Jun 3, 2025
44e7b56
Merge branch 'master' into ref/RJD-1387-hdmap-utils-to-lanelet-wrappe…
TauTheLepton Jun 3, 2025
48f45ca
Merge branch 'master' into ref/RJD-1387-hdmap-utils-to-lanelet-wrappe…
HansRobo Jun 4, 2025
dcd8bb8
Merge branch 'master' into ref/RJD-1387-hdmap-utils-to-lanelet-wrappe…
TauTheLepton Jun 9, 2025
7422ff9
Merge branch 'master' into ref/RJD-1387-hdmap-utils-to-lanelet-wrappe…
TauTheLepton Jun 11, 2025
445825e
Merge branch 'master' into ref/RJD-1387-hdmap-utils-to-lanelet-wrappe…
TauTheLepton Jun 16, 2025
8358905
Merge branch 'master' into ref/RJD-1387-hdmap-utils-to-lanelet-wrappe…
TauTheLepton Jun 18, 2025
ffa91bb
Merge branch 'master' into ref/RJD-1387-hdmap-utils-to-lanelet-wrappe…
TauTheLepton Jun 23, 2025
2f60ae4
Merge branch 'master' into ref/RJD-1387-hdmap-utils-to-lanelet-wrappe…
TauTheLepton Jun 26, 2025
8c917e8
Merge branch 'master' into ref/RJD-1387-hdmap-utils-to-lanelet-wrappe…
TauTheLepton Jul 2, 2025
47fcda0
Merge branch 'master' into ref/RJD-1387-hdmap-utils-to-lanelet-wrappe…
TauTheLepton Jul 7, 2025
2d28d67
Merge branch 'master' into ref/RJD-1387-hdmap-utils-to-lanelet-wrappe…
TauTheLepton Jul 9, 2025
0e1ba60
Merge branch 'master' into ref/RJD-1387-hdmap-utils-to-lanelet-wrappe…
TauTheLepton Jul 15, 2025
13b5ad4
Merge branch 'master' into ref/RJD-1387-hdmap-utils-to-lanelet-wrappe…
TauTheLepton Jul 23, 2025
d06d5f7
Merge branch 'master' into ref/RJD-1387-hdmap-utils-to-lanelet-wrappe…
TauTheLepton Jul 29, 2025
26b626f
Merge remote-tracking branch 'tier4/master' into ref/RJD-1387-hdmap-u…
TauTheLepton Aug 6, 2025
7102aa0
Merge branch 'master' into ref/RJD-1387-hdmap-utils-to-lanelet-wrappe…
hakuturu583 Aug 7, 2025
2c78c45
Merge branch 'master' into ref/RJD-1387-hdmap-utils-to-lanelet-wrappe…
hakuturu583 Aug 7, 2025
8442eed
Merge branch 'master' into ref/RJD-1387-hdmap-utils-to-lanelet-wrappe…
hakuturu583 Sep 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ class ActionNode : public BT::ActionNodeBase
auto getYieldStopDistance(const lanelet::Ids & following_lanelets) const -> std::optional<double>;
auto stopEntity() const -> void;
auto getHorizon() const -> double;
auto getOtherEntitiesCanonicalizedLaneletPoses() const
-> std::vector<traffic_simulator::CanonicalizedLaneletPose>;

/// throws if the derived class return RUNNING.
auto executeTick() -> BT::NodeStatus override;
Expand Down
69 changes: 27 additions & 42 deletions simulation/behavior_tree_plugin/src/action_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,18 @@ auto ActionNode::getBlackBoardValues() -> void
}
}

auto ActionNode::getOtherEntitiesCanonicalizedLaneletPoses() const
-> std::vector<traffic_simulator::CanonicalizedLaneletPose>
{
std::vector<traffic_simulator::CanonicalizedLaneletPose> other_canonicalized_lanelet_poses;
for (const auto & [name, status] : other_entity_status_) {
if (auto const & canonicalized_lanelet_pose = status.getCanonicalizedLaneletPose()) {
other_canonicalized_lanelet_poses.push_back(canonicalized_lanelet_pose.value());
}
}
return other_canonicalized_lanelet_poses;
}

auto ActionNode::getHorizon() const -> double
{
return std::clamp(canonicalized_entity_status_->getTwist().linear.x * 5.0, 20.0, 50.0);
Expand All @@ -133,43 +145,16 @@ auto ActionNode::setCanonicalizedEntityStatus(const traffic_simulator::EntitySta
entity_status, default_matching_distance_for_lanelet_pose_calculation_);
}

auto ActionNode::getOtherEntityStatus(lanelet::Id lanelet_id) const
-> std::vector<traffic_simulator::CanonicalizedEntityStatus>
{
std::vector<traffic_simulator::CanonicalizedEntityStatus> ret;
for (const auto & [name, status] : other_entity_status_) {
if (status.isInLanelet() && traffic_simulator::isSameLaneletId(status, lanelet_id)) {
ret.emplace_back(status);
}
}
return ret;
}

auto ActionNode::getYieldStopDistance(const lanelet::Ids & following_lanelets) const
-> std::optional<double>
{
std::set<double> distances;
for (const auto & lanelet : following_lanelets) {
const auto right_of_way_ids = hdmap_utils_->getRightOfWayLaneletIds(lanelet);
for (const auto right_of_way_id : right_of_way_ids) {
const auto other_status = getOtherEntityStatus(right_of_way_id);
if (!other_status.empty() && canonicalized_entity_status_->isInLanelet()) {
const auto lanelet_pose = canonicalized_entity_status_->getLaneletPose();
const auto distance_forward =
traffic_simulator::lanelet_wrapper::distance::longitudinalDistance(
lanelet_pose, traffic_simulator::helper::constructLaneletPose(lanelet, 0));
const auto distance_backward =
traffic_simulator::lanelet_wrapper::distance::longitudinalDistance(
traffic_simulator::helper::constructLaneletPose(lanelet, 0), lanelet_pose);
if (distance_forward) {
distances.insert(distance_forward.value());
} else if (distance_backward) {
distances.insert(-distance_backward.value());
}
}
}
if (distances.size() != 0) {
return *distances.begin();
if (
const auto canonicalized_lanelet_pose =
canonicalized_entity_status_->getCanonicalizedLaneletPose()) {
if (const auto other_canonicalized_lanelet_poses = getOtherEntitiesCanonicalizedLaneletPoses();
!other_canonicalized_lanelet_poses.empty()) {
traffic_simulator::distance::distanceToYieldStop(
canonicalized_lanelet_pose.value(), following_lanelets, other_canonicalized_lanelet_poses);
}
}
return std::nullopt;
Expand Down Expand Up @@ -235,7 +220,7 @@ auto ActionNode::getDistanceToTrafficLightStopLine(
if (traffic_lights_->isRequiredStopTrafficLightState(traffic_light_id)) {
if (
const auto collision_point =
hdmap_utils_->getDistanceToTrafficLightStopLine(spline, traffic_light_id)) {
traffic_simulator::distance::distanceToTrafficLightStopLine(spline, traffic_light_id)) {
collision_points.insert(collision_point.value());
}
}
Expand Down Expand Up @@ -331,17 +316,17 @@ auto ActionNode::getEntityStatus(const std::string & target_name) const

/**
* @note getDistanceToTargetEntity working schematics
*
* 1. Check if route to target entity from reference entity exists, if not try to transform pose to other
*
* 1. Check if route to target entity from reference entity exists, if not try to transform pose to other
* routable lanelet, within matching distance (findRoutableAlternativeLaneletPoseFrom).
* 2. Calculate longitudinal distance between entities bounding boxes -> bounding_box_distance.
* 3. Calculate longitudinal distance between entities poses -> longitudinal_distance.
* 4. Calculate target entity bounding box distance to reference entity spline (minimal distance from all corners)
* 4. Calculate target entity bounding box distance to reference entity spline (minimal distance from all corners)
* -> target_to_spline_distance.
* 5. If target_to_spline_distance is less than half width of reference entity target entity is conflicting.
* 6. Check corner case where target entity width is bigger than width of entity and target entity
* is exactly on the spline -> spline.getCollisionPointIn2D
* 7. If target entity is conflicting return bounding_box_distance enlarged by half of the entity
* 7. If target entity is conflicting return bounding_box_distance enlarged by half of the entity
* length.
*/
auto ActionNode::getDistanceToTargetEntity(
Expand All @@ -353,9 +338,9 @@ auto ActionNode::getDistanceToTargetEntity(
!isOtherEntityAtConsideredAltitude(status)) {
return std::nullopt;
}
/**
* boundingBoxLaneLongitudinalDistance requires routing_configuration,
* 'allow_lane_change = true' is needed to check distances to entities on neighbour lanelets
/**
* boundingBoxLaneLongitudinalDistance requires routing_configuration,
* 'allow_lane_change = true' is needed to check distances to entities on neighbour lanelets
*/
traffic_simulator::RoutingConfiguration routing_configuration;
routing_configuration.allow_lane_change = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,22 +106,6 @@ class HdMapUtils
traffic_simulator::RoutingConfiguration().routing_graph_type) const
-> lanelet::Ids;

auto getDistanceToTrafficLightStopLine(
const lanelet::Ids & route_lanelets,
const math::geometry::CatmullRomSplineInterface & spline) const -> std::optional<double>;

auto getDistanceToTrafficLightStopLine(
const lanelet::Ids & route_lanelets,
const std::vector<geometry_msgs::msg::Point> & waypoints) const -> std::optional<double>;

auto getDistanceToTrafficLightStopLine(
const math::geometry::CatmullRomSplineInterface & spline,
const lanelet::Id traffic_light_id) const -> std::optional<double>;

auto getDistanceToTrafficLightStopLine(
const std::vector<geometry_msgs::msg::Point> & waypoints,
const lanelet::Id traffic_light_id) const -> std::optional<double>;

auto getFollowingLanelets(
const lanelet::Id current_lanelet_id, const lanelet::Ids & route, const double horizon = 100,
const bool include_current_lanelet_id = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,30 @@ auto distanceToStopLine(

auto distanceToStopLine(const std::vector<Point> & route_waypoints, const lanelet::Id stop_line_id)
-> std::optional<double>;

// TrafficLightStopLine
auto distanceToTrafficLightStopLine(
const SplineInterface & route_spline, const lanelet::Id traffic_light_id)
-> std::optional<double>;

auto distanceToTrafficLightStopLine(
const std::vector<Point> & route_waypoints, const lanelet::Id traffic_light_id)
-> std::optional<double>;

auto distanceToTrafficLightStopLine(
const lanelet::Ids & route_lanelets, const SplineInterface & route_spline)
-> std::optional<double>;

auto distanceToTrafficLightStopLine(
const lanelet::Ids & route_lanelets, const std::vector<Point> & route_waypoints)
-> std::optional<double>;

// Crosswalk
auto distanceToCrosswalk(const std::vector<Point> & route_waypoints, const lanelet::Id crosswalk_id)
-> std::optional<double>;

auto distanceToCrosswalk(const SplineInterface & route_spline, const lanelet::Id crosswalk_id)
-> std::optional<double>;
} // namespace distance
} // namespace lanelet_wrapper
} // namespace traffic_simulator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ namespace lanelet_wrapper
{
namespace lanelet_map
{
// Basics
auto isInLanelet(const lanelet::Id lanelet_id, const double lanelet_pose_s) -> bool;

auto isInLanelet(const lanelet::Id lanelet_id, const Point point) -> bool;
Expand All @@ -52,12 +53,14 @@ auto nearbyLaneletIds(
const Point & point, const double distance_threshold, const bool include_crosswalk,
const std::size_t search_count) -> lanelet::Ids;

// Center points
auto centerPoints(const lanelet::Ids & lanelet_ids) -> std::vector<Point>;

auto centerPoints(const lanelet::Id lanelet_id) -> std::vector<Point>;

auto centerPointsSpline(const lanelet::Id lanelet_id) -> std::shared_ptr<Spline>;

// Next lanelet
auto nextLaneletIds(
const lanelet::Id lanelet_id,
const RoutingGraphType type = RoutingConfiguration().routing_graph_type) -> lanelet::Ids;
Expand All @@ -74,6 +77,7 @@ auto nextLaneletIds(
const lanelet::Ids & lanelet_ids, std::string_view turn_direction,
const RoutingGraphType type = RoutingConfiguration().routing_graph_type) -> lanelet::Ids;

// Previous lanelet
auto previousLaneletIds(
const lanelet::Id lanelet_id,
const RoutingGraphType type = RoutingConfiguration().routing_graph_type) -> lanelet::Ids;
Expand All @@ -96,10 +100,18 @@ auto leftBound(const lanelet::Id lanelet_id) -> std::vector<Point>;
auto rightBound(const lanelet::Id lanelet_id) -> std::vector<Point>;

// Polygons
auto laneletPolygon(const lanelet::Id lanelet_id) -> std::vector<Point>;

auto stopLinePolygon(const lanelet::Id lanelet_id) -> std::vector<Point>;

auto toPolygon(const lanelet::ConstLineString3d & line_string) -> std::vector<Point>;

// Relations
auto rightOfWayLaneletIds(const lanelet::Ids & lanelet_ids)
-> std::unordered_map<lanelet::Id, lanelet::Ids>;

auto rightOfWayLaneletIds(const lanelet::Id lanelet_id) -> lanelet::Ids;

// Objects on path
auto trafficSignsOnPath(const lanelet::Ids & lanelet_ids)
-> std::vector<std::shared_ptr<const lanelet::TrafficSign>>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ using Point = geometry_msgs::msg::Point;
using Pose = geometry_msgs::msg::Pose;
using PoseStamped = geometry_msgs::msg::PoseStamped;
using Spline = math::geometry::CatmullRomSpline;
using SplineInterface = math::geometry::CatmullRomSplineInterface;
using Vector3 = geometry_msgs::msg::Vector3;
using SplineInterface = math::geometry::CatmullRomSplineInterface;

Expand Down Expand Up @@ -159,7 +160,7 @@ class CenterPointsCache
}

auto getCenterPoints(const lanelet::Id lanelet_id, const lanelet::LaneletMapPtr & lanelet_map)
-> std::vector<Point>
-> decltype(auto)
{
if (!exists(lanelet_id)) {
appendData(lanelet_id, centerPoints(lanelet_id, lanelet_map));
Expand All @@ -168,8 +169,7 @@ class CenterPointsCache
}

auto getCenterPointsSpline(
const lanelet::Id lanelet_id, const lanelet::LaneletMapPtr & lanelet_map)
-> std::shared_ptr<Spline>
const lanelet::Id lanelet_id, const lanelet::LaneletMapPtr & lanelet_map) -> decltype(auto)
{
if (!exists(lanelet_id)) {
appendData(lanelet_id, centerPoints(lanelet_id, lanelet_map));
Expand All @@ -184,7 +184,7 @@ class CenterPointsCache
return data_.find(lanelet_id) != data_.end();
}

auto readData(const lanelet::Id lanelet_id) -> std::vector<Point>
auto readData(const lanelet::Id lanelet_id) -> const std::vector<Point> &
{
std::lock_guard lock(mutex_);
return data_.at(lanelet_id);
Expand Down Expand Up @@ -233,7 +233,7 @@ class CenterPointsCache
class LaneletLengthCache
{
public:
auto getLength(lanelet::Id lanelet_id)
auto getLength(lanelet::Id lanelet_id) -> double
{
if (!exists(lanelet_id)) {
THROW_SIMULATION_ERROR("length of : ", lanelet_id, " does not exists on route cache.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
#define TRAFFIC_SIMULATOR__UTILS__DISTANCE_HPP_

#include <geometry/spline/catmull_rom_spline_interface.hpp>
#include <traffic_simulator/data_type/entity_status.hpp>
#include <traffic_simulator/data_type/lanelet_pose.hpp>
#include <traffic_simulator/lanelet_wrapper/distance.hpp>
#include <traffic_simulator_msgs/msg/bounding_box.hpp>
#include <traffic_simulator_msgs/msg/waypoints_array.hpp>

namespace traffic_simulator
Expand Down Expand Up @@ -106,17 +108,29 @@ auto distanceToRightLaneBound(
-> double;

// Other objects
auto distanceToCrosswalk(
const traffic_simulator_msgs::msg::WaypointsArray & waypoints_array,
const lanelet::Id target_crosswalk_id,
const std::shared_ptr<hdmap_utils::HdMapUtils> & hdmap_utils_ptr) -> std::optional<double>;

template <typename... Ts>
auto distanceToStopLine(Ts &&... xs)
{
return lanelet_wrapper::distance::distanceToStopLine(std::forward<decltype(xs)>(xs)...);
}

template <typename... Ts>
auto distanceToTrafficLightStopLine(Ts &&... xs)
{
return lanelet_wrapper::distance::distanceToTrafficLightStopLine(
std::forward<decltype(xs)>(xs)...);
}

template <typename... Ts>
auto distanceToCrosswalk(Ts &&... xs)
{
return lanelet_wrapper::distance::distanceToCrosswalk(std::forward<decltype(xs)>(xs)...);
}

auto distanceToYieldStop(
const CanonicalizedLaneletPose & reference_pose, const lanelet::Ids & following_lanelets,
const std::vector<CanonicalizedLaneletPose> & other_poses) -> std::optional<double>;

// spline
auto distanceToSpline(
const geometry_msgs::msg::Pose & map_pose,
Expand Down
28 changes: 7 additions & 21 deletions simulation/traffic_simulator/src/behavior/follow_trajectory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ auto makeUpdatedStatus(
using geometry_msgs::msg::Pose;
using geometry_msgs::msg::Vector3;

const RoutingConfiguration routing_configuration{allow_lane_change};

const auto quaternion = convertDirectionToQuaternion(
geometry_msgs::build<Vector3>().x(to.x - from.x).y(to.y - from.y).z(to.z - from.z));
const auto from_pose = geometry_msgs::build<Pose>().position(from).orientation(quaternion);
Expand All @@ -94,24 +92,12 @@ auto makeUpdatedStatus(
if (
const auto to_canonicalized_lanelet_pose = pose::toCanonicalizedLaneletPose(
to_pose, entity_status.bounding_box, include_crosswalk, matching_distance)) {
if (const auto longitudinal_distance = distance::longitudinalDistance(
from_canonicalized_lanelet_pose.value(), to_canonicalized_lanelet_pose.value(),
include_adjacent_lanelet, include_opposite_direction, routing_configuration);
longitudinal_distance.has_value()
/**
* DIRTY HACK!
* Negative longitudinal distance (calculated along lanelet in opposite direction)
* causes some scenarios to fail because of an unrelated issue with lanelet matching.
* The issue is caused by wrongly matched lanelet poses and thus wrong distances.
* When lanelet matching errors are fixed, this dirty hack can be removed.
*/
and longitudinal_distance.value() >= 0.0) {
if (
const auto lateral_distance = distance::lateralDistance(
from_canonicalized_lanelet_pose.value(), to_canonicalized_lanelet_pose.value(),
routing_configuration)) {
return std::hypot(longitudinal_distance.value(), lateral_distance.value());
}
if (
const auto longitudinal_distance = distance::longitudinalDistance(
from_canonicalized_lanelet_pose.value(), to_canonicalized_lanelet_pose.value(),
include_adjacent_lanelet, include_opposite_direction,
RoutingConfiguration(allow_lane_change))) {
return longitudinal_distance.value();
}
}
}
Expand Down Expand Up @@ -588,7 +574,7 @@ auto makeUpdatedStatus(
return entity_status.pose.orientation;
} else {
/// @note if there is a designed_velocity vector, set the orientation in the direction of it
return math::geometry::convertDirectionToQuaternion(desired_velocity);
return convertDirectionToQuaternion(desired_velocity);
}
}();

Expand Down
Loading
Loading