Display sonar datapoints in rviz for amcl
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 rangesensorlayer 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: rangesensorlayer doesn't give me data points in rviz (something I was expecting).
costmapcommonparams.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
localcostmapparams.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"}
globalcostmapparams.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.
Asked by rool12 on 2020-12-11 03:46:20 UTC
Answers
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
Asked by Dragonslayer on 2020-12-11 08:48:16 UTC
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!
Asked by rool12 on 2020-12-11 09:55:46 UTC
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.
Asked by Dragonslayer on 2020-12-13 07:52:40 UTC
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.
Asked by rool12 on 2020-12-13 15:30:09 UTC
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?
Asked by Dragonslayer on 2020-12-15 10:33:26 UTC
Comments