如何将 tf::Transform 转换为 btTransform

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

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

tf::TransformbtTransform 的另一个名称。

看看它在tf/transform_datatypes.h中的定义:typedef btTransform tf::Transform

您可以简单地使用tf::Transform::inverse()方法。看看 tf::Transform documentation.