Ask Your Question
0

Combining different urdf-files (xarco) e.g. mount camera on robot

asked 2019-03-17 08:48:07 -0600

steradiant gravatar image

updated 2019-03-17 13:11:22 -0600

jayess gravatar image

Hello, I'm working with the kuka-lwr-ros package and I want to add a camera at the top of the robot. I managed to do this when I directly edited the original kuka_lwr.urdf.xarco file like shown in this tutorial: http://gazebosim.org/tutorials?tut=ro...

For better use, I want to have different files for the sensors and actuators (like camera, gripper and so on). I to copy the urdf.xarco file from an example of this package and edited this one.

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

  <!-- Include all models -->
  <xacro:include filename="$(find lwr_description)/model/kuka_lwr.urdf.xacro"/>
  <xacro:include filename="$(find kuka-lwr-gripper)/robot/my_camera.urdf.xacro"/>

  <!-- using the models -->
  <xacro:kuka_lwr name="lwr">
    <origin xyz="0 0 0" rpy="0 0 0"/>
  </xacro:kuka_lwr>

  <xacro:my_camera>
    <origin xyz="0 0 0" rpy="0 0 0"/>
  </xacro:my_camera>

</robot>

The last part (xarco:my_camera ..., and the include of my_camera.urdf.xarco) is my additions. The my_camera.urdf.xarco looks like follows:

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

  <xacro:property name="camera_link" value="0.05" /> <!-- Size of square 'camera' box -->

  <!-- URDF model with default base_link (world) 
  <xacro:macro name="camera" params="name base_link:=world *origin"> -->
  <xacro:macro name="my_camera">

  <!-- height of link_7 is 0.03 -->
  <joint name="camera_joint" type="fixed">
    <!-- <axis xyz="0 0 0" /> -->
    <origin xyz="0 0 0.01" rpy="0 0 0"/>
    <parent link="kuka_lwr_7_link"/>
    <child link="camera_link"/>
  </joint>

  <!-- Camera -->
  <link name="camera_link">
    <collision>
      <origin xyz="0 0 0" rpy="0 0 0"/>
      <geometry>
         <box size="1 ${camera_link} 0.025"/>
      </geometry>
    </collision>

    <visual>
      <origin xyz="0 0 0" rpy="0 0 0"/>
      <geometry>
         <box size="${camera_link} ${camera_link} 0.025"/>
      </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>

      <!-- camera -->
      <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>rrbot/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:macro>

</robot>

When I launch the launch file with the urdf.xarco from above, I geht the following error:

Unused block "origin" None None
when instantiating macro: my_camera (/home/.../rv_ws/src/kuka-lwr-gripper/robot/kuka-lwr-gripper ...
(more)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2019-03-19 05:45:28 -0600

fvd gravatar image

updated 2019-03-19 05:46:07 -0600

You hand in an origin block to the macro, but you commented out the original macro definition that calls for the origin block:

<xacro:macro name="camera" params="name base_link:=world *origin">

Either you should remove the origin block from the file where you call your macro, so it looks like this:

<xacro:my_camera />

Or you remove your custom macro definition, uncomment the original definition quoted above, and call your macro with the parameters it requests:

<xacro:camera base_link="kuka_lwr_7_link">
  <origin xyz="0 0 .01" rpy="0 0 0"/>
</xacro:camera>
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

2 followers

Stats

Asked: 2019-03-17 08:48:07 -0600

Seen: 203 times

Last updated: Mar 19