Let's begin with the common parameters. First of all, we will create a file with the name costmap_common_params.yaml in chapter6_tutorials/launch and add the following code (refer to GitHub for more information https://github.com/kbipin/Robot-Operating-System-Cookbook/blob/master/chapter7_tutorials/launch/costmap_common_params.yaml):
obstacle_range: 2.5
raytrace_range: 3.0
footprint: [[-0.2,-0.2],[-0.2,0.2], [0.2, 0.2], [0.2,-0.2]]
#robot_radius: ir_of_robot
inflation_radius: 0.5
cost_scaling_factor: 10.0
observation_sources: scan
scan: {sensor_frame: base_link, observation_persistence: 0.0, max_obstacle_height: 0.4, min_obstacle_height: 0.0, data_type: LaserScan, topic: /scan, marking: true, clearing: true}
The preceding file is used to configure the common parameters that are used in both local_costmap and global_costmap.
The obstacle_range and raytrace_range attributes are used to define the maximum distance reading for a sensor that can add new information in the costmaps. The footprint attribute is used to define the geometry of the robot for the navigation stack. Moreover, the cost_scaling_factor attribute defines the behavior of the robot around the obstacles, aggressive or conservative.
Similarly, the observation_sources attribute is used to set the sensors used by the navigation stack to perceive the real world.
However, we are using a simulated laser in Gazebo in our case, but we can also use a point cloud here:
{sensor_frame: base_link, observation_persistence: 0.0, max_obstacle_height: 0.4, min_obstacle_height: 0.0, data_type: LaserScan, topic: /scan, marking: true, clearing: true}
Where the laser is configured to add and clear obstacles in the costmap. We can also add a sensor with a wide range to find obstacles and another sensor to navigate and clear the obstacles. We can refer to the ROS navigation stack tutorials for more information.