ROS的坐标系TF

来源:互联网 发布:a star算法c 编辑:程序博客网 时间:2024/04/28 16:29

ROS坐标系

ROS坐标系使用右手法则,Z轴朝上, X轴到Y轴是逆时针。

TF Tool

view_frames

rosrun tf view_framesevince frames.pdf

rqt_tf_tree

rosrun rqt_tf_tree rqt_tf_tree

坐标系转换

Tturtle1_turtle2=Tturtle1_worldTworld_turtle2

rosrun tf tf_echo [reference_frame] [target_frame]rosrun tf tf_echo turtle1 turtle2

运行结果

At time 1416409795.450- Translation: [0.000, 0.000, 0.000]- Rotation: in Quaternion [0.000, 0.000, 0.914, 0.405]            in RPY [0.000, -0.000, 2.308]At time 1416409796.441- Translation: [0.000, 0.000, 0.000]- Rotation: in Quaternion [0.000, 0.000, 0.914, 0.405]            in RPY [0.000, -0.000, 2.308]At time 1416409797.450- Translation: [0.000, 0.000, 0.000]- Rotation: in Quaternion [0.000, 0.000, 0.914, 0.405]            in RPY [0.000, -0.000, 2.308]At time 1416409798.441- Translation: [0.000, 0.000, 0.000]- Rotation: in Quaternion [0.000, 0.000, 0.914, 0.405]            in RPY [0.000, -0.000, 2.308]At time 1416409799.433- Translation: [0.000, 0.000, 0.000]- Rotation: in Quaternion [0.000, 0.000, 0.691, 0.723]            in RPY [0.000, -0.000, 1.526]

教程

http://wiki.ros.org/tf/Tutorials/Introduction%20to%20tf

demo

一个双龟跟随的游戏,使用 teleop_key node进行第一个龟的导引,第二个龟跟随

安装

$ sudo apt-get install ros-jade-ros-tutorials ros-jade-geometry-tutorials ros-jade-rviz ros-jade-rosbash ros-jade-rqt-tf-tree

运行

roslaunch turtle_tf turtle_tf_demo.launch

map odom base_link

http://www.ros.org/reps/rep-0105.html
https://github.com/turtlebot/turtlebot/issues/58

ROS的坐标系,最终归结为三个标准框架,可以简化许多常见的机器人问题:

1)全局准确,但局部不连续的帧(’map”)
2)全局不准确,但局部光滑框架(’odom”)
3)机器人自身框架(’base_link”)

多种传感器(像激光雷达、深度摄像头和陀螺仪加速度计等)都可以计算base_link和odom的坐标关系,但由于“每个帧只能有一个父帧”,所以只能有一个节点(比如 robot_pose_ekf 融合多传感器)发布base_link和odom的坐标关系。

三个坐标帧的父子关系如下:
map –> odom –> base_link
其实, map和odom都应该和base_link关联,但为了遵守“每个帧只能有一个父帧”的原则,根据map和base_link 以及 odom->base_link的关系,计算出map与odom的坐标关系并发布。

odom->base_link的坐标关系是由里程计节点计算并发布的。
map -> base_link的坐标关系是由定位节点计算出来,但并不发布,而是利用接收odom->base_link的坐标关系,计算出map->odom的坐标关系,然后发布。


编程

tf坐标变换

通过 numpy可以实现坐标变换,tf.transformations 库其实就是对 numpy的包裹。

from tf import transformations as t(trans, rot) = transformer.lookupTransform(frame1, frame2, rospy.Time(0))transform = t.concatenate_matrices(t.translation_matrix(trans), t.quaternion_matrix(rot))inversed_transform = t.inverse_matrix(transform)

Wait for transforms

    listener.waitForTransform("/turtle2", "/carrot1", rospy.Time(), rospy.Duration(4.0))    while not rospy.is_shutdown():        try:            now = rospy.Time.now()            listener.waitForTransform("/turtle2", "/carrot1", now, rospy.Duration(4.0))            (trans,rot) = listener.lookupTransform("/turtle2", "/carrot1", now)

通过坐标的相互关系控制机器人移动

参考: http://wiki.ros.org/pr2_controllers/Tutorials/Using%20the%20base%20controller%20with%20odometry%20and%20transform%20information

0 0
原创粉丝点击