写tf listener时遇到的问题:
参考网页:http://wiki.ros.org/tf/Tutorials/Writing%20a%20tf%20listener%20%28C%2B%2B%29
1. How to publish the pose (position) of the robot after having the tf listener to "listener.lookupTransform("/map", "/base_link", ros::Time(0), transform);"?
解决方法:
use the standard ROS messages to represent pose info. You can use either geometry_msgs/Pose (http://docs.ros.org/jade/api/geometry_msgs/html/msg/Pose.html)or geometry_msgs/PoseWithCovariance (http://docs.ros.org/indigo/api/geometry_msgs/html/msg/PoseWithCovariance.html : if you need to publish pose together with its covariance )
so if you have populated transform variable with a call to lookupTransform, you can for example store the pose (without covariance) as follows,
geometry_msgs::Pose pose;
pose.position.x = transform.getOrigin().x();
pose.position.y = transform.getOrigin().y();
pose.position.z = transform.getOrigin().z();
// these two are valid only if the robot is operating in 2D
double yaw = tf::getYaw( transform.getRotation() );
pose.orientation = tf::createQuaternionMsgFromYaw( yaw );
now you can publish the 2D pose as a geometry_msgs/Pose message
2. 运行写好的程序时,遇到错误:"map" passed to lookupTransform argument target_frame does not exist.
解决方法:
- 加上listener.waitForTransform(...)
try {
listener.waitForTransform(destination_frame, original_frame, ros::Time(0), ros::Duration(10.0) );
listener.lookupTransform(destination_frame, original_frame, ros::Time(0), transform);
} catch (tf::TransformException ex) {
ROS_ERROR("%s",ex.what());
} - 加include的头文件:
#include <nav_msgs/Odometry.h>
#include <tf/transform_listener.h>
再重新编译,就可以通过:./<nodename> 得到publish:; destination_frame和orginal_frame的 tf的topic了。
3. 运行写好的launch file to run publish the tf. 错误:ERROR: cannot launch node of type [learning_tf/pioneer_tf_listener]: can't locate node [pioneer_tf_listener] in package [learning_tf]
解决方法:需要在当前路径下 source ~/catkin_ws/devel/setup.bash
本文档介绍了在编写ROS TF监听器时遇到的常见问题,包括如何发布机器人的定位信息,解决"target_frame不存在"错误,以及启动launch文件时找不到节点的处理办法。提供了详细的解决步骤和代码示例。
1472

被折叠的 条评论
为什么被折叠?



