19 #include "nav2_route/plugins/route_operations/time_marker.hpp"
25 const rclcpp_lifecycle::LifecycleNode::SharedPtr node,
26 std::shared_ptr<nav2_costmap_2d::CostmapSubscriber>,
27 const std::string & name)
29 RCLCPP_INFO(node->get_logger(),
"Configuring Adjust speed limit operation.");
31 nav2_util::declare_parameter_if_not_declared(
32 node,
getName() +
".time_tag", rclcpp::ParameterValue(
"abs_time_taken"));
33 time_tag_ = node->get_parameter(
getName() +
".time_tag").as_string();
34 clock_ = node->get_clock();
35 edge_start_time_ = rclcpp::Time(0.0);
43 const geometry_msgs::msg::PoseStamped & ,
47 rclcpp::Time now = clock_->now();
48 if (!edge_exited || edge_exited->edgeid != curr_edge_) {
49 edge_start_time_ = now;
50 curr_edge_ = edge_entered ? edge_entered->edgeid : 0;
54 float dur =
static_cast<float>((now - edge_start_time_).seconds());
55 if (edge_start_time_.seconds() > 1e-3) {
56 edge_exited->metadata.setValue<
float>(time_tag_, dur);
59 edge_start_time_ = now;
60 curr_edge_ = edge_entered ? edge_entered->edgeid : 0;
66 #include "pluginlib/class_list_macros.hpp"
A plugin interface to perform an operation while tracking the route such as triggered from the graph ...
A route operation to add accurate times to the graph's edges after navigation to use in later iterati...
void configure(const rclcpp_lifecycle::LifecycleNode::SharedPtr node, std::shared_ptr< nav2_costmap_2d::CostmapSubscriber > costmap_subscriber, const std::string &name) override
Configure.
OperationResult perform(NodePtr node_achieved, EdgePtr edge_entered, EdgePtr edge_exited, const Route &route, const geometry_msgs::msg::PoseStamped &curr_pose, const Metadata *mdata=nullptr) override
The main speed limit operation to adjust the maximum speed of the vehicle.
std::string getName() override
Get name of the plugin for parameter scope mapping.
An object representing edges between nodes.
An object to store the nodes in the graph file.
a struct to hold return from an operation
An ordered set of nodes and edges corresponding to the planned route.