Home | Tutorials | Wiki | Issues
Ask Your Question
0

Kinect (in gazebo) not publishing topics

asked 2018-04-07 08:14:14 -0500

malhar gravatar image

Hi,

Update:

I have also tried rosrun gazebo --verbose and I get a warning - [Wrn] [msgs.cc:1655] Conversion of sensor type[depth] not suppported. I believe this may be due to <sensor name="camera" type="depth"> in XML below.

Question: I have been following this tutorial to simulate a Kinect in Gazebo and then publish image,pointcloud etc to ROS topics. However, rostopic list does not show the required topics in the output.

I have also looked at the following questions on this forum - this and this. The issue in the first one seems to be same as mine. The person suggested to use URDF files instead (which I will try but would still like to know why below approach is not working ).

Here is the relevant XML code for the model.sdf file in the kinect directory that I have modified according to the tutorial mentioned above -

  //some xml 

  <sensor name="camera" type="depth">
                    <alwaysOn>true</alwaysOn>
            <update_rate>20</update_rate>
            <camera>
              <horizontal_fov>1.047198</horizontal_fov>
              <image>
                <width>640</width>
                <height>480</height>
                <format>R8G8B8</format>
              </image>
              <clip>
                <near>0.05</near>
                <far>3</far>
              </clip>
            </camera>
                <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/depth/image_raw</imageTopicName>
              <cameraInfoTopicName>/camera/depth/camera_info</cameraInfoTopicName>
              <depthImageTopicName>/camera/depth/image_raw</depthImageTopicName>
              <depthImageInfoTopicName>/camera/depth/camera_info</depthImageInfoTopicName>
              <pointCloudTopicName>/camera/depth/points</pointCloudTopicName>
              <frameName>camera_link</frameName>
              <pointCloudCutoff>0.05</pointCloudCutoff>
              <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>

   // some more xml

I would like to mention the following -

  1. Note that in the XML code - The plugin is defined as a sensor plugin (I am aware that model and sensor plugins are different things in Gazebo and it can lead to an error if the right one is not used.)

  2. I have been using the command - roslaunch gazebo_ros empty_world.launch to open the world.I then manually add the kinect model shown above.

  3. I have also tried rosrun gazebo --verbose and I get a warning - [Wrn] [msgs.cc:1655] Conversion of sensor type[depth] not suppported.

  4. Also, output of rostopic list after launching gazebo and adding the kinect ( Sorry unable to format this as code for some reason ) -

    /clock /gazebo/link_states /gazebo/model_states /gazebo/parameter_descriptions /gazebo/parameter_updates /gazebo/set_link_state /gazebo/set_model_state /rosout /rosout_agg

  5. I have checked rostopic echo /clock , which means the Gazebo simulation is running. o I need to install that plugin libgazebo_ros_openni_kinect.so ? This seems more like an issue on the Gazebo side and hence I have posted here ( instead of ROS forum. )

Thanks a lot !

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2018-04-07 12:37:14 -0500

malhar gravatar image

updated 2018-04-09 15:24:41 -0500

I found the solution by some trial and error.

Update: What I did -

  1. Go to folder ~/.gazebo/models
  2. Make a copy of the ~/.gazebo/models/kinect folder (in the same directory ,ie ~/.gazebo/models ) and rename it as kinect_ros or whatever you want.
  3. As said in this tutorial, update the model.config and model.sdf file with the <name_from_step_2>.
  4. Open Gazebo and try adding the <name_from_step_2> model from the "Insert" tab ( If you can find it in the list )
  5. Assuming step 4 worked and you added the kinect into the Gazebo scene, try rostopic list (and the rest of the tutorial link mentioned above).
  6. If step 5 didnt work, then copy paste (as directed in the tutorial above, so after the closing </camera> tag) the <plugin> ... code from tutorial .. </plugin> code into all the model*.sdf files ( model.sdf, model-1_2.sdf, model-1_3.sdf , model-1_4.sdf ).
  7. Re-launch gazebo_ros and check rostopic or rviz for pointcloud.
  8. If step 7 also didnt work, I can only think of one last thing ( not 100% sure if this makes a difference but try to change this in all the model* files -

    <mesh><uri>model://<name_from_step_2>/meshes/kinect.dae</uri></mesh>

For some reason (probably due to the sdf version) I had to copy paste that plugin into all the model*.sdf files in the kinect folder. (or the duplicated one if you don't want to overwrite it). It works now like the tutorial describes.

edit flag offensive delete link more

Comments

I have exactly the same problem. Unfortunately, your solution doesn't work for me, I still see no camera topic with rostopic list. Even if I insert the Kinect-Model from gazebosim.org/models/ database (and not the one from the ~/.gazebo/models folder). I have also apt-get installed gazebo_ros_pkg, but I'm not quite sure how Gazebo/ROS finds & loads the libgazebo_ros_openni_kinect.so. Can you give me any additional information on how you did it (e.g. that you used a catkin ws etc.)? Thank you!

RedJohn gravatar imageRedJohn ( 2018-04-09 09:44:54 -0500 )edit

Hi, Just check the answer, I just updated it. And no, I didn't use a catkin_ws. Almost identical procedure as mentioned in the tutorial.

malhar gravatar imagemalhar ( 2018-04-09 15:16:36 -0500 )edit

Thank you for your updated answer. Unfortunately, something still doesn't work, because no matter what I do, I can't see the camera topics with rostopic list. What Gazebo/ROS version do you use? I have ROS Kinetic with Gazebo 7.0.0 on a Ubuntu 16.04 (in a VM on a Win10 PC).

RedJohn gravatar imageRedJohn ( 2018-04-12 02:53:53 -0500 )edit

Also, after inserting the Kinect, I get a new error/INFO log and my Gazebo chrashes: Camera Plugin: The 'robotNamespace' param did not exit gzserver: /build/ogre-1.9-mqY1wq/ogre-1.9-1.9.0+dfsg1/OgreMain/src/OgreRenderSystem.cpp:546: virtual void Ogre::RenderSystem::setDepthBufferFor(Ogre::RenderTarget*): Assertion `bAttached && "A new DepthBuffer for a RenderTarget was created, but after creation" "it says it's incompatible with that RT"' failed. The Conversion-warning is also still there.

RedJohn gravatar imageRedJohn ( 2018-04-12 03:02:23 -0500 )edit
1

answered 2018-04-12 04:35:10 -0500

RedJohn gravatar image

After almost 2 days of digging into this issue, I finally managed to get the kinect sensor in Gazebo publish its topics (and see the point cloud in rviz), horray!

I "just" had to upgrade my Gazebo 7.0.0 to 7.11 (follow the alternative step-by-step-installation here (you can do that even if you already have Gazebo & ROS installed). After that, following the tutorial and the answer from from malhar worked quite well.

If you have the same issue, please also check if you have installed the plugin packages and the gazebo_ros packages

sudo apt install ros-kinetic-gazebo-plugins ros-kinetic-gazebo-ros-pkgs ros-kinetic-gazebo-ros-control

in order to have the /opt/ros/kinetic/lib/libgazebo_ros_openni_kinect.so file and the gazebo-ros-bindings.

Just FYI: I'm running ROS Kinetic with Gazebo 7 (7.11) on Ubuntu 16.04 (on a VM with Oracle VM VirtualBox, which runs on a Win10 host). I got my solution from this site (quite at the bottom of the page). It seems there was a bug with Gazebo 7.0.0 inside VMs, which then got resolved in a later version of Gazebo 7. Other solutions I tried can be found here, here, here or here, in case my solution still doesn't solve your problem.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

3 followers

Stats

Asked: 2018-04-07 08:14:14 -0500

Seen: 77 times

Last updated: Apr 12