Rosanswers logo

Hi, I'm tracking an object using a kinect and trying to publish the tf transform of that object in a "/map frame. I'm able to return the object's x, y and depth data using OpenCV. However, I'm struggling with the tf stuff. I've written a function which is meant to update the transform

void updatetransform(double x, double y, double z)
     r = -1.5708;
     p = 0;
     y = -3.1415;

   static tf::TransformBroadcaster br;  

  transform.setOrigin(tf::Vector3(x, y, z));
  quaternion.setRPY(r,p,y);  //where r p y are fixed 
  br.sendTransform(tf::StampedTransform(transform, ros::Time::now(), "kinect2_ir_optical_frame","drone/base_link"));
  ROS_INFO("Sent Drone Transform at %f %f %f", x, y, z);


and in my launch file

  <node name = "Drone_Detector" pkg="detector" type="detect_drone" output="screen" />
  <node pkg="tf" type="static_transform_publisher" name="baselink" args="0 0 1 -1.5708 0 -1.5708 /map /kinect2_link 50" />

But when I run Rviz, using "/map" as a fixed frame, the drone/base_link tf isn't shown in the screen. I've attached a picture of what it looks like at this link. My x,y and depth values are okay from what the kinect but the transform is wrong. Am I doing something wrong here?

Also here's my tf_tree which looks about right to me. Link here

Originally posted by cluelessnigerian on ROS Answers with karma: 3 on 2017-04-19

Post score: 0


1 Answer 1


Rosanswers logo

I don't see any obvious problems with the code, and it seems from your rviz screenshot that the base/drone_link is indeed present (I suspect it to be at the end of the yellow line.) Can you expand up the TF -> Frames tree and inspect the x y and z of the base/drone_link transform to confirm that they are what you expect them to be?

Perhaps it's a good idea to first test the updateTransform function with a know x y and z.

Originally posted by rbbg with karma: 1823 on 2017-04-19

This answer was ACCEPTED on the original site

Post score: 0

Original comments

Comment by cluelessnigerian on 2017-04-20:
I took your advice and took a look at TF -> Frames. The X,Y,Z values in the relative position are about right for drone/base_link. Link Here.However, I'm not quite sure if I understand the output of the remaining values (orientation etc) so I'm not sure how to interpret

Comment by rbbg on 2017-04-20:
It seems to me that you don't see the transform on the screen simply because it is too large. the Y and Z values of -438 and -323 indicate that the frame will be very far away, and not in the default view. If you zoom out very far it should show up. I'm not sure I understand what the problem is.

Comment by cluelessnigerian on 2017-04-20:
I think I'm probably not calculating the transform properly. -438 and -323 are actual pixel positions of the object I'm tracking from the kinect. Surely there must be a way to transform them into a frame that actually shows up within the map frame.


Your Answer

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