lanelet2_route_planning v2.0.0
Loading...
Searching...
No Matches
utils.cpp File Reference
#include <algorithm>
#include <cmath>
#include <limits>
#include <optional>
#include <regex>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <lanelet2_core/geometry/LaneletMap.h>
#include <lanelet2_core/utility/Units.h>
#include <lanelet2_routing/Route.h>
#include <lanelet2_traffic_rules/TrafficRulesFactory.h>
#include <route_planning_msgs_utils/route_access.hpp>
#include "lanelet2_route_planning/conversions.hpp"
#include "lanelet2_route_planning/geometry.hpp"
#include "lanelet2_route_planning/utils.hpp"

Go to the source code of this file.

Namespaces

namespace  lanelet2_route_planning
 

Functions

std::optional< lanelet::routing::Route > lanelet2_route_planning::getRoute (const lanelet::routing::RoutingGraphUPtr &routing_graph, const std::vector< lanelet::ConstLanelet > &route_lanelets)
 Computes a route from start to destination along intermediate destinations.
 
size_t lanelet2_route_planning::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.
 
size_t lanelet2_route_planning::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.
 
size_t lanelet2_route_planning::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.
 
bool lanelet2_route_planning::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::vector< lanelet::ConstLanelet > lanelet2_route_planning::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::vector< ProjectedLaneletPointslanelet2_route_planning::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.
 
std::optional< int > lanelet2_route_planning::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.
 
route_planning_msgs::msg::RouteElement lanelet2_route_planning::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.
 
std::pair< Eigen::Vector2d, Eigen::Vector2d > lanelet2_route_planning::extractDrivableSpace (const lanelet::LineStringLayer &line_string_layer, const PointSequence &point_sequence, const double max_distance)
 Extracts drivable space boundaries for a route element.
 
bool lanelet2_route_planning::isLineStringDrivable (const lanelet::ConstLineString3d &line_string)
 Checks if lanelet line string has a type that is considered drivable.
 
ExtractRegulatoryElementsResult lanelet2_route_planning::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.
 
std::optional< std::array< geometry_msgs::msg::Point, 2 > > lanelet2_route_planning::regulatoryElementReferenceLine (const std::shared_ptr< const lanelet::RegulatoryElement > &regulatory_element)
 Extracts the reference/effect line of a regulatory element.
 
std::optional< std::array< geometry_msgs::msg::Point, 2 > > lanelet2_route_planning::regulatoryElementCancelLine (const std::shared_ptr< const lanelet::RegulatoryElement > &regulatory_element)
 Extracts the cancel line of a regulatory element.
 
std::vector< geometry_msgs::msg::Point > lanelet2_route_planning::regulatoryElementPositions (const std::shared_ptr< const lanelet::RegulatoryElement > &regulatory_element)
 Extracts the sign/signal positions of a regulatory element.
 
std::pair< uint8_t, uint8_t > lanelet2_route_planning::regulatoryElementType (const std::shared_ptr< const lanelet::RegulatoryElement > &regulatory_element)
 Extracts the type and meta value of a regulatory element.
 
uint8_t lanelet2_route_planning::regulatoryElementSpeedLimit (const std::shared_ptr< const lanelet::RegulatoryElement > &regulatory_element)
 Extracts the speed limit of a regulatory element of subtype 'speed_limit'.
 
uint8_t lanelet2_route_planning::laneBoundaryType (const lanelet::ConstLineString2d &line)
 Extracts the lane boundary type of a lanelet line.
 
uint8_t lanelet2_route_planning::speedLimit (const lanelet::ConstLanelet &lanelet, const bool consider_regulatory_elements=true)
 Extracts the speed limit of a lanelet.
 
uint8_t lanelet2_route_planning::speedLimit (const lanelet::ConstLanelet &lanelet, const Eigen::Vector2d &point)
 Extracts the speed limit of a lanelet at a specific position on that lanelet.
 
std::tuple< uint8_t, int > lanelet2_route_planning::suggestedTurnSignal (const lanelet::ConstLanelet &lanelet, const rclcpp::Logger &logger)
 Extracts the suggested turn signal of a lanelet.
 
lanelet::traffic_rules::TrafficRulesPtr lanelet2_route_planning::getTrafficRules ()
 Get traffic rules.
 
std::optional< lanelet::ConstLanelet > lanelet2_route_planning::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.
 
lanelet::ConstLanelet lanelet2_route_planning::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.
 
ResampleCenterlinesAlongPathResult lanelet2_route_planning::resampleCenterlinesAlongPath (const lanelet::routing::LaneletPath &path, const double delta_s, bool monotonically)
 Equidistantly resamples lanelet centerlines along a path to one joint centerline.
 
double lanelet2_route_planning::distanceTraveled (const route_planning_msgs::msg::Route &route)
 Computes the traveled distance along the route.
 
double lanelet2_route_planning::distanceRemaining (const route_planning_msgs::msg::Route &route)
 Computes the remaining distance along the route.
 
double lanelet2_route_planning::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.
 
void lanelet2_route_planning::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 contents.
 
void lanelet2_route_planning::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.
 
LocalRouteWindow lanelet2_route_planning::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.