Adding camera using Xacro

asked 2019-04-30 06:49:39 -0500

dofrey gravatar image

Hi I want to attach a fixed camera on my robot base in Gazebo and RViz and there are two problems with this. First of all, I can not display the camera itself (its just a box). Is there a mistake in my code? And second is, that the image stream with rqt_image_view is right, but the one in RViz seems to have something like an overlay. How so that RViz displays the same topic different?

<?xml version="1.0"?>

<robot xmlns:xacro="http://www.ros.org/wiki/xacro" name="kinova">

  <xacro:property name="M_PI" value="3.1415926535897931" />
  <xacro:property name="camera_size" value="1" />
  <xacro:property name="offset_from_link_x" value="0.05" />
  <xacro:property name="offset_from_link_y" value="0.0" />
  <xacro:property name="offset_from_link_z" value="0.0" />

  <link name="camera_link">
    <visual>
      <geometry>
        <box size="${camera_size} ${camera_size} ${camera_size}"/>
      </geometry>
      <material>
        <script>
          <name>Gazebo/Red</name>
          <uri>file://media/materials/scripts/gazebo.material</uri>
        </script>
      </material>
    </visual>
  </link>

  <joint name="camera_joint" type="fixed">
    <parent link="kinova_link_base"/>
    <child link="camera_link"/>
    <origin rpy="${M_PI/2} ${-M_PI/2} 0" xyz="${offset_from_link_x} ${offset_from_link_y} ${offset_from_link_z}"/>
    <axis xyz="1 0 0" />
  </joint>

  <gazebo reference="camera_link">
    <sensor type="camera" name="camera_camera_sensor">
      <update_rate>30.0</update_rate>
      <camera>
        <pose>0 0 0 ${-M_PI/2} 0 ${-M_PI/2}</pose>
        <horizontal_fov>${85 * M_PI/180.0}</horizontal_fov>
        <image>
          <format>R8G8B8</format>
          <width>1020</width>
          <height>1020</height>
        </image>
        <clip>
          <near>0.01</near>
          <far>100</far>
        </clip>
      </camera>

      <plugin name="camera_camera_controller" filename="libgazebo_ros_camera.so">
        <alwaysOn>true</alwaysOn>
        <updateRate>0.0</updateRate>
        <cameraName>kinova/camera</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>

</robot>

Thanks for your help!

edit retag flag offensive close merge delete