c++rosbulletphysics

How to Transform tf::Transform to btTransform


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? How to convert tf::Transform to btTransform and vice versa ?


Solution

  • tf::Transform is another name for btTransform.

    Have a look to its definition in tf/transform_datatypes.h: typedef btTransform tf::Transform.

    You can simply use the tf::Transform::inverse() method. Have a look at the tf::Transform documentation.