Interpreting data from ROS openni_tracker
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:
- 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?
- I googled but couldn't find what unit these numbers represent. cm, mm or what?
- Any other resource that can help me extract meaningful data from these numbers would be appreciated.
Cheers!
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.