16 #ifndef NAV2_BEHAVIOR_TREE__PLUGINS__DECORATOR__SPEED_CONTROLLER_HPP_
17 #define NAV2_BEHAVIOR_TREE__PLUGINS__DECORATOR__SPEED_CONTROLLER_HPP_
24 #include "nav_msgs/msg/odometry.hpp"
25 #include "nav2_util/odometry_utils.hpp"
27 #include "behaviortree_cpp_v3/decorator_node.h"
29 namespace nav2_behavior_tree
46 const std::string & name,
47 const BT::NodeConfiguration & conf);
56 BT::InputPort<double>(
"min_rate", 0.1,
"Minimum rate"),
57 BT::InputPort<double>(
"max_rate", 1.0,
"Maximum rate"),
58 BT::InputPort<double>(
"min_speed", 0.0,
"Minimum speed"),
59 BT::InputPort<double>(
"max_speed", 0.5,
"Maximum speed"),
68 BT::NodeStatus tick()
override;
74 inline double getScaledRate(
const double & speed)
78 (((speed - min_speed_) / d_speed_) * d_rate_) + min_rate_,
79 max_rate_), min_rate_);
85 inline void updatePeriod()
87 auto velocity = odom_smoother_->getTwist();
88 double speed = std::hypot(velocity.linear.x, velocity.linear.y);
89 double rate = getScaledRate(speed);
93 rclcpp::Node::SharedPtr node_;
99 std::shared_ptr<nav2_util::OdomSmoother> odom_smoother_;
117 geometry_msgs::msg::PoseStamped goal_;
118 std::vector<geometry_msgs::msg::PoseStamped> goals_;
A BT::DecoratorNode that ticks its child every at a rate proportional to the speed of the robot....
static BT::PortsList providedPorts()
Creates list of BT ports.
SpeedController(const std::string &name, const BT::NodeConfiguration &conf)
A constructor for nav2_behavior_tree::SpeedController.