What frame to use when adding range_sensor_layer (sonar) to costmap
I am trying to add a sonar layer into my costmap to detect obstacles. I have used the rangesensorlayer (which is a costmap plugin) for this purpose. I have added the sonar layer parameters properly in globalcostmapparams, localcostmapparams and costmapcommonparams. Now, when I run Rviz, the sonar layer is not showing up. When I try to add it manually by selecting the relevant topic (/sonar), it shows an error about Frame. It says that the frame does not exist. I have seen the message from laser scan which is using frameid : camerdepthimage. I want to know what frameid should I use in the sonar's message which should already exist and upon which the sonar message will be broadcast. (I am new to frames in ros). Thanks
Asked by b2meer on 2016-01-13 06:16:38 UTC
Answers
The frame_id of your sonar message should match the name of the link you have given the sensor in the urdf, e.g.
if your robot.urdf has this link for your sensor:
<link name="sonar_backward">
<visual>
<geometry>
<box size="0.016 0.044 0.02"/>
</geometry>
<origin xyz="${0.016/2} 0 0" rpy="0 0 0"/>
<material name="green">
<color rgba="0 1 0 0.8"/>
</material>
</visual>
</link>
then your message should have set msg.header.frame_id="sonar_backward". Of course this also requires a running joint_state_publisher that publishes the corresponding joints.
Next you need to check your tf tree contains a valid path from your Fixed Frame in rviz (usually odom or map) to your sensor (sonar_backward).
Asked by Humpelstilzchen on 2016-01-14 07:26:31 UTC
Comments
Thanks for the solution. I am a little bit confused here as I am new to ros especially with urdf and tf. I am trying to use this sonar on turtlebot. Now, I am not sure how and where to add the link for sonar in the urdf file. It already has a seperate urdf file for its 3D Kinect Sensor.
Asked by b2meer on 2016-01-15 05:19:48 UTC
Usually you have an urdf that represents your complete robot. The Kinect and Sonar sensors are part of your robot, so they are part of the urdf, see the Tutorial
Asked by Humpelstilzchen on 2016-01-15 07:00:28 UTC
Alright. Thankyou very much. I am looking into it now. I am assuming that this is the last step to make it work. Could you please look into my next answer and check if I am also missing any thing else also in addition to the urdf step.
Asked by b2meer on 2016-01-15 08:46:15 UTC
I have already done the following steps in order to make sonar layer working in costmap.
Having arduino publishing data on topic '/sonar'
Downloaded range sensor plugin from https://github.com/DLu/navigation_layers.git, catkin make and copied the librange_sensor_layer.so and /include/range_sensor_layer (folder) to /ros/indigo/lib and /ros/indigo/include/ respectively
Added the range sensor plugin in local_costmap_params.yaml and global_costmap_params.yaml as : {name: sonar_layer, type: "range_sensor_layer::RangeSensorLayer"} and in common_costmap_params.yaml defined it as: sonar_layer: topics: ["/sonar"] no_readings_timeout: 1.0
Question.1: As you have seen that I have already added the plugin for range sensor layer, but when I run amcl, it lists one by one each layer like 'Using obstacle_layer, Using static_layer' etc, but does not show the message for Using sonar_layer. Will it be corrected after I update the urdf file with an entry for sonar layer or is it related to something else.
Question.2: To make the sonar layer update the costmap, is there any other step in addition to above 3 which I maybe missing (assuming the urdf step is also done since I am working on it now)
Asked by b2meer on 2016-01-15 08:46:33 UTC
Comments
I think you should open a new question for that, because its getting confusing.
- amcl can not use the range sensor as it requires accurate obstacle information.
- Why did you copy the files manually?
- With these changes the values from your range sensor should be in your obstacle layer
Asked by Humpelstilzchen on 2016-01-15 11:26:04 UTC
- I want that when my robot moves, it should also avoid obstacles detected by sonar
- I copied files manually since they are not present by default in ros folder
- The values from sonar layer are not showing Rviz, it only shows a dummy cone for sonar and no obstacles are detected by it.
Asked by b2meer on 2016-01-16 13:14:06 UTC
Comments