Ask Your Question
0

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

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

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
2

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

JohnDoe2991 gravatar image

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

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:

model.config

<?xml version="1.0"?>

<model>
  <name>myModel</name>
  <version>1.0</version>

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


  <author>
    <name>me</name>
    <email>dontcare</email>
  </author>

  <description>
    my 3d model
  </description>
</model>

model.sdf

<?xml version="1.0" ?>
<sdf version="1.4">
  <model name="myModel">    
    <link name="link"> 
      <inertial>
        <mass>5</mass>
        <inertia> 0.0 0.0 0.0 0.0 0.0 0.0 </inertia>
      </inertial>
      <visual name="visual">
      <pose>0 0 0 0 0 0</pose>
        <geometry>
          <mesh>
            <uri>file:///path/to/your/mesh.STL</uri>
            <scale>1 1 1</scale>
          </mesh>
        </geometry>
      </visual>

      <collision name="collision">
      <pose>0 0 0 0 0 0</pose>
        <geometry>
          <mesh>
            <uri>file:///path/to/your/mesh.STL</uri>
            <scale>1 1 1</scale>
          </mesh>
        </geometry>
      </collision>
    </link>
  </model>
</sdf>

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

edit flag offensive delete link more

Comments

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 imageswethmandava ( 2016-05-11 00:38:47 -0600 )edit

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

swethmandava gravatar imageswethmandava ( 2016-05-12 06:39:33 -0600 )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 imageJohnDoe2991 ( 2016-05-12 07:45:17 -0600 )edit

@JohnDoe2991 I also had to add the plugin to get the entry on rviz. http://www.generationrobots.com/en/co... this helped me.

swethmandava gravatar imageswethmandava ( 2016-05-19 07:13:37 -0600 )edit

Question Tools

1 follower

Stats

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

Seen: 540 times

Last updated: May 12 '16