ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

If you're using glc-capture, one way to do this is to can write a plugin to move the cameras, for example, by putting this code in UpdateChild() of the plugin:

gazebo::OgreCamera *cam = gazebo::CameraManager::Instance()->GetCamera("UserCamera(0)");
gazebo::Pose3d pose = cam->GetCameraWorldPose();
pose.pos.z = pose.pos.z + 0.001;
cam->SetWorldPose(pose);

should make the gui view camera move upwards in z-direction 1mm on every udpate.

Alternatively, you can spawn a single urdf link with a camera sensor attached, e.g.

<?xml version="1.0" ?>
<robot name="camera" xmlns:body="http://playerstage.sourceforge.net/gazebo/xmlschema/#body" xmlns:controller="http://playerstage.sourceforge.net/gazebo/xmlschema/#controller" xmlns:geom="http://playerstage.sourceforge.net/gazebo/xmlschema/#geom"  xmlns:sensor="http://playerstage.sourceforge.net/gazebo/xmlschema/#sensor" xmlns:xacro="http://ros.org/wiki/xacro">
  <link name="camera_link">
    <inertial>
      <mass value="1"/>
      <origin xyz="0 0 0"/>
      <inertia ixx="0.1" ixy="0.0" ixz="0.0" iyy="0.1" iyz="0.0" izz="0.1"/>
    </inertial>
  </link>
  <gazebo reference="camera_link">
    <sensor:camera name="camera_sensor">
      <imageSize>640 480</imageSize>
      <imageFormat>BAYER_BGGR8</imageFormat>
      <hfov>90</hfov>
      <nearClip>0.1</nearClip>
      <farClip>100</farClip>
      <updateRate>25.0</updateRate>
      <controller:gazebo_ros_camera name="camera_controller" plugin="libgazebo_ros_camera.so">
        <alwaysOn>true</alwaysOn>
        <updateRate>25.0</updateRate>
        <cameraName>camera</cameraName>
        <imageTopicName>image_raw</imageTopicName>
        <cameraInfoTopicName>camera_info</cameraInfoTopicName>
        <frameName>camera_link</frameName>
        <CxPrime>320.5</CxPrime>
        <Cx>320.5</Cx>
        <Cy>240.5</Cy>
        <!-- image_width / (2*tan(hfov_radian /2)) -->
        <!-- 320 for wide and 772.55 for narrow stereo camera -->
        <focal_length>320</focal_length>
        <distortion_k1>0.0</distortion_k1>
        <distortion_k2>0.0</distortion_k2>
        <distortion_k3>0.0</distortion_k3>
        <distortion_t1>0.0</distortion_t1>
        <distortion_t2>0.0</distortion_t2>
      </controller:gazebo_ros_camera>
    </sensor:camera>
    <turnGravityOff>true</turnGravityOff>
    <material>Gazebo/Blue</material>
  </gazebo>
</robot>

and use ros service /gazebo/set_model_state to update the camera pose. Using ''rosbag record'' to capture a series of images.