「ROS烏龜人 #08」試著了解 tf 筆記

Standard

官網: http://wiki.ros.org/tf
官方tutorial: http://wiki.ros.org/tf/Tutorials

實做筆記:
https://rosonjetson.wordpress.com/2015/08/31/%E3%80%90l2%E3%80%91%E8%AE%93-ros-%E5%B9%AB%E4%BD%A0%E8%99%95%E7%90%86%E7%85%A9%E9%9B%9C%E7%9A%84%E5%BA%A7%E6%A8%99%E8%BD%89%E6%8F%9B%EF%BC%81/

https://www.jianshu.com/p/fb9685c2bf02

http://blog.csdn.net/qq_33179208/article/details/52980293 

http://www.guyuehome.com/355

中文介紹:
https://charlyhuangrostutorial.wordpress.com/2017/04/01/%E6%88%91%E7%9F%A5%E9%81%93%E6%88%91%E7%9A%84%E6%89%8B%E8%87%82%E5%9C%A8%E5%93%AA%E8%A3%A1%E5%97%8E%EF%BC%9F%E9%82%A3%E6%88%91%E7%9A%84%E7%9C%BC%E7%9D%9B%E5%91%A2%EF%BC%9F/

https://read01.com/jz43P.html#.WpWUFRNuZSw

http://blog.exbot.net/archives/1686

http://www.gaolab.pro/archives/76



-------------------------------------------------------自己實作-------------------------------------------------------


0. Introduction to tf
補-1 關於rosrun tf tf_echo輸出內容的意義
http://blog.csdn.net/github_30605157/article/details/72081946

補-2 下面這行指令很特別 用的符號是~的那個`
rosrun rviz rviz -d `rospack find turtle_tf`/rviz/turtle_rviz.rviz

補-3 tf三大查看方法
$ rosrun rviz rviz -d `rospack find turtle_tf`/rviz/turtle_rviz.rviz
$ rosrun tf tf_echo [reference_frame] [target_frame]
$ rosrun rqt_tf_tree rqt_tf_tree
$ rosrun tf view_frames $ evince frames.pdf



1. Writing a tf broadcaster (C++)
補-1 下面這行是說執行rosrun時需要再給一個名字當subscribe的topic name
if(argc!=2)   之所以是2不是1 是因為執行的檔名自己就算一個了

補-2 PoseConstPtr Ptr是C++ pointer的用法,以下兩種方法相通,但意義上不確定
void poseCallback(const turtlesim::PoseConstPtr& msg)
//void poseCallback(const turtlesim::Pose& msg)
q.setRPY(0, 0, msg->theta);
//q.setRPY(0, 0, msg.theta);

補-3 執行步驟
開roscore 開turtlesim 開teleop 開broadcaster
然後再開tf_echo rqt_tf_tree等等 確認確實有tf傳出



2. Writing a tf listener (C++)
補-1 驚訝的發現原來launch file裡面的name=node name是可以改的
name不用和type執行檔裡面寫的node name一樣



3. Adding a frame (C++)
補-1  transform.setRotation( tf::Quaternion(0, 0, 0, 1) );//可以
transform.setRotation(tf::Quaternion.setRPY(0,0,msg->theta));//不行,要設物件

補-2 tf::Quaternion(0, 0, 0, 1)是代表沒有相對旋轉的意思
這部份看是要改回去用之前的rpy或是回去好好把四元數看懂QQ
http://wiki.ros.org/tf2/Tutorials/Quaternions
ROS uses quaternions to track and apply rotations. A quaternion has 4 components (x,y,z, w). That's right, 'w' is last. The commonly-used unit quaternion that yields no rotation about the x/y/z axes is (0,0,0,1):

補-3 關於表達旋轉的各種用法
tf::Quaternion q = tf::createQuaternionFromRPY(0, 0, 0); //tf2
tf::Quaternion(0, 0, 0, 1)
tf::Quaternion q;     q.setRPY(0,0,0);



4. Learning about tf and time (C++)
補-10是最新可取得的, now是現在馬上
For tf, time 0 means "the latest available" transform in the buffer. Now, change this line to get the transform at the current time, "now()"

補-2 即使br是用now發出但他送出去需要一點點時間所以li用now的時候需要等
When a broadcaster sends out a transform, it takes some time before that transform gets into the buffer (usually a couple of milliseconds). So, when you request a frame transform at time "now", you should wait a few milliseconds for that information to arrive.

補-3 不可寫成下面這樣, 因為waitfor裡面好像一定要放物件
//listener.waitForTransform("/turtle2", "/turtle1",ros::Time::now(), ros::Duration(5.0));
//listener.lookupTransform("/turtle2", "/turtle1",ros::Time::now(), transform);

補-4  多用在其他地方
Note: The use of ros::Time::now() is for this example. Usually this would be the timestamp of the data wishing to be transformed. 
Just to teach you about the tf buffer and the time delays that are associated with it. For real tf use cases, it is often perfectly fine to use Time(0).  



5. Time travel with tf (C++)
補-1 試著把now改回ros::Time(0)也是可以運作的, 只是一開始的error會比較多行



6. Debugging tf problems
補-1 li前確認br的tf的frame是哪一個
$ rosrun tf tf_echo turtle3 turtle1
或 $ rosrun tf view_frames  $ evince frames.pdf

補-2 發生時間差的問題時可以用以下指令才確認確切的delay是多少
$ rosrun tf tf_monitor turtle2 turtle1

補-3 複習 waitForTransform, lookupTransform



6. Using Stamped datatypes with tf::MessageFilter
補-1 轉圈圈的是turtle3 可以控制的是turtle1 跟著走得是turtle2
有點困難, 看不太懂QQ



#. 哇靠竟然還存在一個東西叫tf2
http://wiki.ros.org/tf2/Tutorials


0 comments:

張貼留言

留言