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

How to get the header frame id

asked 2017-08-08 04:11:57 -0500

kiasoso gravatar image

Hello,

I want to make a transformation from my kinect to the base_link. My tf tree is build like this: base_link -> chassis -> Kinect -> front_camera.

I would be best if I can get the transformation matrix which directly transforms the data from front_camera to base_link. Because there will be other sensors in the future I want to make it as dynamic as possible. I had something like this in mind (it's like climbing the tree "backwards", from front_camera to Kinect, from Kinect to chassis, and finally from chassis to base_link):

//the first transformation frames     
#ifndef SOURCE_FRAME
#define SOURCE_FRAME "front_camera"
#endif
#ifndef TARGET_FRAME
#define TARGET_FRAME "Kinect"
#endif

geometry_msgs::TransformStamped ts1;
geometry_msgs::Vector3 rotation;
rotation.x = 0;
rotation.y = 0;
rotation.z = 0;
geometry_msgs::Vector3 translation;
translation.x = 0;
translation.y = 0;
translation.z = 0;

 do{
  ts1 = tBuffer.lookupTransform(TARGET_FRAME, ros::Time(0), SOURCE_FRAME, ros:Time(0), "base_link" ros::Duration(5.0));
   rotation += ts1.transform.rotation;

   translation += ts1.transform.translation;

   ts1.header.frame_id = ts1.child_frame_id;
   ts1.child_frame_id = **????????**

   }while(ts1.header.frame_id != "base_link");

I know this is probably not perfect c++ or code in general, but I hope you get what I want to do. I think I will get the syntax and everything right, but I don't know where to look for a function/way to get the child frame id, when I only have the header frame id?

(If you have a different/easier approach for me, I'd be also grateful for advice)

Thanks for your help!

edit retag flag offensive close merge delete

Comments

Is there a reason you can't just ask TF (with lookupTransform(..)) for the transform front_camera->base_link and instead want to do the work yourself? For "other sensors", just substitute their TF frame in place of front_camera.

gvdhoorn gravatar image gvdhoorn  ( 2017-08-08 05:03:52 -0500 )edit

Well as I understood the tutorials, I thought that you only can get the transform between a frame and it's parent frame and not like over a few frames! Seems like I misunderstood something! Thank you for telling me, I will try and see if I can get it rolling!

kiasoso gravatar image kiasoso  ( 2017-08-08 11:13:08 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2017-08-08 11:26:34 -0500

gvdhoorn gravatar image

updated 2017-08-08 11:26:47 -0500

No, that is not how TF works. You can ask for the transform from any frame to any other frame, as long as there is a path between those two frames.

edit flag offensive delete link more

Comments

I feel like a fool! Thank you so much for clearing it up! It works fine now.

kiasoso gravatar image kiasoso  ( 2017-08-09 00:39:21 -0500 )edit
1

No problem, we're all learning here. Glad you got it to work.

gvdhoorn gravatar image gvdhoorn  ( 2017-08-09 01:45:21 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2017-08-08 04:11:57 -0500

Seen: 2,779 times

Last updated: Aug 08 '17