Ask Your Question
0

Interpreting data from ROS openni_tracker

asked 2014-05-04 22:57:16 -0600

Latif Anjum gravatar image

Hi,

I am subscribing to the /tf data from openni_tracker. Here is my program where I am using lookupTransform() function to get the data published over /tf.

#include <ros/ros.h>
#include <tf/transform_listener.h>
#include <stdio.h>

using namespace std;

int main(int argc, char** argv){
  ros::init(argc, argv, "my_tf_listener");

  ros::NodeHandle node;
  tf::TransformListener listener;

  ros::Rate rate(10.0);

  while (node.ok()){
    tf::StampedTransform transform;
    try{
      listener.lookupTransform("/openni_depth_frame", "/left_elbow_1", ros::Time(0), transform);  
      }
    catch (tf::TransformException ex){
         ROS_ERROR("%s",ex.what());
         }
    double left_elbow_1_x = transform.getOrigin().x();  
    double left_elbow_1_y = transform.getOrigin().y();
    double left_elbow_1_z = transform.getOrigin().z();

    cout <<"left_elbow_1_x " <<left_elbow_1_x<<endl;
    cout <<"left_elbow_1_y " <<left_elbow_1_y<<endl;
    cout <<"left_elbow_1_z " <<left_elbow_1_z<<endl;

    try{
      listener.lookupTransform("/openni_depth_frame", "/right_elbow_1", ros::Time(0), transform);
    }
    catch (tf::TransformException ex){
      ROS_ERROR("%s",ex.what());
    }

    double right_elbow_1_x = transform.getRotation().x(); 
    double right_elbow_1_y = transform.getRotation().y(); 
    double right_elbow_1_z = transform.getRotation().z();
    double right_elbow_1_w = transform.getRotation().w();

    cout <<"right_elbow_1_x " <<right_elbow_1_x<<endl;
    cout <<"right_elbow_1_y " <<right_elbow_1_y<<endl;
    cout <<"right_elbow_1_z " <<right_elbow_1_z<<endl;
    cout <<"right_elbow_1_w " <<right_elbow_1_w<<endl;

    rate.sleep();
    }
  return 0;
}

I know tf::StampedTransform::getOrigin() returns the origin vector translation between the two /tf messages used in lookupTransform function. Similarly I have an idea that tf::StampedTransform::getRotation() returns a quaternion representing the rotation between the two /tf messages used in lookupTransform function. Here is an excerpt of the output I get after running the program.

left_elbow_1_x 2.35472
left_elbow_1_y 0.146672
left_elbow_1_z 0.299355
right_elbow_1_x 0.331682
right_elbow_1_y -0.58186
right_elbow_1_z 0.308364
right_elbow_1_w 0.675527

Here are my questions:

  1. I am finding it hard to understand these output numbers. Can someone explain or direct me to sources I can consult to relate these numbers to actual physical movements or rotations?
  2. I googled but couldn't find what unit these numbers represent. cm, mm or what?
  3. Any other resource that can help me extract meaningful data from these numbers would be appreciated.

Cheers!

edit retag flag offensive close merge delete

Comments

Hello thank you verymuch for your code. But I can't find a way to get joint positions with this code . My openni_tracker is working... Please let me know how can I do this so that I can see all the joint coordinates or specific ones in real-time in terminal..

I'm waiting for your answer.

PKumars gravatar imagePKumars ( 2015-11-22 05:29:35 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2014-05-05 08:59:01 -0600

tfoote gravatar image

ROS message datatypes are standardized in REP 103 The positions are in meters, and quaternions don't have units. For more on quaternions I suggest looking here: https://en.wikipedia.org/wiki/Quatern...

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: 2014-05-04 22:57:16 -0600

Seen: 460 times

Last updated: May 05 '14