18 #include "nav2_route/plugins/edge_cost_functions/time_scorer.hpp"
24 const rclcpp_lifecycle::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 time scorer.");
33 nav2_util::declare_parameter_if_not_declared(
34 node,
getName() +
".speed_tag", rclcpp::ParameterValue(
"abs_speed_limit"));
35 speed_tag_ = node->get_parameter(
getName() +
".speed_tag").as_string();
37 nav2_util::declare_parameter_if_not_declared(
38 node,
getName() +
".time_tag", rclcpp::ParameterValue(
"abs_time_taken"));
39 prev_time_tag_ = node->get_parameter(
getName() +
".time_tag").as_string();
42 nav2_util::declare_parameter_if_not_declared(
43 node,
getName() +
".weight", rclcpp::ParameterValue(1.0));
44 weight_ =
static_cast<float>(node->get_parameter(
getName() +
".weight").as_double());
46 nav2_util::declare_parameter_if_not_declared(
47 node,
getName() +
".max_vel", rclcpp::ParameterValue(0.5));
48 max_vel_ =
static_cast<float>(node->get_parameter(
getName() +
".max_vel").as_double());
54 const EdgeType & ,
float & cost)
58 time = edge->metadata.getValue<
float>(prev_time_tag_, time);
60 cost = weight_ * time;
65 float velocity = 0.0f;
66 velocity = edge->metadata.getValue<
float>(speed_tag_, velocity);
67 if (velocity <= 0.0f) {
71 cost = weight_ * hypotf(
72 edge->end->coords.x - edge->start->coords.x,
73 edge->end->coords.y - edge->start->coords.y) / velocity;
84 #include "pluginlib/class_list_macros.hpp"
A plugin interface to score edges during graph search to modify the lowest cost path (e....
Scores edges by the time to traverse an edge. It uses previous times to navigate the edge primarily,...
void configure(const rclcpp_lifecycle::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.
std::string getName() override
Get name of the plugin for parameter scope mapping.
An object representing edges between nodes.
An object to store salient features of the route request including its start and goal node ids,...