0
$\begingroup$

Rosanswers logo

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!


Originally posted by kiasoso on ROS Answers with karma: 13 on 2017-08-08

Post score: 0


Original comments

Comment by gvdhoorn on 2017-08-08:
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.

Comment by kiasoso on 2017-08-08:
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!

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.


Originally posted by gvdhoorn with karma: 86574 on 2017-08-08

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by kiasoso on 2017-08-09:
I feel like a fool! Thank you so much for clearing it up! It works fine now.

Comment by gvdhoorn on 2017-08-09:
No problem, we're all learning here. Glad you got it to work.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.