47 #include <nav_msgs/Path.h> 58 if (
setup_ && config.restore_defaults) {
60 config.restore_defaults =
false;
89 dp_->reconfigure(config);
133 dsrv_ =
new dynamic_reconfigure::Server<DWAPlannerConfig>(private_nh);
135 dsrv_->setCallback(cb);
138 ROS_WARN(
"This planner has already been initialized, doing nothing.");
144 ROS_ERROR(
"This planner has not been initialized, please call initialize() before using this planner");
151 return dp_->setPlan(orig_global_plan);
156 ROS_ERROR(
"This planner has not been initialized, please call initialize() before using this planner");
191 ROS_ERROR(
"This planner has not been initialized, please call initialize() before using this planner");
195 geometry_msgs::PoseStamped robot_vel;
205 geometry_msgs::PoseStamped drive_cmds;
221 cmd_vel.linear.x = drive_cmds.pose.position.x;
222 cmd_vel.linear.y = drive_cmds.pose.position.y;
223 cmd_vel.angular.z =
tf2::getYaw(drive_cmds.pose.orientation);
226 std::vector<geometry_msgs::PoseStamped> local_plan;
229 "The dwa local planner failed to find a valid plan, cost functions discarded all candidates. This can mean there is an obstacle too close to the robot.");
235 ROS_DEBUG_NAMED(
"dwa_local_planner",
"A valid velocity command of (%.2f, %.2f, %.2f) was found for this cycle.",
236 cmd_vel.linear.x, cmd_vel.linear.y, cmd_vel.angular.z);
240 double p_x, p_y, p_th;
243 geometry_msgs::PoseStamped p;
246 p.pose.position.x = p_x;
247 p.pose.position.y = p_y;
248 p.pose.position.z = 0.0;
252 local_plan.push_back(p);
270 std::vector<geometry_msgs::PoseStamped> transformed_plan;
277 if(transformed_plan.empty()) {
278 ROS_WARN_NAMED(
"dwa_local_planner",
"Received an empty transformed plan.");
281 ROS_DEBUG_NAMED(
"dwa_local_planner",
"Received a transformed plan with %zu points.", transformed_plan.size());
288 std::vector<geometry_msgs::PoseStamped> local_plan;
289 std::vector<geometry_msgs::PoseStamped> transformed_plan;
306 ROS_WARN_NAMED(
"dwa_local_planner",
"DWA planner failed to produce path.");
307 std::vector<geometry_msgs::PoseStamped> empty_plan;
boost::shared_ptr< DWAPlanner > dp_
The trajectory controller.
void reconfigureCB(DWAPlannerConfig &config, uint32_t level)
Callback to update the local planner's parameters based on dynamic reconfigure.
Eigen::Vector3f getAccLimits()
bool getLocalPlan(const geometry_msgs::PoseStamped &global_pose, std::vector< geometry_msgs::PoseStamped > &transformed_plan)
void setRPY(const tf2Scalar &roll, const tf2Scalar &pitch, const tf2Scalar &yaw)
void warnRenamedParameter(const ros::NodeHandle &nh, const std::string current_name, const std::string old_name)
#define ROS_WARN_NAMED(name,...)
void reconfigureCB(LocalPlannerLimits &config, bool restore_defaults)
dynamic_reconfigure::Server< DWAPlannerConfig > * dsrv_
void initialize(tf2_ros::Buffer *tf, costmap_2d::Costmap2D *costmap, std::string global_frame)
std::string getGlobalFrameID()
bool isPositionReached(LocalPlannerUtil *planner_util, const geometry_msgs::PoseStamped &global_pose)
geometry_msgs::PoseStamped current_pose_
unsigned int getPointsSize() const
base_local_planner::OdometryHelperRos odom_helper_
void getPoint(unsigned int index, double &x, double &y, double &th) const
bool isGoalReached(LocalPlannerUtil *planner_util, OdometryHelperRos &odom_helper, const geometry_msgs::PoseStamped &global_pose)
base_local_planner::LatchedStopRotateController latchedStopRotateController_
ROS Wrapper for the DWAPlanner that adheres to the BaseLocalPlanner interface and can be used as a pl...
void initialize(std::string name, tf2_ros::Buffer *tf, costmap_2d::Costmap2DROS *costmap_ros)
Constructs the ros wrapper.
bool computeVelocityCommandsStopRotate(geometry_msgs::Twist &cmd_vel, Eigen::Vector3f acc_lim, double sim_period, LocalPlannerUtil *planner_util, OdometryHelperRos &odom_helper, const geometry_msgs::PoseStamped &global_pose, boost::function< bool(Eigen::Vector3f pos, Eigen::Vector3f vel, Eigen::Vector3f vel_samples)> obstacle_check)
#define ROS_DEBUG_NAMED(name,...)
A class implementing a local planner using the Dynamic Window Approach.
costmap_2d::Costmap2DROS * costmap_ros_
bool computeVelocityCommands(geometry_msgs::Twist &cmd_vel)
Given the current position, orientation, and velocity of the robot, compute velocity commands to send...
bool getParam(const std::string &key, std::string &s) const
LocalPlannerLimits getCurrentLimits()
std::string getBaseFrameID()
bool getRobotPose(geometry_msgs::PoseStamped &global_pose) const
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
bool setPlan(const std::vector< geometry_msgs::PoseStamped > &orig_global_plan)
Set the plan that the controller is following.
double getYaw(const A &a)
void publishPlan(const std::vector< geometry_msgs::PoseStamped > &path, const ros::Publisher &pub)
dwa_local_planner::DWAPlannerConfig default_config_
ros::Publisher l_plan_pub_
tf2_ros::Buffer * tf_
Used for transforming point clouds.
void publishLocalPlan(std::vector< geometry_msgs::PoseStamped > &path)
void convert(const A &a, B &b)
void setOdomTopic(std::string odom_topic)
void publishGlobalPlan(std::vector< geometry_msgs::PoseStamped > &path)
~DWAPlannerROS()
Destructor for the wrapper.
void getRobotVel(geometry_msgs::PoseStamped &robot_vel)
bool dwaComputeVelocityCommands(geometry_msgs::PoseStamped &global_pose, geometry_msgs::Twist &cmd_vel)
Given the current position, orientation, and velocity of the robot, compute velocity commands to send...
DWAPlannerROS()
Constructor for DWAPlannerROS wrapper.
std::vector< geometry_msgs::Point > getRobotFootprint()
bool isGoalReached()
Check if the goal pose has been achieved.
ros::Publisher g_plan_pub_
#define PLUGINLIB_EXPORT_CLASS(class_type, base_class_type)
base_local_planner::LocalPlannerUtil planner_util_
double yaw_goal_tolerance
bool checkTrajectory(const Eigen::Vector3f pos, const Eigen::Vector3f vel, const Eigen::Vector3f vel_samples)
Check if a trajectory is legal for a position/velocity pair.