1.需要修改./src/navigation-full/turtlebot_apps/turtlebot_navigation/param/costmap_common_params.yaml文件。模仿obstaclelayer,增加一个ultrasoniclayer,定义如下.
ultrasonic_layer:
enabled: true
max_obstacle_height: 1.0
origin_z: 0.0
z_resolution: 0.2
z_voxels: 6
unknown_threshold: 15
mark_threshold: 0
combination_method: 1
track_unknown_space: true #true needed for disabling globalpath planning through unknown space
obstacle_range: 1.0
raytrace_range: 3.0
publish_voxel_map: false
observation_sources: ultrasonic
ultrasonic:
data_type: LaserScan
topic: ultrasonic_scan
marking: true
clearing: true
min_obstacle_height: 0.05
max_obstacle_height: 1.0
2. 将这个layer加入到localcostmap里面。
修改./src/navigation-full/turtlebot_apps/turtlebot_navigation/param/local_costmap_params.yaml:
local_costmap:
global_frame: odom
robot_base_frame: /base_footprint
update_frequency: 40.0//这个是将各个layer数据综合处理的频率。这直接影响到传感器检测到的数据反应到地图中的速度。也影响到了机器人对传感器数据的感知速度
publish_frequency: 16.0 //这个是将costmap地图数据发送出去给rviz的频率
static_map: false
rolling_window: true
width: 4.0 //local cost map的直径4m
height: 4.0
resolution: 0.05 //local cost map是一个格子地图,每个格子对应5cm.
transform_tolerance: 0.5
plugins:
- {name: obstacle_layer, type: "costmap_2d::VoxelLayer"}
- {name: xtion_layer, type: "costmap_2d::VoxelLayer"}
- {name: ultrasonic_layer, type: "costmap_2d::VoxelLayer"} //我们的超声波地图数据
- {name: inflation_layer, type: "costmap_2d::InflationLayer"}//inflation负责给所有的障碍物数据周围膨胀出一定的范围,避免机器人把一个很狭小的空间当作通道