tf 常用接口函数

原文地址:http://www.360doc.com/content/17/0411/11/7821691_644634302.shtml

1、定义一个tf发布器

tf::TransformBroadcaster br;

2、定义个tf的转换关系

tf::Transform transform;

设置三维坐标点的位置

transform.setOrigin( tf::Vector3(msg->x, msg->y, 0.0) );

将角度转换成四元数,设置到转换中

tf::Quaternion q;

q.setRPY(0, 0, msg->theta);

transform.setRotation(q);

3、将转换关系即相对父坐标系的位置发送到tf库

br.sendTransform(tf::StampedTransform(transform, ros::Time::now(), "world", turtle_name));

4、定义一个接收器

tf::TransformListener listener;

5、定义个Stamped tf的转换关系

tf::StampedTransform transform;

6、等待需要的tf转换关系生成

listener.waitForTransform("/turtle2", "/turtle1", now, ros::Duration(3.0));

7、查阅turtle2转换成turtle1的

 listener.lookupTransform("/turtle2", "/turtle1",now, transform);

8、注册接收某个坐标系

tf_filter_ = new tf::MessageFilter<geometry_msgs::PointStamped>(point_sub_, tf_, target_frame_, 10);

    tf_filter_->registerCallback( boost::bind(&PoseDrawer::msgCallback, this, _1) );

9、转换point_ptr到target_frame_的转换关系

tf_.transformPoint(target_frame_, *point_ptr, point_out);

10、将yaw角度值转换成四元素

tf::createQuaternionMsgFromYaw(angle+M_PI/2);

tf::Quaternion createIdentityQuaternion()

  • Return an identity quaternion.

tf::Quaternion createQuaternionFromRPY(double roll,double pitch,double yaw)

  • Return a tf::Quaternion constructed from Fixed-Axis Roll, Pitch and Yaw

geometry_msgs::Quaternion createQuaternionMsgFromRollPitchYaw(double roll,double pitch,double yaw)

  • Return a geometry_msgs::Quaternion constructed from Fixed-Axis Roll, Pitch and Yaw.

11、

Quaternion

tf::Quaternion

Vector

tf::Vector3

Point

tf::Point

Pose

tf::Pose

Transform

tf::Transform

12、抛出异常

Exceptions used in the tf package

All exceptions in tf inherit from tf::TransformException, which inherits from std::runtime_error.

tf::ConnectivityException

  • Thrown if the request cannot be completed due to the two frame ids not being in the same connected tree.

tf::ExtrapolationException

  • Thrown if there is a connection between the frame ids requested but one or more of the transforms are out of date.

tf::InvalidArgument

  • Thrown if an argument is invalid. The most common case is an unnormalized quaternion.

tf::LookupException

  • Thrown if an unpublished frame id is referenced.

原文地址:http://www.360doc.com/content/17/0411/11/7821691_644634302.shtml

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值