35 #include "dwb_plugins/limited_accel_generator.hpp"
39 #include "pluginlib/class_list_macros.hpp"
40 #include "dwb_core/exceptions.hpp"
41 #include "nav2_ros_common/node_utils.hpp"
47 const nav2::LifecycleNode::SharedPtr & nh,
48 const std::string & plugin_name)
50 plugin_name_ = plugin_name;
54 nav2::declare_parameter_if_not_declared(
55 nh, plugin_name +
".sim_period", rclcpp::PARAMETER_DOUBLE);
56 if (!nh->get_parameter(plugin_name +
".sim_period", acceleration_time_)) {
61 throw std::runtime_error(
"Failed to get 'sim_period' value");
63 }
catch (std::exception &) {
65 rclcpp::get_logger(
"LimitedAccelGenerator"),
66 "'sim_period' parameter is not set for %s", plugin_name.c_str());
67 double controller_frequency = nh->declare_or_get_parameter(
"controller_frequency", 20.0);
68 if (controller_frequency > 0) {
69 acceleration_time_ = 1.0 / controller_frequency;
72 rclcpp::get_logger(
"LimitedAccelGenerator"),
73 "A controller_frequency less than or equal to 0 has been set. "
74 "Ignoring the parameter, assuming a rate of 20Hz");
75 acceleration_time_ = 0.05;
83 velocity_iterator_->startNewIteration(current_velocity, acceleration_time_);
87 const nav_2d_msgs::msg::Twist2D & cmd_vel,
88 const nav_2d_msgs::msg::Twist2D & ,
Interface for iterating through possible velocities and creating trajectories.
Limits the acceleration in the generated trajectories to a fraction of the simulated time.
void startNewIteration(const nav_2d_msgs::msg::Twist2D ¤t_velocity) override
Start a new iteration based on the current velocity.
nav_2d_msgs::msg::Twist2D computeNewVelocity(const nav_2d_msgs::msg::Twist2D &cmd_vel, const nav_2d_msgs::msg::Twist2D &start_vel, const double dt) override
Calculate the velocity after a set period of time, given the desired velocity and acceleration limits...
void initialize(const nav2::LifecycleNode::SharedPtr &nh, const std::string &plugin_name) override
Initialize parameters as needed.
void initialize(const nav2::LifecycleNode::SharedPtr &nh, const std::string &plugin_name) override
Initialize parameters as needed.