Ask Your Question
1

Publishing tf from Gazebo camera to Rviz

asked 2018-03-12 02:31:39 -0600

dpakshimpo gravatar image

updated 2018-03-21 08:16:06 -0600

Hello,

I am using the braccio_arm ( https://github.com/grassjelly/ros_bra... ) and trying to learn and simulate pick and place. I am able to launch the arm independently and work with it. Now, I created a world in Gazebo and would like to publish the PCL data from gazebo to Rviz and then plan to use pick and place. I face 2 issues, 1. I am unable to transform data from camera_link in Gazebo to base_link of robot. Kindly help. I followed the tutorial here and was added camera_link on my gazebo fie and URDF file.

Gazebo world has a kinect at 1.1 m in z and a table with 3 shapes on it. The kinect plugin code:

  <plugin name='camera_link_plugin' filename='libgazebo_ros_openni_kinect.so'>
    <baseline>0.2</baseline>
    <alwaysOn>true</alwaysOn>
    <updateRate>0.0</updateRate>
    <cameraName>camera_ir</cameraName>
    <imageTopicName>/camera/depth/image_raw</imageTopicName>
    <cameraInfoTopicName>/camera/depth/camera_info</cameraInfoTopicName>
    <depthImageTopicName>/camera/depth/image_raw</depthImageTopicName>
    <depthImageInfoTopicName>/camera/depth/camera_info</depthImageInfoTopicName>
    <pointCloudTopicName>/camera/depth/points</pointCloudTopicName>
    <frameName>camera_link</frameName>
    <pointCloudCutoff>0.05</pointCloudCutoff>
    <distortionK1>0</distortionK1>
    <distortionK2>0</distortionK2>
    <distortionK3>0</distortionK3>
    <distortionT1>0</distortionT1>
    <distortionT2>0</distortionT2>
    <CxPrime>0</CxPrime>
    <Cx>0</Cx>
    <Cy>0</Cy>
    <focalLength>0</focalLength>
    <hackBaseline>0</hackBaseline>
  </plugin>
</sensor>

My URDF links for the robot:

<robot xmlns:xacro="http://www.ros.org/wiki/xacro" 
xmlns:sensor="http://playerstage.sourceforge.net/gazebo/xmlschema/#sensor"
    xmlns:controller="http://playerstage.sourceforge.net/gazebo/xmlschema/#controller"
    xmlns:interface="http://playerstage.sourceforge.net/gazebo/xmlschema/#interface"
name="braccio">

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

<xacro:property name="kinect_box_length" value="0.3556" />
<xacro:property name="kinect_box_width" value="0.1778" />
<xacro:property name="kinect_box_height" value="0.0762" />
<xacro:property name="kinect_box_mass" value="1.274595" />

<xacro:macro name="inertial_matrix_cuboid" params="mass box_length box_width">
               <inertial>
                       <mass value="${mass}" />
                       <inertia ixx="${mass/12*(box_length*box_length)}" 
                                ixy = "0" ixz = "0"
                                iyy="${mass/12*(box_width*box_width)}" iyz = "0"
                                izz="${mass/12*(box_length*box_length + box_width*box_width)}" />
               </inertial>
</xacro:macro>

<xacro:macro name="transmission_block" params="joint_name idx">
      <transmission name="tran_${idx}">
        <type>transmission_interface/SimpleTransmission</type>
        <joint name="${joint_name}">
          <hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
        </joint>
        <actuator name="motor__${idx}">
          <hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
          <mechanicalReduction>1</mechanicalReduction>
        </actuator>
      </transmission>
</xacro:macro>

<link name="base_footprint"/>

<joint name="base_footprint_joint" type="fixed">
    <parent link="base_footprint"/>
    <child link="base_link"/>
  </joint>

    <link name="base_link">
    <visual>
      <geometry>
    <cylinder length="0.01" radius=".053" />
      </geometry>
      <material name="black"/>
      <origin rpy="0 0 0" xyz="0 0 0"/>
    </visual>
    <inertial>
      <mass value="2"/>
    <inertia ixx="0.015" ixy="0" ixz="0" iyy="0.00666666666667" iyz="0" izz="0.0216666666667"/>
    </inertial>
  </link>

    <link name="camera_link"> 
    <xacro:inertial_matrix_cuboid mass="${kinect_box_mass}" box_length="${kinect_box_length}" box_width="${kinect_box_width}"/>
    </link>

  <joint name="camera_joint" type="fixed">
    <origin xyz="0 0 1.1" rpy="0 0 0"/> 
    <parent link="base_link"/>
    <child link="camera_link"/>
  </joint>

  <link name="braccio_base_link">
    <visual>
      <geometry>
        <mesh filename="package://braccio_arduino_ros_rviz/stl/braccio_base.stl" scale="0.001 0.001 0.001"/>
      </geometry>
      <material name="orange"/>
      <origin rpy="0 ...
(more)
edit retag flag offensive close merge delete

Comments

1

I would suggest you to change your link world to base_footprint (just change the names) Gazebo is able to link base_footprint to world(see #q208051). Also, your camera link needs the inertial tag too.

Delb gravatar imageDelb ( 2018-03-15 03:56:18 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2018-03-12 03:13:53 -0600

Delb gravatar image

updated 2018-03-12 03:14:53 -0600

gvdhoorn gravatar image

Look at #q283961, you missed the inertial tag which is required by Gazebo.

For your PCL data, have you tried rotating your box in the urdf ?

edit flag offensive delete link more

Comments

Thanks for you input Delib, unfortunately, it did not work too.

dpakshimpo gravatar imagedpakshimpo ( 2018-03-12 05:40:50 -0600 )edit

How do I get to 5 points, so that I can upload images?

dpakshimpo gravatar imagedpakshimpo ( 2018-03-12 05:45:45 -0600 )edit

Can you edit your question to show the modifications ? Also I noticed you defined the same origin in the joint tag and link tag which means you won't have your box at the same position as the tf which could be an issue (put origin of link and collision tag to 0 0 0

Delb gravatar imageDelb ( 2018-03-13 06:15:17 -0600 )edit

Hello Delb,

I have modified the URDF/XACRO file to remove the camera link visual element and tired to visualise the PCL data in Rviz, as reported earlier. I tried to write a node to transform the data from camera_link to world, that also did not help.

dpakshimpo gravatar imagedpakshimpo ( 2018-03-15 03:17:37 -0600 )edit

For some reason my comment to the other answer is missing, i updated the xacro file with the inertial tag for camera link (this is based on the actual dimensions of Kinect) the issue is not resolved. My Gazebo has a kinect spawned at same height as mentioned in URDF and that has the plugin code

dpakshimpo gravatar imagedpakshimpo ( 2018-03-16 00:54:23 -0600 )edit

Can you add your launch file too please ? The urdf seems fine though. Do you have this line somewhere ? xmlns:sensor="http://playerstage.sourceforge.net/gazebo/xmlschema/#sensor"

Delb gravatar imageDelb ( 2018-03-16 03:19:49 -0600 )edit

Hello Delb, Thanks for your time again. Edited the qn with launch files for Gazebo and Rviz. I added the above xml tag to my XACRO now.

dpakshimpo gravatar imagedpakshimpo ( 2018-03-18 22:36:04 -0600 )edit

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: 2018-03-12 02:31:39 -0600

Seen: 648 times

Last updated: Mar 21 '18