Home | Tutorials | Wiki | Issues
Ask Your Question
0

Multiple instances of same sensor publishing to same topic

asked 2020-01-07 03:08:46 -0500

wongrufus gravatar image

updated 2020-01-07 20:44:00 -0500

I have my simulated depth sensor configured as follows

model.sdf

    ...
    <plugin name="camera_plugin" filename="libgazebo_ros_openni_kinect.so">
      <baseline>0.2</baseline>
      <alwaysOn>true</alwaysOn>
      <!-- Keep this zero, update_rate in the parent <sensor> tag
        will control the frame rate. -->
      <updateRate>0.0</updateRate>
      <cameraName>camera_ir</cameraName>
      <imageTopicName>/camera/color/image_raw</imageTopicName>
      <cameraInfoTopicName>/camera/color/camera_info</cameraInfoTopicName>
      <depthImageTopicName>/camera/depth/image_raw</depthImageTopicName>
      <depthImageCameraInfoTopicName>/camera/depth/camera_info</depthImageCameraInfoTopicName>
      <pointCloudTopicName>/camera/depth/points</pointCloudTopicName>
      <frameName>camera_frame</frameName>
      <pointCloudCutoff>0.5</pointCloudCutoff>
      <pointCloudCutoffMax>3.0</pointCloudCutoffMax>
      <distortionK1>0</distortionK1>
      <distortionK2>0</distortionK2>
      <distortionK3>0</distortionK3>
      <distortionT1>0</distortionT1>
      <distortionT2>0</distortionT2>
      <CxPrime>0</CxPrime>
      <Cx>0</Cx>
      <Cy>0</Cy>
      <focalLength>0</focalLength>
      <hackBaseline>0</hackBaseline>
    </plugin>
    </sensor>
    </link>
  </model>
</sdf>

Whenever I have more than 1 sensor in my gazebo world (created through the Insert tab in the gazebo GUI), the topics published by the sensors get mixed together and the following error message appears:

I've tried adding a robotNamespace for the plugin but that does not solve the problem, the same problem persists, just with the same robotNamespace added in front of all the topics.

This answer that says using an empty robotnamespace doesn't seem to work.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-01-09 01:48:24 -0500

wongrufus gravatar image

updated 2020-01-09 01:49:51 -0500

The key is to not use global names for all names

      <imageTopicName>camera/color/image_raw</imageTopicName>
      <cameraInfoTopicName>camera/color/camera_info</cameraInfoTopicName>
      <depthImageTopicName>camera/depth/image_raw</depthImageTopicName>
      <depthImageCameraInfoTopicName>camera/depth/camera_info</depthImageCameraInfoTopicName>
      <pointCloudTopicName>camera/depth/points</pointCloudTopicName>
      <frameName>camera_frame</frameName>

(Notice the starting / removed)

And follow the instructions here of setting up the group namespace and tf prefix.

Something along the followings in the launch file will do:

<param name="robot_description_sdf" textfile="kinect/model.sdf"/>

<group ns="kinect1">
    <param name="tf_prefix" value="kinect1_tf" />
    <node pkg="gazebo_ros" type="spawn_model" name="spawn_sdf" args="-sdf -param /robot_description_sdf -model kinect1 -x -3 -y 0 -z 1" />
</group>

<group ns="kinect2">
    <param name="tf_prefix" value="kinect2_tf" />
    <node pkg="gazebo_ros" type="spawn_model" name="spawn_sdf" args="-sdf -param /robot_description_sdf -model kinect2 -x -3 -y 1 -z 1" />
</group>
edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2020-01-07 03:08:46 -0500

Seen: 95 times

Last updated: Jan 09