Env.
VMware workstation(Ubuntu 18.04 amd64, ROS Melodic)
1. Set Up the Demo
$ sudo apt-get install ros-melodic-ros-tutorials ros-melodic-geometry-tutorials ros-melodic-rviz ros-melodic-rosbash ros-melodic-rqt-tf-tree
2. Running the Demo
# 1st termial
$ roslaunch turtle_tf turtle_tf_demo.launch
두 거북이가 나타난다.
turtle1(가운데 있는 거북이)를 화살표로 조정할 수 있으며(roslaunch를 실행한 terminal에 화살표 입력),
turtle2(다른 거북이)가 따라간다.
3. What is Happening
tf 라이브러리를 사용하여 3개의 coordinate frames을 만들었다. - a world frame, a turtle1 frame, and a turtle2 frame
tf broadcaster를 사용하여 turtle coordinate frames를 publish하고
tf listener를 이용하여 turtle frames의 차이를 계산하여 하나의 거북이(turtle2)가 다른 거북이(turtle1)을 따라가게 된다.
4. tf Tools
4.1 Using view_frames
# 2nd termial
$ rosrun tf view_frames
Listening to /tf for 5.0 seconds
Done Listening
dot - graphviz version 2.40.1 (20161225.0304)
Detected dot version 2.40
frames.pdf generated
$ evince frames.pdf
3개의 frames는 tf에 의해 broadcast한다. - the world, turtle1, and turtle2
world는 turtle1과 turtle2 frames의 parent이고,
turtle1과 turtle2는 world의 children이다.
디버깅 목적으로,
view_frames는
most recent transform을 통해 가장 최근에 받은 시간 정보와
average rate를 통해 tf의 속도를 알 수 있다.
4.2 Using rqt_tf_tree
# 2nd terminal
$ rqt
or
$ rosrun rqt_tf_tree rqt_tf_tree
4.3 Using tf_echo
tf_echo는 두 frame간의 transform에 대해 알려준다.
Usage:
$ rosrun tf tf_echo [source_frame] [target_frame]
# 2nd terminal
$ rosrun tf tf_echo turtle1 turtle2
At time 1661181402.121
- Translation: [0.000, 0.000, 0.000]
- Rotation: in Quaternion [0.000, 0.000, 0.627, 0.779]
in RPY (radian) [0.000, -0.000, 1.357]
in RPY (degree) [0.000, -0.000, 77.722]
At time 1661181402.825
- Translation: [0.000, 0.000, 0.000]
- Rotation: in Quaternion [0.000, 0.000, 0.627, 0.779]
in RPY (radian) [0.000, -0.000, 1.357]
in RPY (degree) [0.000, -0.000, 77.722]
At time 1661181403.818
- Translation: [0.000, 0.000, 0.000]
- Rotation: in Quaternion [0.000, 0.000, 0.627, 0.779]
in RPY (radian) [0.000, -0.000, 1.357]
in RPY (degree) [0.000, -0.000, 77.722]
...
5. rviz and tf
# 2nd terminal
$ rviz
or
$ rosrun rviz rviz -d `rospack find turtle_tf`/rviz/turtle_rviz.rviz
- Fixed Frame은 world로 설정
- Add TF
ref.
http://wiki.ros.org/tf/Tutorials/Introduction%20to%20tf
tf/Tutorials/Introduction to tf - ROS Wiki
Note: This tutorial assumes you have a working knowledge of compiling programs in ROS. Check out the ROS tutorials to learn how to do this. Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your
wiki.ros.org