35 #include "dwb_plugins/limited_accel_generator.hpp"
39 #include "nav_2d_utils/parameters.hpp"
40 #include "pluginlib/class_list_macros.hpp"
41 #include "dwb_core/exceptions.hpp"
42 #include "nav2_util/node_utils.hpp"
48 const nav2_util::LifecycleNode::SharedPtr & nh,
49 const std::string & plugin_name)
51 plugin_name_ = plugin_name;
55 nav2_util::declare_parameter_if_not_declared(
56 nh, plugin_name +
".sim_period", rclcpp::PARAMETER_DOUBLE);
57 if (!nh->get_parameter(plugin_name +
".sim_period", acceleration_time_)) {
62 throw std::runtime_error(
"Failed to get 'sim_period' value");
64 }
catch (std::exception &) {
66 rclcpp::get_logger(
"LimitedAccelGenerator"),
67 "'sim_period' parameter is not set for %s", plugin_name.c_str());
68 double controller_frequency = nav_2d_utils::searchAndGetParam(
69 nh,
"controller_frequency", 20.0);
70 if (controller_frequency > 0) {
71 acceleration_time_ = 1.0 / controller_frequency;
74 rclcpp::get_logger(
"LimitedAccelGenerator"),
75 "A controller_frequency less than or equal to 0 has been set. "
76 "Ignoring the parameter, assuming a rate of 20Hz");
77 acceleration_time_ = 0.05;
85 velocity_iterator_->startNewIteration(current_velocity, acceleration_time_);
89 const nav_2d_msgs::msg::Twist2D & cmd_vel,
90 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.
void initialize(const nav2_util::LifecycleNode::SharedPtr &nh, const std::string &plugin_name) override
Initialize parameters as needed.
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_util::LifecycleNode::SharedPtr &nh, const std::string &plugin_name) override
Initialize parameters as needed.