An example configuration. Assuming you have, let's say, 3 sonars publishing sensor_msgs/Range messages on /mobile_base/sensors/sonars/sonar1, /mobile_base/sensors/sonars/sonar2 and /mobile_base/sensors/sonars/sonar3:
costmap_common_params.yaml
robot_radius: 0.18
inflation_layer:
...
obstacle_layer:
...
range_sensor_layer:
clear_threshold: 0.46
mark_threshold: 0.98
no_readings_timeout: 2.0
ns: /mobile_base/sensors/sonars
topics: ["sonar1", "sonar2", "sonar3"]
and in local_costmap_params.yaml (and global_costmap_params.yaml, if you want to use the sonars also in the global costmap):
...
plugins:
- {name: range_sensor_layer, type: "range_sensor_layer::RangeSensorLayer"}
.... # any other plugins you use, typically:
- {name: obstacle_layer, type: "costmap_2d::VoxelLayer"}
- {name: inflation_layer, type: "costmap_2d::InflationLayer"}
- {name: footprint_layer, type: "costmap_2d::FootprintLayer"}
Hope this helps.