00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #include <teb_local_planner/teb_config.h>
00040
00041 namespace teb_local_planner
00042 {
00043
00044 void TebConfig::loadRosParamFromNodeHandle(const ros::NodeHandle& nh)
00045 {
00046
00047 nh.param("odom_topic", odom_topic, odom_topic);
00048 nh.param("map_frame", map_frame, map_frame);
00049
00050
00051 nh.param("teb_autosize", trajectory.teb_autosize, trajectory.teb_autosize);
00052 nh.param("dt_ref", trajectory.dt_ref, trajectory.dt_ref);
00053 nh.param("dt_hysteresis", trajectory.dt_hysteresis, trajectory.dt_hysteresis);
00054 nh.param("min_samples", trajectory.min_samples, trajectory.min_samples);
00055 nh.param("max_samples", trajectory.max_samples, trajectory.max_samples);
00056 nh.param("global_plan_overwrite_orientation", trajectory.global_plan_overwrite_orientation, trajectory.global_plan_overwrite_orientation);
00057 nh.param("allow_init_with_backwards_motion", trajectory.allow_init_with_backwards_motion, trajectory.allow_init_with_backwards_motion);
00058 nh.param("global_plan_via_point_sep", trajectory.global_plan_viapoint_sep, trajectory.global_plan_viapoint_sep);
00059 nh.param("via_points_ordered", trajectory.via_points_ordered, trajectory.via_points_ordered);
00060 nh.param("max_global_plan_lookahead_dist", trajectory.max_global_plan_lookahead_dist, trajectory.max_global_plan_lookahead_dist);
00061 nh.param("exact_arc_length", trajectory.exact_arc_length, trajectory.exact_arc_length);
00062 nh.param("force_reinit_new_goal_dist", trajectory.force_reinit_new_goal_dist, trajectory.force_reinit_new_goal_dist);
00063 nh.param("feasibility_check_no_poses", trajectory.feasibility_check_no_poses, trajectory.feasibility_check_no_poses);
00064 nh.param("publish_feedback", trajectory.publish_feedback, trajectory.publish_feedback);
00065 nh.param("shrink_horizon_backup", trajectory.shrink_horizon_backup, trajectory.shrink_horizon_backup);
00066 nh.param("shrink_horizon_min_duration", trajectory.shrink_horizon_min_duration, trajectory.shrink_horizon_min_duration);
00067
00068
00069 nh.param("max_vel_x", robot.max_vel_x, robot.max_vel_x);
00070 nh.param("max_vel_x_backwards", robot.max_vel_x_backwards, robot.max_vel_x_backwards);
00071 nh.param("max_vel_y", robot.max_vel_y, robot.max_vel_y);
00072 nh.param("max_vel_theta", robot.max_vel_theta, robot.max_vel_theta);
00073 nh.param("acc_lim_x", robot.acc_lim_x, robot.acc_lim_x);
00074 nh.param("acc_lim_y", robot.acc_lim_y, robot.acc_lim_y);
00075 nh.param("acc_lim_theta", robot.acc_lim_theta, robot.acc_lim_theta);
00076 nh.param("min_turning_radius", robot.min_turning_radius, robot.min_turning_radius);
00077 nh.param("wheelbase", robot.wheelbase, robot.wheelbase);
00078 nh.param("cmd_angle_instead_rotvel", robot.cmd_angle_instead_rotvel, robot.cmd_angle_instead_rotvel);
00079
00080
00081 nh.param("xy_goal_tolerance", goal_tolerance.xy_goal_tolerance, goal_tolerance.xy_goal_tolerance);
00082 nh.param("yaw_goal_tolerance", goal_tolerance.yaw_goal_tolerance, goal_tolerance.yaw_goal_tolerance);
00083 nh.param("free_goal_vel", goal_tolerance.free_goal_vel, goal_tolerance.free_goal_vel);
00084
00085
00086 nh.param("min_obstacle_dist", obstacles.min_obstacle_dist, obstacles.min_obstacle_dist);
00087 nh.param("inflation_dist", obstacles.inflation_dist, obstacles.inflation_dist);
00088 nh.param("include_costmap_obstacles", obstacles.include_costmap_obstacles, obstacles.include_costmap_obstacles);
00089 nh.param("costmap_obstacles_behind_robot_dist", obstacles.costmap_obstacles_behind_robot_dist, obstacles.costmap_obstacles_behind_robot_dist);
00090 nh.param("obstacle_poses_affected", obstacles.obstacle_poses_affected, obstacles.obstacle_poses_affected);
00091 nh.param("legacy_obstacle_association", obstacles.legacy_obstacle_association, obstacles.legacy_obstacle_association);
00092 nh.param("obstacle_association_force_inclusion_factor", obstacles.obstacle_association_force_inclusion_factor, obstacles.obstacle_association_force_inclusion_factor);
00093 nh.param("obstacle_association_cutoff_factor", obstacles.obstacle_association_cutoff_factor, obstacles.obstacle_association_cutoff_factor);
00094 nh.param("costmap_converter_plugin", obstacles.costmap_converter_plugin, obstacles.costmap_converter_plugin);
00095 nh.param("costmap_converter_spin_thread", obstacles.costmap_converter_spin_thread, obstacles.costmap_converter_spin_thread);
00096
00097
00098 nh.param("no_inner_iterations", optim.no_inner_iterations, optim.no_inner_iterations);
00099 nh.param("no_outer_iterations", optim.no_outer_iterations, optim.no_outer_iterations);
00100 nh.param("optimization_activate", optim.optimization_activate, optim.optimization_activate);
00101 nh.param("optimization_verbose", optim.optimization_verbose, optim.optimization_verbose);
00102 nh.param("penalty_epsilon", optim.penalty_epsilon, optim.penalty_epsilon);
00103 nh.param("weight_max_vel_x", optim.weight_max_vel_x, optim.weight_max_vel_x);
00104 nh.param("weight_max_vel_y", optim.weight_max_vel_y, optim.weight_max_vel_y);
00105 nh.param("weight_max_vel_theta", optim.weight_max_vel_theta, optim.weight_max_vel_theta);
00106 nh.param("weight_acc_lim_x", optim.weight_acc_lim_x, optim.weight_acc_lim_x);
00107 nh.param("weight_acc_lim_y", optim.weight_acc_lim_y, optim.weight_acc_lim_y);
00108 nh.param("weight_acc_lim_theta", optim.weight_acc_lim_theta, optim.weight_acc_lim_theta);
00109 nh.param("weight_kinematics_nh", optim.weight_kinematics_nh, optim.weight_kinematics_nh);
00110 nh.param("weight_kinematics_forward_drive", optim.weight_kinematics_forward_drive, optim.weight_kinematics_forward_drive);
00111 nh.param("weight_kinematics_turning_radius", optim.weight_kinematics_turning_radius, optim.weight_kinematics_turning_radius);
00112 nh.param("weight_optimaltime", optim.weight_optimaltime, optim.weight_optimaltime);
00113 nh.param("weight_obstacle", optim.weight_obstacle, optim.weight_obstacle);
00114 nh.param("weight_inflation", optim.weight_inflation, optim.weight_inflation);
00115 nh.param("weight_dynamic_obstacle", optim.weight_dynamic_obstacle, optim.weight_dynamic_obstacle);
00116 nh.param("weight_viapoint", optim.weight_viapoint, optim.weight_viapoint);
00117 nh.param("weight_adapt_factor", optim.weight_adapt_factor, optim.weight_adapt_factor);
00118
00119
00120 nh.param("enable_homotopy_class_planning", hcp.enable_homotopy_class_planning, hcp.enable_homotopy_class_planning);
00121 nh.param("enable_multithreading", hcp.enable_multithreading, hcp.enable_multithreading);
00122 nh.param("simple_exploration", hcp.simple_exploration, hcp.simple_exploration);
00123 nh.param("max_number_classes", hcp.max_number_classes, hcp.max_number_classes);
00124 nh.param("selection_obst_cost_scale", hcp.selection_obst_cost_scale, hcp.selection_obst_cost_scale);
00125 nh.param("selection_prefer_initial_plan", hcp.selection_prefer_initial_plan, hcp.selection_prefer_initial_plan);
00126 nh.param("selection_viapoint_cost_scale", hcp.selection_viapoint_cost_scale, hcp.selection_viapoint_cost_scale);
00127 nh.param("selection_cost_hysteresis", hcp.selection_cost_hysteresis, hcp.selection_cost_hysteresis);
00128 nh.param("selection_alternative_time_cost", hcp.selection_alternative_time_cost, hcp.selection_alternative_time_cost);
00129 nh.param("roadmap_graph_samples", hcp.roadmap_graph_no_samples, hcp.roadmap_graph_no_samples);
00130 nh.param("roadmap_graph_area_width", hcp.roadmap_graph_area_width, hcp.roadmap_graph_area_width);
00131 nh.param("roadmap_graph_area_length_scale", hcp.roadmap_graph_area_length_scale, hcp.roadmap_graph_area_length_scale);
00132 nh.param("h_signature_prescaler", hcp.h_signature_prescaler, hcp.h_signature_prescaler);
00133 nh.param("h_signature_threshold", hcp.h_signature_threshold, hcp.h_signature_threshold);
00134 nh.param("obstacle_keypoint_offset", hcp.obstacle_keypoint_offset, hcp.obstacle_keypoint_offset);
00135 nh.param("obstacle_heading_threshold", hcp.obstacle_heading_threshold, hcp.obstacle_heading_threshold);
00136 nh.param("viapoints_all_candidates", hcp.viapoints_all_candidates, hcp.viapoints_all_candidates);
00137 nh.param("visualize_hc_graph", hcp.visualize_hc_graph, hcp.visualize_hc_graph);
00138
00139 checkParameters();
00140 checkDeprecated(nh);
00141 }
00142
00143 void TebConfig::reconfigure(TebLocalPlannerReconfigureConfig& cfg)
00144 {
00145 boost::mutex::scoped_lock l(config_mutex_);
00146
00147
00148 trajectory.teb_autosize = cfg.teb_autosize;
00149 trajectory.dt_ref = cfg.dt_ref;
00150 trajectory.dt_hysteresis = cfg.dt_hysteresis;
00151 trajectory.global_plan_overwrite_orientation = cfg.global_plan_overwrite_orientation;
00152 trajectory.allow_init_with_backwards_motion = cfg.allow_init_with_backwards_motion;
00153 trajectory.global_plan_viapoint_sep = cfg.global_plan_viapoint_sep;
00154 trajectory.via_points_ordered = cfg.via_points_ordered;
00155 trajectory.max_global_plan_lookahead_dist = cfg.max_global_plan_lookahead_dist;
00156 trajectory.exact_arc_length = cfg.exact_arc_length;
00157 trajectory.force_reinit_new_goal_dist = cfg.force_reinit_new_goal_dist;
00158 trajectory.feasibility_check_no_poses = cfg.feasibility_check_no_poses;
00159 trajectory.publish_feedback = cfg.publish_feedback;
00160 trajectory.shrink_horizon_backup = cfg.shrink_horizon_backup;
00161
00162
00163 robot.max_vel_x = cfg.max_vel_x;
00164 robot.max_vel_x_backwards = cfg.max_vel_x_backwards;
00165 robot.max_vel_y = cfg.max_vel_y;
00166 robot.max_vel_theta = cfg.max_vel_theta;
00167 robot.acc_lim_x = cfg.acc_lim_x;
00168 robot.acc_lim_y = cfg.acc_lim_y;
00169 robot.acc_lim_theta = cfg.acc_lim_theta;
00170 robot.min_turning_radius = cfg.min_turning_radius;
00171 robot.wheelbase = cfg.wheelbase;
00172 robot.cmd_angle_instead_rotvel = cfg.cmd_angle_instead_rotvel;
00173
00174
00175 goal_tolerance.xy_goal_tolerance = cfg.xy_goal_tolerance;
00176 goal_tolerance.yaw_goal_tolerance = cfg.yaw_goal_tolerance;
00177 goal_tolerance.free_goal_vel = cfg.free_goal_vel;
00178
00179
00180 obstacles.min_obstacle_dist = cfg.min_obstacle_dist;
00181 obstacles.inflation_dist = cfg.inflation_dist;
00182 obstacles.include_costmap_obstacles = cfg.include_costmap_obstacles;
00183 obstacles.legacy_obstacle_association = cfg.legacy_obstacle_association;
00184 obstacles.obstacle_association_force_inclusion_factor = cfg.obstacle_association_force_inclusion_factor;
00185 obstacles.obstacle_association_cutoff_factor = cfg.obstacle_association_cutoff_factor;
00186 obstacles.costmap_obstacles_behind_robot_dist = cfg.costmap_obstacles_behind_robot_dist;
00187 obstacles.obstacle_poses_affected = cfg.obstacle_poses_affected;
00188
00189
00190
00191 optim.no_inner_iterations = cfg.no_inner_iterations;
00192 optim.no_outer_iterations = cfg.no_outer_iterations;
00193 optim.optimization_activate = cfg.optimization_activate;
00194 optim.optimization_verbose = cfg.optimization_verbose;
00195 optim.penalty_epsilon = cfg.penalty_epsilon;
00196 optim.weight_max_vel_x = cfg.weight_max_vel_x;
00197 optim.weight_max_vel_y = cfg.weight_max_vel_y;
00198 optim.weight_max_vel_theta = cfg.weight_max_vel_theta;
00199 optim.weight_acc_lim_x = cfg.weight_acc_lim_x;
00200 optim.weight_acc_lim_y = cfg.weight_acc_lim_y;
00201 optim.weight_acc_lim_theta = cfg.weight_acc_lim_theta;
00202 optim.weight_kinematics_nh = cfg.weight_kinematics_nh;
00203 optim.weight_kinematics_forward_drive = cfg.weight_kinematics_forward_drive;
00204 optim.weight_kinematics_turning_radius = cfg.weight_kinematics_turning_radius;
00205 optim.weight_optimaltime = cfg.weight_optimaltime;
00206 optim.weight_obstacle = cfg.weight_obstacle;
00207 optim.weight_inflation = cfg.weight_inflation;
00208 optim.weight_dynamic_obstacle = cfg.weight_dynamic_obstacle;
00209 optim.weight_viapoint = cfg.weight_viapoint;
00210 optim.weight_adapt_factor = cfg.weight_adapt_factor;
00211
00212
00213 hcp.enable_multithreading = cfg.enable_multithreading;
00214 hcp.simple_exploration = cfg.simple_exploration;
00215 hcp.max_number_classes = cfg.max_number_classes;
00216 hcp.selection_cost_hysteresis = cfg.selection_cost_hysteresis;
00217 hcp.selection_prefer_initial_plan = cfg.selection_prefer_initial_plan;
00218 hcp.selection_obst_cost_scale = cfg.selection_obst_cost_scale;
00219 hcp.selection_viapoint_cost_scale = cfg.selection_viapoint_cost_scale;
00220 hcp.selection_alternative_time_cost = cfg.selection_alternative_time_cost;
00221
00222 hcp.obstacle_keypoint_offset = cfg.obstacle_keypoint_offset;
00223 hcp.obstacle_heading_threshold = cfg.obstacle_heading_threshold;
00224 hcp.roadmap_graph_no_samples = cfg.roadmap_graph_no_samples;
00225 hcp.roadmap_graph_area_width = cfg.roadmap_graph_area_width;
00226 hcp.roadmap_graph_area_length_scale = cfg.roadmap_graph_area_length_scale;
00227 hcp.h_signature_prescaler = cfg.h_signature_prescaler;
00228 hcp.h_signature_threshold = cfg.h_signature_threshold;
00229 hcp.viapoints_all_candidates = cfg.viapoints_all_candidates;
00230 hcp.visualize_hc_graph = cfg.visualize_hc_graph;
00231
00232 checkParameters();
00233 }
00234
00235
00236 void TebConfig::checkParameters() const
00237 {
00238
00239 if (robot.max_vel_x_backwards <= 0)
00240 ROS_WARN("TebLocalPlannerROS() Param Warning: Do not choose max_vel_x_backwards to be <=0. Disable backwards driving by increasing the optimization weight for penalyzing backwards driving.");
00241
00242
00243 if (robot.max_vel_x <= optim.penalty_epsilon)
00244 ROS_WARN("TebLocalPlannerROS() Param Warning: max_vel_x <= penalty_epsilon. The resulting bound is negative. Undefined behavior... Change at least one of them!");
00245
00246 if (robot.max_vel_x_backwards <= optim.penalty_epsilon)
00247 ROS_WARN("TebLocalPlannerROS() Param Warning: max_vel_x_backwards <= penalty_epsilon. The resulting bound is negative. Undefined behavior... Change at least one of them!");
00248
00249 if (robot.max_vel_theta <= optim.penalty_epsilon)
00250 ROS_WARN("TebLocalPlannerROS() Param Warning: max_vel_theta <= penalty_epsilon. The resulting bound is negative. Undefined behavior... Change at least one of them!");
00251
00252 if (robot.acc_lim_x <= optim.penalty_epsilon)
00253 ROS_WARN("TebLocalPlannerROS() Param Warning: acc_lim_x <= penalty_epsilon. The resulting bound is negative. Undefined behavior... Change at least one of them!");
00254
00255 if (robot.acc_lim_theta <= optim.penalty_epsilon)
00256 ROS_WARN("TebLocalPlannerROS() Param Warning: acc_lim_theta <= penalty_epsilon. The resulting bound is negative. Undefined behavior... Change at least one of them!");
00257
00258
00259 if (trajectory.dt_ref <= trajectory.dt_hysteresis)
00260 ROS_WARN("TebLocalPlannerROS() Param Warning: dt_ref <= dt_hysteresis. The hysteresis is not allowed to be greater or equal!. Undefined behavior... Change at least one of them!");
00261
00262
00263 if (trajectory.min_samples <3)
00264 ROS_WARN("TebLocalPlannerROS() Param Warning: parameter min_samples is smaller than 3! Sorry, I haven't enough degrees of freedom to plan a trajectory for you. Please increase ...");
00265
00266
00267 if (obstacles.costmap_obstacles_behind_robot_dist < 0)
00268 ROS_WARN("TebLocalPlannerROS() Param Warning: parameter 'costmap_obstacles_behind_robot_dist' should be positive or zero.");
00269
00270
00271 if (hcp.obstacle_keypoint_offset>=1 || hcp.obstacle_keypoint_offset<=0)
00272 ROS_WARN("TebLocalPlannerROS() Param Warning: parameter obstacle_heading_threshold must be in the interval ]0,1[. 0=0deg opening angle, 1=90deg opening angle.");
00273
00274
00275 if (robot.cmd_angle_instead_rotvel && robot.wheelbase==0)
00276 ROS_WARN("TebLocalPlannerROS() Param Warning: parameter cmd_angle_instead_rotvel is non-zero but wheelbase is set to zero: undesired behavior.");
00277
00278 if (robot.cmd_angle_instead_rotvel && robot.min_turning_radius==0)
00279 ROS_WARN("TebLocalPlannerROS() Param Warning: parameter cmd_angle_instead_rotvel is non-zero but min_turning_radius is set to zero: undesired behavior. You are mixing a carlike and a diffdrive robot");
00280
00281
00282 if (optim.weight_adapt_factor < 1.0)
00283 ROS_WARN("TebLocalPlannerROS() Param Warning: parameter weight_adapt_factor shoud be >= 1.0");
00284
00285 }
00286
00287 void TebConfig::checkDeprecated(const ros::NodeHandle& nh) const
00288 {
00289 if (nh.hasParam("line_obstacle_poses_affected") || nh.hasParam("polygon_obstacle_poses_affected"))
00290 ROS_WARN("TebLocalPlannerROS() Param Warning: 'line_obstacle_poses_affected' and 'polygon_obstacle_poses_affected' are deprecated. They share now the common parameter 'obstacle_poses_affected'.");
00291
00292 if (nh.hasParam("weight_point_obstacle") || nh.hasParam("weight_line_obstacle") || nh.hasParam("weight_poly_obstacle"))
00293 ROS_WARN("TebLocalPlannerROS() Param Warning: 'weight_point_obstacle', 'weight_line_obstacle' and 'weight_poly_obstacle' are deprecated. They are replaced by the single param 'weight_obstacle'.");
00294
00295 if (nh.hasParam("costmap_obstacles_front_only"))
00296 ROS_WARN("TebLocalPlannerROS() Param Warning: 'costmap_obstacles_front_only' is deprecated. It is replaced by 'costmap_obstacles_behind_robot_dist' to define the actual area taken into account.");
00297
00298 if (nh.hasParam("costmap_emergency_stop_dist"))
00299 ROS_WARN("TebLocalPlannerROS() Param Warning: 'costmap_emergency_stop_dist' is deprecated. You can safely remove it from your parameter config.");
00300
00301 if (nh.hasParam("alternative_time_cost"))
00302 ROS_WARN("TebLocalPlannerROS() Param Warning: 'alternative_time_cost' is deprecated. It has been replaced by 'selection_alternative_time_cost'.");
00303 }
00304
00305
00306 }