Ask Your Question
0

I have a question about URDF models and tf transformations

asked 2015-05-13 04:50:59 -0500

Andromeda gravatar image

updated 2015-05-13 11:07:07 -0500

Hi guys, I was convinced that if one defines, let's say 2 links, in a urdf file and joins them toghether with a joint element, then the physic relations between both links is going to be recognized automatically from tf when reading (parsing) the file at the moment to start the program. So it would be possible - I thought - to listen that transformation in my C++ program.

To make it clearer: I have the following urdf file (of course it is just a barebone example)

  ##### base_link ##############################################################

  <link name="base_link">

    <visual>
      <origin xyz="0.0 0.0 ${offset_cg_ground}" rpy="${pi/2} 0.0 ${pi}"/>
      <geometry>
        <mesh filename="package://my_package/my_model.dae" 
              scale="${scale_factor} ${scale_factor} ${scale_factor}"/>
      </geometry>
      <material name="grey" >
        <color rgba="0.4 0.4 0.5 1.0"/>
      </material>
    </visual>

  </link>


 ##### base_frame ##############################################################

  <link name="base_frame">

    <visual>
      <origin xyz="0.0 0.0 0.0" rpy="0.0 0.0 0.0" />
      <geometry>
        <cylinder length="${cylinder_height}" radius="${cylinder_radius}" />
      </geometry>
    </visual>

    <!-- Inertial information is needed for Gazebo or simulation porpuses -->
    <inertial>
      <mass value="${mass}" />
      <origin xyz="0 0 0" />
      <inertia ixx="${Ixx}" ixy="${Ixy}" ixz="${Ixz}" 
               iyy="${Iyy}" iyz="${Iyz}" 
               izz="${Izz}" />
    </inertial>

  </link>

which are assembled togheter with the following joint:

<joint name="base_link_2_base_frame" type="fixed">
  <parent link="base_link" />
  <child link="base_frame" />
  <origin xyz="0.0 0.0 ${offset_cg_ground}" rpy="0.0 0.0 0.0"/>
</joint>

Ok?? Now...in my C++ program I m going to broadcast only the transformation between the frames: /odom and /base_link . See the following snippet:

...
        odom_transform_.header.stamp    = ros::Time::now();
        odom_transform_.header.frame_id = "/odom";
        odom_transform_.child_frame_id  = "/base_link";

        ros::Rate loop( frequency_main_loop_ );

        do 
        {   
            /* Time must be always updated */
            odom_transform_.header.stamp    = ros::Time::now();

            /* Broadcast the position and orientation of the quadrotor */
            odom_transform_.transform.translation.x = actual_pose_.position.x;
            odom_transform_.transform.translation.y = actual_pose_.position.y;
            odom_transform_.transform.translation.z = actual_pose_.position.z;
            odom_transform_.transform.rotation        = actual_pose_.orientation;

            broadcaster_.sendTransform( odom_transform_ );

            ros::spinOnce();

            loop.sleep();

        } while( ros::ok() );
...

so no transformatiions between /base_link and /base_frame are going to be published in my program since I thought that those frames are fixed and their relative position is already configured in the urdf file.

Now...taking a look to the tf transformation printed in the pdf file I got confirmation that those frames are linked and recognized by tf, BUT I discovered that the command

rosrun tf tf_echo base_link base_frame

outputs the followings statements:

me@YE-166:~/workspace_ros$ rosrun tf tf_echo base_link base_frame
Failure at 254.547000000
Exception thrown:"base_frame" passed to lookupTransform argument source_frame does not exist. 
The current list of frames is:
Frame base_link exists with parent odom.

Failure at 254.547000000
Exception thrown:"base_frame" passed to lookupTransform argument source_frame does not exist. 
The current list of frames is:
Frame base_link exists with parent odom.

At time 256.020
- Translation: [0.000, 0.000, 0.084]
- Rotation: in Quaternion [0.000, 0.000, 0.000, 1.000]
            in RPY [0.000, -0.000, 0.000]
At time 257.020
- Translation: [0.000, 0.000, 0 ...
(more)
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2015-05-13 12:17:26 -0500

ahendrix gravatar image

robot_state_publisher expects the robot_description parameter to be in the global namespace, not a private parameter.

robot_description is set as a public parameter because it is used by multiple nodes, not just the robot state publisher.

Try this:

<param name="robot_description" command="$(find xacro)/xacro.py $(arg urdf_file)" />
<!-- Robot_state_publisher: needed for all the tf transformations -->
<node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" >
    <param name="publish_frequency" type="double" value="20" />
</node>
edit flag offensive delete link more

Comments

Ok I got it now.

Andromeda gravatar imageAndromeda ( 2015-05-13 16:30:29 -0500 )edit
2

answered 2015-05-13 10:55:23 -0500

David Lu gravatar image

The only way to get the transforms in a URDF to publish is by using robot_state_publisher.

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: 2015-05-13 04:50:59 -0500

Seen: 1,157 times

Last updated: May 13 '15