Ask Your Question

How can I simulate a camera model for software testing? [closed]

asked 2016-05-10 22:10:35 -0500

swethmandava gravatar image

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?

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by swethmandava
close date 2016-12-14 10:55:56.596373

1 Answer

Sort by ยป oldest newest most voted

answered 2016-05-11 00:18:50 -0500

JohnDoe2991 gravatar image

updated 2016-05-12 07:43:26 -0500

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 "". 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

edit flag offensive delete link more


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?

swethmandava gravatar image swethmandava  ( 2016-05-11 00:38:47 -0500 )edit

Hey thanks for the edit. I'm trying to follow your steps but can't find the camera image on rviz.

swethmandava gravatar image swethmandava  ( 2016-05-12 06:39:33 -0500 )edit

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.

JohnDoe2991 gravatar image JohnDoe2991  ( 2016-05-12 07:45:17 -0500 )edit

@JohnDoe2991 I also had to add the plugin to get the entry on rviz. this helped me.

swethmandava gravatar image swethmandava  ( 2016-05-19 07:13:37 -0500 )edit

Question Tools

1 follower


Asked: 2016-05-10 22:10:35 -0500

Seen: 897 times

Last updated: May 12 '16