Skip to main content

SDF template for cameras

SDFormat (SDF) can be used to create a camera within Flowstate. In the following template, important details are provided in the comments (i.e., <!-- this is a comment -->): i

<?xml version="1.0" ?>
<sdf version="1.11">
<model name="my_camera">
<link name="camera_link">
<visual name="camera_visual">
<geometry>
<!-- Can be a mesh or primitive shape; this example uses a mesh. -->
<mesh>
<uri>relative/path/to/mesh</uri>
</mesh>
</geometry>
</visual>
<collision name ="camera_collision">
<geometry>
<!-- Fill this section with a mesh or primitive shape;
this is used for motion planning and physics.
See http://sdformat.org/spec?ver=1.11&elem=geometry for
available types. -->
</geometry>
</collision>
</link>
<!-- A link named "sensor_link" is required for this to work in
the frontend. -->
<link name="sensor_link">
<!-- By default, the camera frustum is facing up. If the mesh of your
camera lens is not facing up, you'll need to update the sensor_link's
pose to match accordingly. In this example, the mesh lens is rotated
90 degrees in the y-direction. -->
<pose>0 0 0 0 1.5708 0</pose>
<sensor name="camera_sensor" type="camera">
<!-- Need to rotate sensor so that camera frame conforms to
Intrinsic's convention (z forward, x right, y down). -->
<pose>0 0 0 1.57079632679 -1.57079632679 0</pose>
<update_rate>10.0</update_rate>
<camera>
<image>
<!-- Look at the camera hardware specifications for the camera's
width and height. -->
<width>1936</width>
<height>1216</height>
</image>
<lens>
<intrinsics>
<!-- These intrinsics will be used for the camera type default
config. -->
<fx>1000</fx>
<fy>1000</fy>
<cx>968</cx>
<cy>608</cy>
</intrinsics>
</lens>
</camera>
</sensor>
</link>
<!-- Required joint that positions the camera and sensor links if
there are two links representing the visual + collision and sensor
link. -->
<joint name="camera_joint" type="fixed">
<parent>camera_link</parent>
<child>sensor_link</child>
</joint>
</model>
</sdf>

Note: Complex meshes with a large number of polygons will cause slow performance of the simulator when used as collision meshes. We recommend using either a simplified mesh or primitive shapes (e.g., box, sphere, cylinder) for collisions.

For a full example, download this FLIR blackfly zip.

Current limitations

  • Only supports one <include> and does not support nested <include>s.
  • The zip file used to create the SceneObject must only contain the SDF file and meshes. Zipping the directory that holds these two files will result in an error.