How to get the header frame id
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!
Is there a reason you can't just ask TF (with
lookupTransform(..)
) for the transformfront_camera->base_link
and instead want to do the work yourself? For "other sensors", just substitute their TF frame in place offront_camera
.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!