ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Display sonar datapoints in rviz for amcl

asked 2020-12-11 02:46:20 -0500

rool12 gravatar image

updated 2020-12-11 08:16:14 -0500

Hey guys!

I would like some help with my problem. I've a project where I use a front and a side sonar to locate a mobile robot in a known environment (in combination with relative measurement sensors). For this I made a gazebo simulation and made a link to rviz, what is working good (the sonar beam is displaying). Now I'm stuck for some time with localization of the robot in rviz. I would like to use the range_sensor_layer to display data point(s) of a (known) obstacle, and to localize the robot like here or here. When I add a laser scanner, the visualization works good and as expected, but I want to do the same with a sonar.

TLDR: range_sensor_layer doesn't give me data points in rviz (something I was expecting).

costmap_common_params.yaml:

map_type: costmap

footprint: [[0.25, 0.25], [0.25,-0.25], [-0.25,-0.25], [-0.25,0.25]]

inflation_layer:   
  inflation_radius: 0.3

obstacle_layer:
  obstacle_range: 2.5
  raytrace_range: 3.0 

sonar_layer:   
  nr: /sonar
  topics: ["/sonar_front", "/sonar_side"]
  no_readings_timeout: 1.0
  clear_threshold: 0.2
  mark_threshold: 0.8

local_costmap_params.yaml:

local_costmap:    
  global_frame: odom  
  robot_base_frame: robot_footprint

  update_frequency: 1.0   
  publish_frequency: 1.0    
  width: 20.0 
  height: 20.0    
  resolution: 0.05   
  static_map: false    
  rolling_window: true

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

global_costmap_params.yaml:

global_costmap:   
  global_frame: map   
  robot_base_frame: robot_footprint

  update_frequency: 10.0
  publish_frequency: 10.0    
  width: 40.0    
  height: 40.0   
  resolution: 0.05    
  static_map: true    
  rolling_window: false

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

I hope this gives enough information! If I'm not clear or need to add more information, please tell me. Thank you in advance.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2020-12-11 07:48:16 -0500

Dragonslayer gravatar image

updated 2020-12-11 07:54:17 -0500

First, is this really your formating in the yaml files? There should be indentations. Then i miss definition like the API discribes (http://wiki.ros.org/range_sensor_layer), its not the same as laser scan, similar:

  sonar_layer:
    topics: ["/sonar"]
    no_readings_timeout: 1.0

Further I would look at this posts, -> post ->link text

edit flag offensive delete link more

Comments

Thanks for answering! Due to copying and pasting the .yaml documents to the forum, the whole layout changed. I also added some parameters for the sonar_layer. I edited my original post with my current configuration. Unfortunately it did not give me anymore information in rviz (it is true that I should see a datapoint of the sonar on the obstacle at all?). /sonar/sonar_front and /sonar/sonar_side are given values when I echo those based on my simulation in gazebo, and I can see the range cone in rviz. I can't get it connected with amcl unfortunately ... Do I need to add something for this sonar to the amcl launch-file? Thanks!

rool12 gravatar image rool12  ( 2020-12-11 08:55:46 -0500 )edit
1

Sonar usually isnt used with amcl. amcl is made for 360° 2d laserscans and a map. For this approach sonar has much to little datapoints and sonar is noisy. In the navigation stack its just used for move_base to detect obstacles in the local_costmap. I have seen the obstacle layer given to global_costmap as well though, but I dont see a good reason for this, and it still only relates to move_base. amcl doesnt see the costmaps but only the mapservers /map (might be updateable though) and "compares" to /laserscan. You should see obstacles in the local_costmap visualization in rviz, thats where the interpreted sonar data is published.

Dragonslayer gravatar image Dragonslayer  ( 2020-12-13 06:52:40 -0500 )edit

Ah alright, thanks for explaining it to me better. I am using a premade/preknown map, and this sonar_layer doesn't add anything even to the costmap. I expected a change in the local costmap when a obstacle is detected, just like here, but it doesn't add something to the local costmap unfortunately. This while it is detecting a object when I echo the side or front sonar, and it is visualizing the cone rangedata in Rviz.

rool12 gravatar image rool12  ( 2020-12-13 14:30:09 -0500 )edit

I once red that the listing of layers can mess the costmap up. You could try 1. obstacle_layer 2. sonar_layer 3. inflation_layer. You might also check rostopic for spelling errors in the topics and/or namespaces. Maybe costmap is looking for a /sonar in his own namespace or something like that (/local_costmap/sonar?). And of course the sonar might be timing out, ultrasonics are usually working at low update frequency, rviz is more flexible. Checked the logs?

Dragonslayer gravatar image Dragonslayer  ( 2020-12-15 09:33:26 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2020-12-11 02:46:20 -0500

Seen: 303 times

Last updated: Dec 11 '20