Ask Your Question
0

How to Transform tf::Transform to btTransform

asked 2015-10-13 01:04:49 -0500

johnny.lin gravatar image
    void broadcastKinectTransform(const tf::Transform& transform, const std::string& kinect_rgb_optical, const std::string& ground, tf::TransformBroadcaster& broadcaster, const tf::TransformListener& listener) {
    std::string link;
    if (listener.getParent(kinect_rgb_optical, ros::Time(0), link) && listener.getParent(link, ros::Time(0), link)) {
            tf::StampedTransform tfTransform;
            listener.lookupTransform (link, kinect_rgb_optical, ros::Time(0), tfTransform);
            broadcaster.sendTransform(tf::StampedTransform(transform * tfTransform.asBt().inverse(), ros::Time::now(), ground, link));
    } else {
            broadcaster.sendTransform(tf::StampedTransform(transform, ros::Time::now(), ground, kinect_rgb_optical));
    }
}

In the above function, .asBt() is deprecated, what should I do to finish the transformation?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2015-10-13 16:30:23 -0500

updated 2015-10-14 07:54:47 -0500

You can simply remove the .asBt() part. Multiplication of tf::StampedTransform by tf::Transform will return tf::Transform.

EDIT

Both Bullet and tf have almost identical interfaces, but the type names differ. So you have to convert everything using POD-types, for example floats array.

To convert btTransform to tf::Transform do something like this:

btTransform bt_transform;
tf::Transform tf_transform;
float gl_matrix[15];

bt_transform.getOpenGLMatrix(gl_matrix);
tf_transform.setFromOpenGLMatrix(gl_matrix);

Or you can do this component-wise by separately extracting quaternion and origin vector from Bullet transform and setting them back to tf transform. But I think the above method is cleaner.

edit flag offensive delete link more

Comments

Is there a way to do transformation between btTransform and tf::Transform ?

johnny.lin gravatar image johnny.lin  ( 2015-10-13 23:08:14 -0500 )edit

What ROS version are you using? Is this btTransform from ROS code or are you using Bullet directly?

Boris gravatar image Boris  ( 2015-10-14 07:20:40 -0500 )edit

I am converting some fuerte code to indigo, so there are plenty of incompatible errors. I am using ROS and bullet together.

johnny.lin gravatar image johnny.lin  ( 2015-10-14 08:58:39 -0500 )edit

Then conversion via OpenGL-matrix should work fine (the one I mentioned after edit).

Boris gravatar image Boris  ( 2015-10-14 09:26:17 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2015-10-13 01:04:49 -0500

Seen: 647 times

Last updated: Oct 14 '15