Ask Your Question
0

How can I make my objects/robot appear in image_raw topic when using Gazebo camera plugin?

asked 2020-04-16 16:23:37 -0500

Pinknoise2077 gravatar image

updated 2020-04-16 16:29:04 -0500

Hi All,

I am currently trying to set up a camera in Gazebo, to display the content of the simulation in rviz. However, I cannot see anything in the camera image.

To do that, I use the universal robot package on ROS Kinetic, and modify the ur5_robot.urdf.xacro file. I simply added the camera links and joints + the gazebo tags, as presented in the Gazebo tutorial on cameras.

Here is the modified ur5_robot.urdf.xacro file that I use:

<?xml version="1.0"?>
<robot xmlns:xacro="http://wiki.ros.org/xacro" name="ur5">

  <!-- Add a camera in the URDF -->
  <xacro:property name="camera_yaw_angle" value="${pi/2}" />  
  <xacro:property name="camera_roll_angle" value="${-pi/2 - pi/6}" />  
  <xacro:property name="camera_depth" value="0.05" />
  <xacro:property name="camera_height" value="0.07" />
  <xacro:property name="camera_length" value="0.15" />
  <xacro:property name="camera_z_offset" value="0.01" />
  <!-- Size of square 'camera' box -->
  <xacro:property name="camera_x" value="2" />
  <!-- x position of 'camera' box -->
  <xacro:property name="camera_y" value="0.05" />
  <!-- y position of 'camera' box -->
  <xacro:property name="camera_z" value="0.5" />
  <!-- z position of 'camera' box -->

  <joint name="camera_joint" type="fixed">
    <axis xyz="0 1 0" />
    <origin xyz="${camera_x} ${camera_y} ${camera_z}" rpy="${camera_roll_angle} 0 ${camera_yaw_angle}"/>
    <parent link="world"/>
    <child link="camera_link"/>
  </joint>

  <!-- Camera -->
  <link name="camera_link">
    <collision>
      <origin xyz="0 0 ${-1 * camera_depth - camera_z_offset}" rpy="0 0 0"/>
      <geometry>
        <box size="${camera_length} ${camera_height} ${camera_depth}"/>
      </geometry>
    </collision>

    <visual>
      <origin xyz="0 0 ${-1 * camera_depth - camera_z_offset}" rpy="0 0 0"/>
      <geometry>
        <box size="${camera_length} ${camera_height} ${camera_depth}"/>
      </geometry>
      <material name="red"/>
    </visual>

    <inertial>
      <mass value="1e-5" />
      <origin xyz="0 0 0" rpy="0 0 0"/>
      <inertia ixx="1e-6" ixy="0" ixz="0" iyy="1e-6" iyz="0" izz="1e-6" />
    </inertial>
  </link>

  <gazebo reference="camera_link">
    <sensor type="camera" name="camera1">
      <update_rate>30.0</update_rate>
      <camera name="head">
        <horizontal_fov>1.3962634</horizontal_fov>
        <image>
          <width>800</width>
          <height>800</height>
          <format>R8G8B8</format>
        </image>
        <clip>
          <near>0.02</near>
          <far>300</far>
        </clip>
        <noise>
          <type>gaussian</type>
          <!-- Noise is sampled independently per pixel on each frame.
               That pixel's noise value is added to each of its color
               channels, which at that point lie in the range [0,1]. -->
          <mean>0.0</mean>
          <stddev>0.007</stddev>
        </noise>
      </camera>

      <plugin name="camera_controller" filename="libgazebo_ros_camera.so">
        <alwaysOn>true</alwaysOn>
        <updateRate>0.0</updateRate>
        <cameraName>ur5/camera1</cameraName>
        <imageTopicName>image_raw</imageTopicName>
        <cameraInfoTopicName>camera_info</cameraInfoTopicName>
        <frameName>camera_link</frameName>
        <hackBaseline>0.07</hackBaseline>
        <distortionK1>0.0</distortionK1>
        <distortionK2>0.0</distortionK2>
        <distortionK3>0.0</distortionK3>
        <distortionT1>0.0</distortionT1>
        <distortionT2>0.0</distortionT2>
      </plugin>
    </sensor>
  </gazebo>

  <xacro:arg name="transmission_hw_interface" default="hardware_interface/PositionJointInterface"/>

  <!-- common stuff -->
  <xacro:include filename="$(find ur_description)/urdf/common.gazebo.xacro" />

  <!-- ur5 -->
  <xacro:include filename="$(find ur_description)/urdf/ur5.urdf.xacro" />

  <!-- arm -->
  <xacro:ur5_robot prefix ...
(more)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-04-16 16:41:49 -0500

Pinknoise2077 gravatar image

updated 2020-04-16 17:09:43 -0500

Well, I think I found the issue. Somehow, I thought that the camera was displaying along the Z axis of the camera joint frame.

For people that are not clear with how the camera frame works, here is what I found:

The camera joint is what you should care about to position/orient the camera. The link is only for visualization, and actually does not influence how the camera looks at the scene.

The camera is looking in the direction of the X vector of the camera joint frame. The Y vector is in the direction of the width of the image, and the Z vector is in the direction of the height of the image.

So what is really important to set up the camera is to set the joint origin tag xyz and rpy parameters correctly.

More precisely, this part:

  <joint name="camera_joint" type="fixed">
    <axis xyz="0 1 0" />
    <origin xyz="${camera_x} ${camera_y} ${camera_z}" rpy="${camera_roll_angle} 0 ${camera_yaw_angle}"/>
    <parent link="world"/>
    <child link="camera_link"/>
  </joint>

I would also add that the axis tag has no influence on the camera at all in this case. Its only a filler.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-04-16 16:23:37 -0500

Seen: 786 times

Last updated: Apr 16 '20