ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
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
2 | No.2 Revision |
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.
3 | No.3 Revision |
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.