如何将tf :: Transform转换为btTransform

时间:2015-10-13 10:17:38

标签: c++ ros bulletphysics

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));
    }
}

在上面的函数.asBt()中已弃用,我该怎么做才能完成转换?如何将tf::Transform转换为btTransform,反之亦然?

1 个答案:

答案 0 :(得分:1)

tf::TransformbtTransform的另一个名称。

tf/transform_datatypes.h中查看其定义:typedef btTransform tf::Transform

您只需使用tf::Transform::inverse()方法即可。看看tf::Transform documentation