tf static_transform_publisher


transform,ROS中管理3D坐標系變換的工具。只要告訴tf兩個相關聯坐標系的坐標變換信息,tf會幫你一直記錄這個兩個坐標系的坐標變換,即使兩個坐標系處於運動中。
1 tf的命令行用法有以下6種:
view_frames: visualizes the full tree of coordinate transforms. 打印當前tf圖形化信息,樹狀結構。
tf_monitor: monitors transforms between frames. 起監控作用,可以在ROS_CONSOLE中打印出兩個坐標系的延遲信息,以及每個坐標系是由哪個節點發布的。
tf_echo: prints specified transform to screen。類似於rostopic echo,打印當前的tf信息
roswtf: with the tfwtf plugin, helps you track down problems with tf.  找錯的
static_transform_publisher is a command line tool for sending static transforms. 靜態發布一個從父坐標系到子坐標系的一個坐標變換。這個用的非常頻繁!
2 static_transform_publisher
接下來主要介紹下static_transform_publisher,因為這個用的最頻繁。
2.1 yaw pitch roll

這是Eular的wiki中的原圖,以飛機為例。
yaw 控制飛機方向,故稱為偏航角
pitch 控制飛機俯仰角度,故稱為俯仰
roll 控制飛機橫滾,故稱為橫滾 (中文名稱為經驗之談,可能不准確!!!)
這三個詞同樣可以應用在坐標系中。 
yaw代表這繞z軸旋轉的角度,pitch代表繞Y軸的角度,roll代表繞X軸的角度。
2.2 用法解釋
wiki.ros.org 中的原文說到:

static_transform_publisher x y z yaw pitch roll frame_id child_frame_id period_in_ms
Publish a static coordinate transform to tf using an x/y/z offset in meters and yaw/pitch/roll in radians. (yaw is rotation about Z, pitch is rotation about Y, and roll is rotation about X). The period, in milliseconds, specifies how often to send a transform. 100ms (10hz) is a good value.
static_transform_publisher x y z qx qy qz qw frame_id child_frame_id  period_in_ms
Publish a static coordinate transform to tf using an x/y/z offset in meters and quaternion. The period, in milliseconds, specifies how often to send a transform. 100ms (10hz) is a good value.

static_transform_publisher is designed both as a command-line tool for manual use, as well as for use within roslaunch files for setting static transforms. For example:

<launch>
<node pkg="tf" type="static_transform_publisher" name="link1_broadcaster" args="1 0 0 0 0 0 1 link1_parent link1 100" />
</launch>


從中可以看出static_transform_publisher有兩種發布方式,一種是發布yaw pitch roll,一種是發布四元數。而且用法既可以通過命令行形式敲命令,也可以寫進launch文件中啟動。
值得一提的是:這個命令是發布靜態坐標變換的,只能發布兩個靜止的坐標系間的坐標變換,而且,它是將坐標變換發布到tf中,剩下的由tf進行操作。
參數解釋:
1 前邊的x y z分別代表着相應軸的平移,單位是 米 。
2 yaw pitch roll 分別代表着繞三個軸的轉動,單位是 弧度 。
  前文介紹過了,可能有人感覺這東西不好記,很容易忘掉哪個對應哪個坐標軸,其實你可以發現,yaw pitch roll 分別對應着 Z,Y,X軸的旋轉,也就是把我們總說的XYZ的反過來,只要記住順序還是不容易弄錯的。
3 再之后的frame_id為坐標系變換中的父坐標系, child_frame_id為坐標系變換中的子坐標系。
4 最后一個參數為發布頻率,單位為 毫秒。通常取100。
   一毫秒為一秒的千分之一,100毫秒即為0.1秒,也就是10Hz。

3 實例


現有如上坐標變換,想要再加上一個camera_link與kinect_Link的坐標變換,
<node pkg="tf" type="static_transform_publisher" name="camera_base_link"
args="0 0 0 0 0 0 kinect_Link camera_link 100" />
這是沒有加旋轉的時候:
可以看到這兩個坐標系重合了,所以要加上旋轉才行,要把camera_link的方向弄到與base_link一致才行。
<node pkg="tf" type="static_transform_publisher" name="camera_base_link"
args="0 0 0 1.57079 -1.57079 0 kinect_Link camera_link 100" />

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM