ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

openni_tracker/Transform depth

asked 2011-07-15 04:06:32 -0500

qdocehf gravatar image

updated 2016-10-24 08:33:44 -0500

ngrennan gravatar image

I am using the openni_tracker with a Kinect, and I have written a node to receive the transforms from it. Is there a variable that will tell me the distance between the sensor and a joint of a person being tracked?

Update: In openni_tracker.cpp, this code is found:

void publishTransform(XnUserID const& user, XnSkeletonJoint const& joint, string const& frame_id, string const& child_frame_id) {
    static tf::TransformBroadcaster br;

    XnSkeletonJointPosition joint_position;
    g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(user, joint, joint_position);
    double x = joint_position.position.X / 1000.0;
    double y = joint_position.position.Y / 1000.0;
    double z = joint_position.position.Z / 1000.0;

    XnSkeletonJointOrientation joint_orientation;
    g_UserGenerator.GetSkeletonCap().GetSkeletonJointOrientation(user, joint, joint_orientation);

    XnFloat* m = joint_orientation.orientation.elements;
    KDL::Rotation rotation(m[0], m[1], m[2],
                                           m[3], m[4], m[5],
                                           m[6], m[7], m[8]);
    double qx, qy, qz, qw;
    rotation.GetQuaternion(qx, qy, qz, qw);

    tf::Transform transform;
    transform.setOrigin(tf::Vector3(x, y, z));
    transform.setRotation(tf::Quaternion(qx, qy, qz, qw));
    br.sendTransform(tf::StampedTransform(transform, ros::Time::now(), frame_id, child_frame_id));
}

It appears that the Vector3 in transform is equal to joint_position.position which is supposed to be the exact position(not how much the joint has moved). Also, the output data seems to show that this is true. Therefore, I believe the problem has been solved.

edit retag flag offensive close merge delete

Comments

What do you mean with "distance from the sensor"? Kinect's distance measurements are not in transformations, but in the pointcloud or depth image topics. The distance of the transform would be the norm of its translation (if that has meaning to you).
dornhege gravatar image dornhege  ( 2011-07-15 07:19:57 -0500 )edit
How can I access the pointcloud or depth image topics? Would I be able to use them to measure the distance between the sensor and a person that is being tracked?
qdocehf gravatar image qdocehf  ( 2011-07-15 07:28:42 -0500 )edit
You just subscribe to the topics in question and yes, they would give you distances.
dornhege gravatar image dornhege  ( 2011-07-15 10:42:37 -0500 )edit
In what files are those topics created? I need a bit more information about them to be able to subscribe to them.
qdocehf gravatar image qdocehf  ( 2011-07-18 01:16:33 -0500 )edit
Sorry, I had openni_camera in mind. Never worked with tracker, but you can test that quite easily: rosrun tf view_frames while it is running should give you the /tf tree. This should contain the skeleton frames - and maybe? a kinect frame that you can use.
dornhege gravatar image dornhege  ( 2011-07-18 08:03:33 -0500 )edit

2 Answers

Sort by » oldest newest most voted
0

answered 2011-07-19 05:11:42 -0500

qdocehf gravatar image

It appears that the Vector3 in transform is equal to joint_position.position which is supposed to be the exact position(not how much the joint has moved). Also, the output data seems to show that this is true.

edit flag offensive delete link more
1

answered 2011-07-19 00:44:38 -0500

Miguel Prada gravatar image

First of all you need to know what you exactly mean by "the distance between the sensor and the person". Is it the distance to the closest person joint? To the person torso?

In any case, if you take the transform between any joint and "openni_depth_frame", you can calculate the distance of that joint to the sensor by getting the norm of the translation vector with sqrt(x²+y²+z²).

edit flag offensive delete link more

Comments

@qdocehf If this answers your question (from the updated title it should) you can click the checkmark to accept the answer.
dornhege gravatar image dornhege  ( 2011-07-19 02:15:36 -0500 )edit
No, it was actually something else that I found. It is at the bottom of my updated question.
qdocehf gravatar image qdocehf  ( 2011-07-19 02:29:14 -0500 )edit
You should answer your own question then, and an admin will mark it as answered. This way it will be cleared off of the list of "unanswered" questions.
tfoote gravatar image tfoote  ( 2011-07-19 04:46:16 -0500 )edit
I posted an answer if you want to mark it.
qdocehf gravatar image qdocehf  ( 2011-07-21 08:06:51 -0500 )edit

Question Tools

Stats

Asked: 2011-07-15 04:06:32 -0500

Seen: 535 times

Last updated: Aug 03 '11