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

Revision history [back]

I'm assuming that the transformations between self.mytfname and dronename + "_svo_drone_vision" are being provided by your other node.

One thing to point out is that the TF system is based on message passing, so it is not safe to assume that a TF will be available in the buffer immediately after it has been broadcast. It will take a small amount of time before it is available.

I also noticed that you're looking up the TF at the current time, this will required extrapolating the drone TFs into the future so I would be expecting to see that excepting being thrown. A way around this is to lookup using the time rospy.Time(0) this tells the TF listener to return the most recent transform available, which should get around this problem.

It would be good to see a more complete block of code so we could see how transformToGlobal is being called. Hope this helps.

I'm assuming that the transformations between self.mytfname and dronename + "_svo_drone_vision" are being provided by your other node.

One thing to point out is that the TF system is based on message passing, so it is not safe to assume that a TF will be available in the buffer immediately after it has been broadcast. It will take a small amount of time before it is available.

I also noticed that you're looking up the TF at the current time, this will required extrapolating the drone TFs into the future so I would be expecting to see that excepting being thrown. A way around this is to lookup using the time rospy.Time(0) this tells the TF listener to return the most recent transform available, which should get around this problem.

It would be good to see a more complete block of code so we could see how transformToGlobal is being called. Hope this helps.

Thanks for the update:

I'm afraid that this is not how the TF system is meant to be used. You're broadcasting two static transforms and looking up a TF every time the transformToGlobal method is being called. This will be very slow at best and not work at all at worst.

I would recommend using two static transform publisher nodes to setup the two transformations you're creating in the transformToGlobal method. These transforms should define the location of your depth sensor of the drone. This way you'll only need to lookup a single transform inside this node.

Also you're transformToGlobal method should return the transform itself, so that the same transform can be used to transform all the points. This means you only need to do the lookup once, not again for each new point.

Hope this makes sense.

I'm assuming that the transformations between self.mytfname and dronename + "_svo_drone_vision" are being provided by your other node.

One thing to point out is that the TF system is based on message passing, so it is not safe to assume that a TF will be available in the buffer immediately after it has been broadcast. It will take a small amount of time before it is available.

I also noticed that you're looking up the TF at the current time, this will required extrapolating the drone TFs into the future so I would be expecting to see that excepting being thrown. A way around this is to lookup using the time rospy.Time(0) this tells the TF listener to return the most recent transform available, which should get around this problem.

It would be good to see a more complete block of code so we could see how transformToGlobal is being called. Hope this helps.

Thanks for the update:

I'm afraid that this is not how the TF system is meant to be used. You're broadcasting two static transforms and looking up a TF every time the transformToGlobal method is being called. This will be very slow at best and not work at all at worst.

I would recommend using two static transform publisher nodes to setup the two transformations you're creating in the transformToGlobal method. These transforms should define the location of your depth sensor of the drone. This way you'll only need to lookup a single transform inside this node.

Also you're transformToGlobal method should return the transform itself, so that the same transform can be used to transform all the points. This means you only need to do the lookup once, not again for each new point.

Hope this makes sense.

Update:

If you need to transform a point into a different frame this feature is already built into the TF system for you. If you convert your point into a PointStamped object so it has a time then you can convert it with a single line:

from tf2_geometry_msgs import PointStamped

...

PointStamped myPoint
myPoint.header.frame_id = "depth_frame"
myPoint.header.stamp = <Time of depth scan>
myPoint.x = x
myPoint.y = y
myPoiny.z = z

transformedPoint = tf_buf.transform(myPoint, "new_frame_id")

This will take care of the fully transformation for you including any rotations.