Rosanswers logo

hello, I am trying to read xyz from tfMessage which publishes the kinect's translation from the pi_tracker or the openni_launch and i want it sent to tum_simulator..

where is the code

geometry_msgs::Twist command;
ros::Publisher pub_takeoff, pub_land, pub_toggle_state, pub_vel;
geometry_msgs::TransformStamped transforms;
geometry_msgs::Transform transform;
geometry_msgs::Vector3 translation;

using namespace ros;

void chatterCallback(const tf::tfMessage::ConstPtr& mes)


    command.linear.x = mes->transforms.transform.translation.x;
    //command.linear.y = mes->y;
    //command.linear.z = mes->z;
    //command.angular.z= mes->z;
ROS_INFO("I received %f %f %f %f/n", command.linear.x, command.linear.y, command.linear.z, command.angular.z);

int main(int argc, char **argv) {

 //init subscr node
ros::init(argc, argv, "simkin");
// Create a node handle
ros::NodeHandle n;
// Initialize the node
ros::Subscriber sub = n.subscribe("/tf", 1000, chatterCallback);

 // A publisher for the movement data
 Publisher pub = n.advertise<geometry_msgs::Twist>("/cmd_vel", 10);

 // Drive forward at a given speed.  The robot points up the x-axis.
 //geometry_msgs::Twist command;

 Rate rate(10);
 while (ok()) {

 return 0;

Originally posted by Silimon Sorin on ROS Answers with karma: 3 on 2013-05-21

Post score: 0

Original comments

Comment by davinci on 2013-05-21:
What is the question? What goes wrong?

Comment by Silimon Sorin on 2013-05-22:
it doesn't work,the error is that"transform does not name a type"...I need to read the xyz from the /tf...OR I could you the pi_tracker topic /skeleton which is not so compact but is I put in chatterCallback pi_tracker::skeleton (this is the error:error: ‘pi_tracker’ does not name a type /home/ssr )

Comment by gaussian on 2015-01-24:
@Silimon Sorin @ngrennan Did you understand how we should do it for kinect? We get transforms of all the skeletal coordinate frames separately. Guess we should receive them separately! Please help


1 Answer 1


Rosanswers logo

You should use the TF library rather than subscribing to the /tf topic directly. Take a look at the tf documentation and the tf C++ tutorial.

Originally posted by ahendrix with karma: 47576 on 2013-05-22

This answer was ACCEPTED on the original site

Post score: 4

Original comments

Comment by bit-pirate on 2013-05-22:
Agreed. The way you access the tf data is not recommended. If you use the tf topic like this, you will receive the data of all transforms in your system. To get the data of a specific transform, use the tf::TransformListener. Have a look at the above linked tutorials to learn how to use it.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.