Transfer Function TF ROS
Transfer Function TF ROS
Tutorial
The output is a pdf file containing the different frames, their publishing
frequency, the relevant node, etc.
Other tf commands
rosrun tf tf_echo
rosrun tf tf_monitor
rosrun tf static_transform_publisher:
Usage: rosrun tf static_transform_publisher x y z yaw
pitch roll frame_id child_frame_id period(milliseconds)
OR
Usage: rosrun tf static_transform_publisher x y z qx qy
qz qw frame_id child_frame_id period(milliseconds)
tf Python/C++ library
Python:
br = tf.TransformBroadcaster()
br.sendTransform(x,y,z,rot,Time, frame1 , frame2 )
C++:
static tf::TransformBroadcaster br;
tf::Transform transform;
transform.setOrigin(tf::Vector3);
transform.setRotation( tf::Quaternion(r, p, y) );
br.sendTransform(tf::StampedTransform(transform,Time, "frame1",
frame2 ));
tf Python/C++ library
Listeners read the current tree of transforms and compute the transform
between two frames in the same tree
Python:
listener = tf.TransformListener()
(trans,rot)=listener.lookupTransform('/frame1','/frame2',
rospy.Time(0))
C++:
tf::TransformListener listener;
tf::StampedTransform transform;
listener.lookupTransform("/turtle2", "/turtle1",ros::Time(0),
transform);
tf and time
Because not every transform is available at all times, it is advisable to use
the following code block (wrap around a try/catch):
Try {
ros::Time now = ros::Time::now();
listener.waitForTransform("/frame2","/frame1",now,ros::Duration(3.0));
listener.lookupTransform("/turtle2", "/turtle1",now, transform); }
URDF model can also include other physical properties such as inertia,
collisions, joint dynamics, etc.