一般用前四个参数就行了,如果开始没有坐标系转换,会报错 “turtle1” passed to lookupTransform argument target_frame does not exist 。如果又有了转换,程序可以正常运行。因为网络问题,如果timeout为0,那会直接报错失败,如果设置太小,也可能捕捉不到转换。使用tf_echo就会发现它要等一点时间才会输出结果,这是一样的道理。
std::string tf_error; // make sure that the transform between base_link and the global frame is available while (ros::ok() && !tf_.waitForTransform(global_frame_, "base_link", ros::Time(), ros::Duration(0.1), ros::Duration(0.01), &tf_error)) { ros::spinOnce(); if (last_error + ros::Duration(5.0) < ros::Time::now()) { ROS_WARN("Timed out waiting for transform from %s to %s to become available before running costmap, tf error: %s", robot_base_frame_.c_str(), global_frame_.c_str(), tf_error.c_str()); last_error = ros::Time::now(); } // The error string will accumulate and errors will typically be the same, so the last // will do for the warning above. Reset the string here to avoid accumulation. tf_error.clear(); }
其他有用的函数
tf::Transformer类的重要函数
std::string Transformer::allFramesAsString() const A way to see what frames have been cached Useful for debugging.
bool Transformer::frameExists (const std::string & frame_id_str) const Check if a frame exists in the tree.
void Transformer::getFrameStrings ( std::vector< std::string > & ids ) const A way to get a std::vector of available frame ids.
Vector3 getAxis()const//Return the axis of the rotation represented by this quaternion. //Set the quaternion using fixed axis RPY. voidsetRPY(const tfScalar &roll, const tfScalar &pitch, const tfScalar &yaw) //Return an identity quaternion. tf::Quaternion createIdentityQuaternion()
CMake Error at /home/user/catkin_ws/devel/share/costmap_2d/cmake/costmap_2dConfig.cmake:113 (message): Project 'costmap_2d' specifies '/usr/local/include/pcl-1.8' as an include dir, which is not found. It does neither exist as an absolute directory nor in'/home/user/catkin_ws/src/navigation/costmap_2d//usr/local/include/pcl-1.8'.