0
$\begingroup$

Rosanswers logo

Hi, I am trying to use ROS navigation stack with RPlidar A2. currently, I am running gmapping with move_base and explore_lite so that robot can do auto-exploration and do SLAM. the problem is, even though I set allow_unkown to false in dwa_local_planner_params.yaml, the path generated by move_base is going through the unknown space (I also checked the value being false with rosparam get) Thank you for your help!

This is my costmap_common_parmas.yaml

obstacle_range: 2.5 #maximum obstale size
raytrace_range: 3.0 #robot will clear out space up to 3 meters 
footprint: [[-0.30,-0.177], [0.105,-0.177], [0.105, 0.177], [-0.30,0.177]] #not sure, from legacy
robot_radius: 0.2
inflation_radius: 0.3 #0.55

observation_sources: laser_scan_sensor 

laser_scan_sensor: {sensor_frame: laser_frame, data_type: LaserScan, topic: scan, marking: true, clearing: true}

This is my global_costmap.yaml

global_costmap:
  global_frame: map
  robot_base_frame: base_link
  update_frequency: 5.0

This is my local_costmap_params.yaml

local_costmap:
  global_frame: odom # NEW!! odom
  robot_base_frame: base_link
  update_frequency: 5.0
  publish_frequency: 2.0
  static_map: false
  rolling_window: true # will remain centered around the robot as the robot moves around
  width: 5.0 #meters
  height: 5.0
  resolution: 0.01 #tend to set them equally as the static map
  static_map: true #if we use map_sever, keep it true

and I am using dwa_local_planner and A* for global_planner.

EDIT

After accepting the answer, I worked on properly setting the costmap yaml files and now it works properly. I have played with 'track_unkown_space' param and I decided to set them like these. These are the files I have written.

common_costmap.yaml

obstacle_range: 2.5 #maximum obstale size
raytrace_range: 3.0 #robot will clear out space up to 3 meters 
footprint: [[-0.30,-0.177], [0.105,-0.177], [0.105, 0.177], [-0.30,0.177]] #not sure, from legacy
robot_radius: 0.2
inflation_radius: 0.3 #0.55

global_costmap.yaml (here, I set 'track_unkown_space' to true, since I wanted A* planner to only plan in known & free space) - make sure you load these in move_base.xml file with namespace global_costmap.

global_frame: map
robot_base_frame: base_link
update_frequency: 3.0
publish_frequency: 2.0
static_map: true #if we use map_sever, keep it true
  
  # obstacle_layer: {enabled: true, lethal_cost_threshold: 100, track_unknown_space: true, unknown_cost_value: -1}

  # static_layer: {enabled: true, lethal_cost_threshold: 100, track_unknown_space: true, unknown_cost_value: -1} 

plugins:
- {name: static_layer, type: "costmap_2d::StaticLayer"} 
- {name: obstacle_layer, type: "costmap_2d::ObstacleLayer"}
- {name: inflation_layer, type: "costmap_2d::InflationLayer"}

static_layer:
  unknown_cost_value: 0 # default: 0
  lethal_cost_threshold: 100 # default: 100
  map_topic: map # default: "map"

obstacle_layer:
  combination_method: 1 #default 1, meaning we will combine the layers
  observation_sources: laser_scan_sensor
  track_unknown_space: true
  map_type: costmap
  laser_scan_sensor:
    sensor_frame: laser_frame                 # default: ""
    topic: scan               # or /scan?
    data_type: LaserScan                # default: "PointCloud"
    marking: true                       # default: true
    clearing: true                      # default: false

inflation_layer:
  inflation_radius: 0.45 # default: 0.55

local_costmap.yaml (here, I set 'track_unknown_space' to false, since DWA planner works fine with this param being false.) I got this idea from this link text

global_frame: map # NEW!! odom
robot_base_frame: base_link
update_frequency: 5.0
publish_frequency: 2.0
static_map: false
rolling_window: true # will remain centered around the robot as the robot moves around
width: 5.0 #meters
height: 5.0
resolution: 0.01 #tend to set them equally as the static map

plugins: 
- {name: obstacle_layer, type: "costmap_2d::ObstacleLayer"}
- {name: inflation_layer, type: "costmap_2d::InflationLayer"}

obstacle_layer:
  combination_method: 1
  observation_sources: laser_scan_sensor
  track_unknown_space: false
  map_type: costmap
  laser_scan_sensor:
    sensor_frame: laser_frame                 # default: ""
    topic: scan               # or /scan?
    data_type: LaserScan                # default: "PointCloud"
    marking: true                       # default: true
    clearing: true                      # default: false

inflation_layer:
  inflation_radius: 0.45 # default: 0.55

EDIT 2 I just wanted to say that explore_lite won't work with this setting as explore_lite sets unkown area as goals. If I set the allow_unkown to true, so that I could use explore_lite, the path generated wasn't appropriate as you can see in the picture. However, the above setting with costmap layers works great with general navigation stack when given goals in know & free space, so I am trying to find exploration method that works with only known&free move_base goal. image description


Originally posted by So Young on ROS Answers with karma: 118 on 2021-01-12

Post score: 1


Original comments

Comment by So Young on 2021-01-12:
I've seen some posts about setting track_unknown_space to true, but since my costmap doesn't have layers, I thought wouldn't need to worry about that parameter. (or maybe I'm understanding it wrong)

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

As you may have seen, the documentation for global_planner states:

~<name>/allow_unknown (bool, default: true)
    Specifies whether or not to allow the planner to create plans that traverse unknown space. NOTE: if you are using a layered costmap_2d costmap with a voxel or obstacle layer, you must also set the track_unknown_space param for that layer to be true, or it will convert all your unknown space to free space (which planner will then happily go right through)

What you may have missed is that your cost map does contain layers, even when defined with pre-Hydro parameters. From the costmap_2d wiki:

Pre-Hydro Parameters

Hydro and later releases use plugins for all costmap_2d layers. If you don't provide a plugins parameter then the initialization code will assume that your configuration is pre-Hydro and will load a default set of plugins with default namespaces. Your parameters will be moved to the new namespaces automagically. The default namespaces are static_layer, obstacle_layer and inflation_layer. Some tutorials (and books) still refer to pre-Hydro parameters, so pay close attention. To be safe, be sure to provide a plugins parameter.

Therefore, it seems you'll still need to set track_unknown_space to true in the obstacle_layer namespace.


Originally posted by tryan with karma: 1421 on 2021-01-13

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by So Young on 2021-01-13:
Thank you, yes I didn't know my costmap had default layers. I'll try to set them properly and also set track_unkown_space and see if it works!

Comment by So Young on 2021-01-13:
Thank you for helping me with this problem, I have fixed the costmap yamls and now it works properly. I have also edited my post. Thanks!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.