// 开始规划时再次获取位姿 if ( !costmap_ros_->getRobotPose(current_pose_)) { ROS_ERROR("Could not get robot pose"); returnfalse; }
// TEB的部分全局路径也叫 transformed_plan,应该是因为下面的getLocalPlan参数也是这个名字 std::vector<geometry_msgs::PoseStamped> transformed_plan; // 获取全局路径 if ( !planner_util_.getLocalPlan(current_pose_, transformed_plan) ) { ROS_ERROR("Could not get local plan"); returnfalse; }
if(transformed_plan.empty()) { ROS_WARN_NAMED("dwa_local_planner", "Received an empty transformed plan."); returnfalse; } ROS_DEBUG_NAMED("dwa_local_planner", "Received a transformed plan with %zu points.", transformed_plan.size());
// update plan in dwa_planner even if we just stop and rotate, to allow checkTrajectory dp_->updatePlanAndLocalCosts(current_pose_, transformed_plan, costmap_ros_->getRobotFootprint() );
// we want the robot nose to be drawn to its final position // (before robot turns towards goal orientation), not the end of the // path for the robot center. Choosing the final position after // turning towards goal orientation causes instability when the // robot needs to make a 180 degree turn at the end std::vector<geometry_msgs::PoseStamped> front_global_plan = global_plan_; double angle_to_goal = atan2(goal_pose.pose.position.y - pos[1], goal_pose.pose.position.x - pos[0]);
goal_front_costs_.setTargetPoses(front_global_plan); // keeping the nose on the path if (sq_dist > forward_point_distance_ * forward_point_distance_ * cheat_factor_) { alignment_costs_.setScale(path_distance_bias_); // costs for robot being aligned with path (nose on path, not ju alignment_costs_.setTargetPoses(global_plan_); } else { // once we are close to goal, trying to keep the nose close to anything destabilizes behavior. alignment_costs_.setScale(0.0); } }