Rosanswers logo

I have camera poses to fully inspect a 3D structure. I would like to test this using a camera model and mark the fov by something in order to measure the coverage. Is there any way I can do this?

Originally posted by swethmandava on ROS Answers with karma: 102 on 2016-05-10

Post score: 0


1 Answer 1


Rosanswers logo

There is a camera model for Gazebo. You can simply add it to your simulation and the corresponding image will be published as a ROS topic. If you want to change the FOV or framerate, you can edit the corresponding model.sdf in ~/.gazebo/models/camera

Edit: I'm using ROS Indigo, so the following may vary if you use a different version. You first need to add your 3D model to gazebo. Your 3D model must either be a STL or Collada file. Go to ~/.gazebo/models/ and create a folder "yourModel". Create two files:


<?xml version="1.0"?>


  <sdf version="1.4">model.sdf</sdf>


    my 3d model


<?xml version="1.0" ?>
<sdf version="1.4">
  <model name="myModel">    
    <link name="link"> 
        <inertia> 0.0 0.0 0.0 0.0 0.0 0.0 </inertia>
      <visual name="visual">
      <pose>0 0 0 0 0 0</pose>
            <scale>1 1 1</scale>

      <collision name="collision">
      <pose>0 0 0 0 0 0</pose>
            <scale>1 1 1</scale>

Edit the file correspondingly where necessary.

First you need to start a roscore. Open a terminal and enter "roscore".

Now open a second terminal an start Gazebo with the command "rosrun gazebo_ros gazebo"

The gazebo window should open now. First set the gravity to zero (this makes handling the models easier, because they can float without gravity). To do that, click on the left panel on "Physics" and below on gravity and set the z-value to "0.00".

Now switch to the "insert" tab, there should be your "myModel" model listed. Click on it and place it somewhere in the window. If nothing appears, there should be an error message in the terminal window, where you started gazebo. If everything worked right, your model should appear. You can move and rotate it however you want.

To add the camera go again to the "insert" tab and select "http://gazebosim.org/models". There should be a Camera model. You can place it where ever you want. As soon as you placed it once, you can edit the resolution, FOV, framerate of the camera in the "~/gazebo/models/camera/model.sdf" file. You need to insert the camera again, that the changes to the model.sdf file take effect.

To visualize the camera image, open a third terminal and enter "rviz". In this app, click the button "add" in the left bottom corner, switch to the "by topic" tab and select the camera image. Now you can see what the camera sees in your simulation.

image topic in rviz

Originally posted by JohnDoe2991 with karma: 305 on 2016-05-11

This answer was ACCEPTED on the original site

Post score: 2

Original comments

Comment by swethmandava on 2016-05-11:
Thanks @JohnDoe2991 I have never worked on Gazebo, I have a couple of doubts. can I move the camera model around and get images from all pose positions? And how do i compare the corresponding images to the 3D model being inspected to make sure the entire surface area is covered?

Comment by swethmandava on 2016-05-12:
Hey thanks for the edit. I'm trying to follow your steps but can't find the camera image on rviz.

Comment by JohnDoe2991 on 2016-05-12:
I added an image of rviz's "add" menue. Let me know, if this entry doesn't show up. Maybe I made some special changes to my camera model that I cannot remember.

Comment by swethmandava on 2016-05-19:
@JohnDoe2991 I also had to add the plugin to get the entry on rviz. http://www.generationrobots.com/en/content/75-gazebo-and-ros this helped me.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.