ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A answers.ros.org

# I have a question about URDF models and tf transformations

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 ##############################################################

<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>

##### 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:

...

ros::Rate loop( frequency_main_loop_ );

do
{
/* Time must be always updated */

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;

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 ... edit retag close merge delete ## 2 Answers Sort by » oldest newest most voted 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>

more

Ok I got it now.

( 2015-05-13 16:30:29 -0600 )edit

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

more