一.安裝teb_local_planner算法
源码下载地址:GitHub - rst-tu-dortmund/teb_local_planner: An optimal trajectory planner considering distinctive topologies for mobile robots based on Timed-Elastic-Bands (ROS Package)
注意选择对应ROS版本的代码。
放在navigation目录下(或者自己创建一个):
安装缺失依赖:
rosdep install teb_local_planner
在src当前目录下运行:
rosdep install --from-paths src --ignore-src --rosdistro=<ros_version> -y
编译:
catkin_make -DCATKIN_WHITELIST_PACKAGES="teb_local_planner"
在编译过程中会出现缺包,对应安装就好了。
查看是否安装成功:
rospack plugins --attrib=plugin nav_core
会出现以下相关信息:
teb_local_planner /home/catkin_navigation/src/navigation/teb_local_planner-melodic-devel/teb_local_planner_plugin.xml
测试:
roslaunch teb_local_planner test_optim_node.launch
二.teb替代DWA算法
move_base.launch文件中添加teb配置内容:
<launch><!-- Arguments --><arg name="model" default="$(env TURTLEBOT3_MODEL)" doc="model type [burger, waffle, waffle_pi]"/><arg name="cmd_vel_topic" default="/cmd_vel" /><arg name="odom_topic" default="odom" /><arg name="move_forward_only" default="false"/><!--true机器人只能向前运动--><!-- move_base --><node pkg="move_base" type="move_base" respawn="false" name="move_base" output="screen"><!--加载Dijkstra、A star算法--><param name="base_global_planner" value="global_planner/GlobalPlanner"/><param name="planner_frequency" value="1.0" /><param name="planner_patience" value="5.0" /><!--加载DWA算法<param name="base_local_planner" value="dwa_local_planner/DWAPlannerROS" />--><!--加载TEB算法--><param name="base_local_planner" value="teb_local_planner/TebLocalPlannerROS" /><!--配置文件--><rosparam file="$(find turtlebot3_navigation)/param/costmap_common_params_$(arg model).yaml" command="load" ns="global_costmap" /><rosparam file="$(find turtlebot3_navigation)/param/costmap_common_params_$(arg model).yaml" command="load" ns="local_costmap" /><rosparam file="$(find turtlebot3_navigation)/param/local_costmap_params.yaml" command="load" /><rosparam file="$(find turtlebot3_navigation)/param/global_costmap_params.yaml" command="load" /><rosparam file="$(find turtlebot3_navigation)/param/move_base_params.yaml" command="load" /><!--DWA配置文件--><rosparam file="$(find turtlebot3_navigation)/param/dwa_local_planner_params_$(arg model).yaml" command="load" /><!--TEB配置文件--><rosparam file="$(find turtlebot3_navigation)/param/teb_local_planner_params.yaml" command="load" /><remap from="cmd_vel" to="$(arg cmd_vel_topic)"/><remap from="odom" to="$(arg odom_topic)"/><param name="DWAPlannerROS/min_vel_x" value="0.0" if="$(arg move_forward_only)" /></node>
</launch>
在turtlebot3_navigation/param文件夹下创建teb_local_planner_params.yaml文件:
TebLocalPlannerROS:odom_topic: odommap_frame: map# Trajectoryteb_autosize: Truedt_ref: 0.5dt_hysteresis: 0.05min_samples: 3global_plan_overwrite_orientation: Trueglobal_plan_viapoint_sep: 0.1 # negative, do not use viapoints. positive, use them. the actual value does not mattermax_global_plan_lookahead_dist: 1.5global_plan_prune_distance: 0.6force_reinit_new_goal_dist: 1.0feasibility_check_no_poses: 3publish_feedback: falseallow_init_with_backwards_motion: trueexact_arc_length: falseshrink_horizon_backup: trueshrink_horizon_min_duration: 10# Robotmax_vel_x: 0.22max_vel_x_backwards: 0.5max_vel_theta: 2.75max_vel_y: 0.0acc_lim_y: 0.0acc_lim_x: 2.5acc_lim_theta: 3.2min_turning_radius: 0.0wheelbase: 0.0 # not used, is differentialcmd_angle_instead_rotvel: false # not used, is differentialfootprint_model: # types: "point", "circular", "two_circles", "line", "polygon"
# type: "circular"
# radius: 0.5 # for type "circular"
# type: "line"
# line_start: [-0.0545, 0.0] # for type "line"
# line_end: [0.0545, 0.0] # for type "line"
# front_offset: 0.2 # for type "two_circles"
# front_radius: 0.2 # for type "two_circles"
# rear_offset: 0.2 # for type "two_circles"
# rear_radius: 0.2 # for type "two_circles"type: "polygon"vertices: [[-0.105, -0.105], [-0.105, 0.105], [0.041, 0.105], [0.041, -0.105]] # for type "polygon"# GoalTolerancexy_goal_tolerance: 0.05yaw_goal_tolerance: 0.17free_goal_vel: False# Obstaclesmin_obstacle_dist: 0.1 # minimum distance to obstacle: it depends on the footprint_modelinflation_dist: 0.0 # greater than min_obstacle_dist to take effectinclude_costmap_obstacles: True # use the local costmapcostmap_obstacles_behind_robot_dist: 1.0 # distance at which obstacles behind the robot are taken into accountlegacy_obstacle_association: falseobstacle_poses_affected: 30 # unused if legacy_obstacle_association is falseobstacle_association_force_inclusion_factor: 10.0 # the obstacles that will be taken into account are those closer than min_obstacle_dist*factor, if legacy is falseobstacle_association_cutoff_factor: 40.0 # the obstacles that are further than min_obstacle_dist * factor will not be taken into account, if legacy is false
# costmap_converter_plugin: "costmap_converter::CostmapToPolygonsDBSMCCH"#costmap_converter_plugin: "costmap_converter::CostmapToLinesDBSRANSAC"#costmap_converter_plugin: "costmap_converter::CostmapToLinesDBSMCCH"
# costmap_converter_plugin: "costmap_converter::CostmapToPolygonsDBSConcaveHull"costmap_converter_plugin: "" # deactivate plugincostmap_converter_spin_thread: Truecostmap_converter_rate: 10# Optimizationno_inner_iterations: 5no_outer_iterations: 4optimization_activate: True # optimizeoptimization_verbose: Falsepenalty_epsilon: 0.1weight_max_vel_x: 2weight_max_vel_y: 1weight_max_vel_theta: 1weight_acc_lim_x: 1weight_acc_lim_y: 1weight_acc_lim_theta: 1weight_kinematics_nh: 1 # is a holonomic robotweight_kinematics_forward_drive: 10 # prefer forward driving, for differentialweight_kinematics_turning_radius: 0 # prefer turns that respect the min_turning_radius, not used if differential (min_turning_radius = 0)weight_optimaltime: 1.0 # prefer trajectories with less transition timeweight_obstacle: 50.0 # prefer trajectories that respect the min_obstacle_distweight_inflation: 0.1 # prefer trajectories that respect the inflation of the obstacles#weight_dynamic_obstacle: 10 # not in use yetweight_viapoint: 1.0 # prefer trajectories that respect the viapoints in the global pathweight_adapt_factor: 2 # factor to multiply some weights (currently only weight_obstacle) at each iteration (gives better results than a huge value for the weight)# Homotopy Class Plannerenable_homotopy_class_planning: True # currently not used
效果展示:
参考:【ROS】Turtlebot3局部避障TEB算法配置_move_base三维导航_RockWang.的博客-CSDN博客