13#include <lanelet2_core/primitives/Lanelet.h>
14#include <lanelet2_routing/LaneletPath.h>
15#include <lanelet2_routing/RoutingGraph.h>
16#include <lanelet2_traffic_rules/TrafficRules.h>
18#include <geometry_msgs/msg/point.hpp>
19#include <geometry_msgs/msg/quaternion.hpp>
20#include <rclcpp/rclcpp.hpp>
21#include <route_planning_msgs/msg/route.hpp>
22#include <route_planning_msgs/msg/route_element.hpp>
30 route_planning_msgs::msg::Route
route;
41std::optional<lanelet::routing::Route>
getRoute(
const lanelet::routing::RoutingGraphUPtr& routing_graph,
42 const std::vector<lanelet::ConstLanelet>& route_lanelets);
54 size_t current_global_idx,
55 double distance_behind,
56 double distance_ahead);
70 const Eigen::Vector2d& point,
71 const bool consider_order =
false,
72 const bool behind =
true);
94 const Eigen::Vector2d& point,
95 const size_t idx_indication,
96 const bool consider_order =
false,
97 const bool behind =
true);
112 const Eigen::Vector2d& point,
113 const size_t idx_closest,
141 const lanelet::routing::RoutingGraphUPtr& routing_graph,
143 bool sort_from_left =
true);
167 const Eigen::Vector2d& point,
168 const Eigen::Vector2d& prev_point,
169 const Eigen::Vector2d& next_point,
170 const std::vector<lanelet::ConstLanelet>& lanelets,
171 const rclcpp::Logger& logger = rclcpp::get_logger(
"lanelet2_route_planning"));
193 const lanelet::ConstLanelet& lanelet_of_next_point,
194 const lanelet::routing::RoutingGraphUPtr& routing_graph);
209 const geometry_msgs::msg::Quaternion& orientation,
211 bool will_change_suggested_lane =
false,
212 uint8_t speed_limit = 0);
246std::pair<Eigen::Vector2d, Eigen::Vector2d>
extractDrivableSpace(
const lanelet::LineStringLayer& line_string_layer,
247 const PointSequence& point_sequence,
248 const double max_distance);
281 std::vector<route_planning_msgs::msg::RegulatoryElement>
284 std::vector<std::vector<uint8_t>>
286 std::vector<std::vector<uint8_t>>
305 const std::vector<lanelet::ConstLanelet>& adjacent_left_lanelets,
306 const std::vector<lanelet::ConstLanelet>& adjacent_right_lanelets,
319 const std::shared_ptr<const lanelet::RegulatoryElement>& regulatory_element);
331 const std::shared_ptr<const lanelet::RegulatoryElement>& regulatory_element);
342 const std::shared_ptr<const lanelet::RegulatoryElement>& regulatory_element);
354std::pair<uint8_t, uint8_t>
regulatoryElementType(
const std::shared_ptr<const lanelet::RegulatoryElement>& regulatory_element);
392uint8_t
speedLimit(
const lanelet::ConstLanelet& lanelet,
const bool consider_regulatory_elements =
true);
413uint8_t
speedLimit(
const lanelet::ConstLanelet& lanelet,
const Eigen::Vector2d& point);
425std::tuple<uint8_t, int>
suggestedTurnSignal(
const lanelet::ConstLanelet& lanelet,
const rclcpp::Logger& logger);
446 const Eigen::Vector2d& point,
447 const lanelet::LaneletMapConstPtr& map,
448 const std::optional<lanelet::traffic_rules::TrafficRulesPtr> traffic_rules = std::nullopt);
462 const lanelet::ConstLanelet& lanelet,
463 const Eigen::Vector2d& position,
464 const double distance);
483 const double delta_s,
515double estimateRemainingTime(
const route_planning_msgs::msg::Route& route,
const double reference_speed = 50.0 / 3.6);
528 route_planning_msgs::msg::Route& route_msg,
529 std::vector<std::vector<int>>& suggested_turn_signal_distance_ahead_by_route_element_by_lane_element);
544 std::vector<std::pair<double, lanelet::ConstLanelet>>& lanelets_with_distances,
545 const std::optional<lanelet::traffic_rules::TrafficRulesPtr>& traffic_rules = std::nullopt);
uint8_t laneBoundaryType(const lanelet::ConstLineString2d &line)
Extracts the lane boundary type of a lanelet line.
lanelet::ConstLanelet followLaneletsAlongRoutingGraph(const lanelet::routing::RoutingGraphUPtr &routing_graph, const lanelet::ConstLanelet &lanelet, const Eigen::Vector2d &position, const double distance)
Follows a lanelet's and following lanelets' centerline for a given distance.
double distanceTraveled(const route_planning_msgs::msg::Route &route)
Computes the traveled distance along the route.
lanelet::traffic_rules::TrafficRulesPtr getTrafficRules()
Get traffic rules.
bool changesLaneFromPointToPoint(const Eigen::Vector2d &point, const Eigen::Vector2d &next_point, const double sampling_distance)
Identifies a lane change based on the distance between two reference line points.
std::optional< lanelet::routing::Route > getRoute(const lanelet::routing::RoutingGraphUPtr &routing_graph, const std::vector< lanelet::ConstLanelet > &route_lanelets)
Computes a route from start to destination along intermediate destinations.
std::optional< std::array< geometry_msgs::msg::Point, 2 > > regulatoryElementReferenceLine(const std::shared_ptr< const lanelet::RegulatoryElement > ®ulatory_element)
Extracts the reference/effect line of a regulatory element.
std::vector< geometry_msgs::msg::Point > regulatoryElementPositions(const std::shared_ptr< const lanelet::RegulatoryElement > ®ulatory_element)
Extracts the sign/signal positions of a regulatory element.
bool isLineStringDrivable(const lanelet::ConstLineString3d &line_string)
Checks if lanelet line string has a type that is considered drivable.
size_t matchPointToLineString(const std::vector< Eigen::Vector2d > &line_string, const Eigen::Vector2d &point, const size_t idx_indication, const bool consider_order=false, const bool behind=true)
Finds the index of a point in a line string that is locally closest to another point.
LocalRouteWindow extractLocalRouteWindow(const route_planning_msgs::msg::Route &full_route, size_t current_global_idx, double distance_behind, double distance_ahead)
Extracts a local route window while preserving absolute route data.
ExtractRegulatoryElementsResult extractRegulatoryElements(const lanelet::ConstLanelet &lanelet, const std::vector< lanelet::ConstLanelet > &adjacent_left_lanelets, const std::vector< lanelet::ConstLanelet > &adjacent_right_lanelets, const PointSequence &point_sequence)
Extracts regulatory element information for a route element.
double estimateRemainingTime(const route_planning_msgs::msg::Route &route, const double reference_speed=50.0/3.6)
Estimate remaining time for a route based on speed limits.
route_planning_msgs::msg::RouteElement createMinimalRouteElement(const geometry_msgs::msg::Point &position, const geometry_msgs::msg::Quaternion &orientation, double s=0.0, bool will_change_suggested_lane=false, uint8_t speed_limit=0)
Create a minimal route element message.
uint8_t speedLimit(const lanelet::ConstLanelet &lanelet, const bool consider_regulatory_elements=true)
Extracts the speed limit of a lanelet.
std::optional< std::array< geometry_msgs::msg::Point, 2 > > regulatoryElementCancelLine(const std::shared_ptr< const lanelet::RegulatoryElement > ®ulatory_element)
Extracts the cancel line of a regulatory element.
std::optional< int > computeFollowingLaneIdxOffset(const lanelet::ConstLanelet &lanelet, const lanelet::ConstLanelet &lanelet_of_next_point, const lanelet::routing::RoutingGraphUPtr &routing_graph)
Computes the offset of lane element indices from current to next route element.
void sortLaneletsByMatchingCost(const lanelet::BasicPoint2d &point, std::vector< std::pair< double, lanelet::ConstLanelet > > &lanelets_with_distances, const std::optional< lanelet::traffic_rules::TrafficRulesPtr > &traffic_rules=std::nullopt)
Sorts lanelet candidates by their matching cost for a 2D point.
size_t indexOfLineStringPointClosestToPoint(const std::vector< Eigen::Vector2d > &line_string, const Eigen::Vector2d &point, const bool consider_order=false, const bool behind=true)
Finds the index of a point in a line string that is closest to another point.
ResampleCenterlinesAlongPathResult resampleCenterlinesAlongPath(const lanelet::routing::LaneletPath &path, const double delta_s, bool monotonically)
Equidistantly resamples lanelet centerlines along a path to one joint centerline.
size_t considerOrderForPointMatchedToLineString(const std::vector< Eigen::Vector2d > &line_string, const Eigen::Vector2d &point, const size_t idx_closest, const bool behind)
Takes a closest point in a line string and guarantees that it is behind or ahead of the given point.
void postprocessRouteMessage(route_planning_msgs::msg::Route &route_msg, std::vector< std::vector< int > > &suggested_turn_signal_distance_ahead_by_route_element_by_lane_element)
Postprocesses a route message, filling missing information that can be inferred from other message co...
std::pair< Eigen::Vector2d, Eigen::Vector2d > extractDrivableSpace(const lanelet::LineStringLayer &line_string_layer, const PointSequence &point_sequence, const double max_distance)
Extracts drivable space boundaries for a route element.
std::pair< uint8_t, uint8_t > regulatoryElementType(const std::shared_ptr< const lanelet::RegulatoryElement > ®ulatory_element)
Extracts the type and meta value of a regulatory element.
std::vector< lanelet::ConstLanelet > adjacentLeftOrRightLanelets(const lanelet::ConstLanelet &lanelet, const lanelet::routing::RoutingGraphUPtr &routing_graph, bool left, bool sort_from_left=true)
Finds lanelets adjacent to the left or right of a given lanelet.
std::optional< lanelet::ConstLanelet > laneletAtPoint(const Eigen::Vector2d &point, const lanelet::LaneletMapConstPtr &map, const std::optional< lanelet::traffic_rules::TrafficRulesPtr > traffic_rules=std::nullopt)
Find lanelet at arbitrary point.
std::vector< ProjectedLaneletPoints > projectPointToLaneletLines(const Eigen::Vector2d &point, const Eigen::Vector2d &prev_point, const Eigen::Vector2d &next_point, const std::vector< lanelet::ConstLanelet > &lanelets, const rclcpp::Logger &logger=rclcpp::get_logger("lanelet2_route_planning"))
Projects a point to the centerline and bounds of a set of lanelets.
uint8_t regulatoryElementSpeedLimit(const std::shared_ptr< const lanelet::RegulatoryElement > ®ulatory_element)
Extracts the speed limit of a regulatory element of subtype 'speed_limit'.
std::tuple< uint8_t, int > suggestedTurnSignal(const lanelet::ConstLanelet &lanelet, const rclcpp::Logger &logger)
Extracts the suggested turn signal of a lanelet.
double distanceRemaining(const route_planning_msgs::msg::Route &route)
Computes the remaining distance along the route.
A local route window and its offset in the complete route.
route_planning_msgs::msg::Route route
Helper type for a sequence of three points.
PointSequence(const Eigen::Vector2d &prev, const Eigen::Vector2d ¤t, const Eigen::Vector2d &next)
Constructs a point sequence from three consecutive points.
Eigen::Vector2d next
next point
Eigen::Vector2d prev
previous point
Eigen::Vector2d current
current point
Projected lanelet points.
Eigen::Vector2d centerline_point
projected centerline point
Eigen::Vector2d right_bound_point
projected right bound point
Eigen::Vector2d left_bound_point
projected left bound point
Return type of resampleCenterlinesAlongPath.
std::vector< Eigen::Vector3d > centerline
resampled centerline
std::vector< size_t > lanelet_idx_by_point
lanelet index in path for each point