18 #include "nav2_route/plugins/edge_cost_functions/distance_scorer.hpp"
24 const nav2::LifecycleNode::SharedPtr node,
25 const std::shared_ptr<tf2_ros::Buffer>,
26 std::shared_ptr<nav2_costmap_2d::CostmapSubscriber>,
27 const std::string & name)
29 RCLCPP_INFO(node->get_logger(),
"Configuring distance scorer.");
33 nav2::declare_parameter_if_not_declared(
34 node,
getName() +
".speed_tag", rclcpp::ParameterValue(
"speed_limit"));
35 speed_tag_ = node->get_parameter(
getName() +
".speed_tag").as_string();
38 nav2::declare_parameter_if_not_declared(
39 node,
getName() +
".weight", rclcpp::ParameterValue(1.0));
40 weight_ =
static_cast<float>(node->get_parameter(
getName() +
".weight").as_double());
46 const EdgeType & ,
float & cost)
49 float speed_val = 1.0f;
50 speed_val = edge->metadata.getValue<
float>(speed_tag_, speed_val);
51 cost = weight_ * hypotf(
52 edge->end->coords.x - edge->start->coords.x,
53 edge->end->coords.y - edge->start->coords.y) / speed_val;
64 #include "pluginlib/class_list_macros.hpp"
Scores edges by the distance traversed, weighted by speed limit metadata to optimize for time to goal...
std::string getName() override
Get name of the plugin for parameter scope mapping.
void configure(const nav2::LifecycleNode::SharedPtr node, const std::shared_ptr< tf2_ros::Buffer > tf_buffer, std::shared_ptr< nav2_costmap_2d::CostmapSubscriber > costmap_subscriber, const std::string &name) override
Configure.
bool score(const EdgePtr edge, const RouteRequest &route_request, const EdgeType &edge_type, float &cost) override
Main scoring plugin API.
A plugin interface to score edges during graph search to modify the lowest cost path (e....
An object representing edges between nodes.
An object to store salient features of the route request including its start and goal node ids,...