1. 程式人生 > >對TF座標變換的理解

對TF座標變換的理解

對TF座標變換的理解

啟動turtle_if_demo.launch檔案

~ roslaunch turtle_tf turtle_tf_demo.launch 

turtle_tf_demo.launch 的內容如下

<launch>

  <!-- Turtlesim Node-->
  <node pkg="turtlesim" type="turtlesim_node" name="sim"/>

  <node pkg="turtlesim"
type="turtle_teleop_key" name="teleop" output="screen"/> <!-- Axes --> <param name="scale_linear" value="2" type="double"/> <param name="scale_angular" value="2" type="double"/> <node name="turtle1_tf_broadcaster" pkg="turtle_tf" type="turtle_tf_broadcaster.py" respawn=
"false" output="screen" > <param name="turtle" type="string" value="turtle1" /> </node> <node name="turtle2_tf_broadcaster" pkg="turtle_tf" type="turtle_tf_broadcaster.py" respawn="false" output="screen" > <param name="turtle" type="string" value="turtle2" /> <
/node> <node name="turtle_pointer" pkg="turtle_tf" type="turtle_tf_listener.py" respawn="false" output="screen" > </node> </launch>

1.第一個節點turtlesim_node,啟動後的名字sim
2.第二個節點turtle_teleop_key,啟動後的名字teleop(teleoperate:verb 遠端操縱,遙控)
3.定義伺服器全域性變數/scale_linear(value=2)、/scale_angular (value=2)
4.第三個節點turtle_tf_broadcaster.py,啟動後的名字turtle1_tf_broadcaster
同時定義了全域性變數/turtle,value=“turtle1”
5.第四個節點turtle_tf_broadcaster.py,啟動後的名字turtle2_tf_broadcaster
同時定義了全域性變數/turtle,value=“turtle2”
6.第五個節點turtle_tf_listener.py,啟動後的名字turtle_pointer

~ roslaunch turtle_tf turtle_tf_demo.launch 
... logging to /home/tangshp/.ros/log/6051b604-155c-11e9-8475-8cec4b8e96d3/roslaunch-tangshp-OptiPlex-7060-32675.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://tangshp-OptiPlex-7060:33679/

SUMMARY
========

PARAMETERS
 * /rosdistro: kinetic
 * /rosversion: 1.12.14
 * /scale_angular: 2.0
 * /scale_linear: 2.0
 * /turtle1_tf_broadcaster/turtle: turtle1
 * /turtle2_tf_broadcaster/turtle: turtle2

NODES
  /
    sim (turtlesim/turtlesim_node)#執行後的名字+功能包/可執行程式名
    teleop (turtlesim/turtle_teleop_key)
    turtle1_tf_broadcaster (turtle_tf/turtle_tf_broadcaster.py)
    turtle2_tf_broadcaster (turtle_tf/turtle_tf_broadcaster.py)
    turtle_pointer (turtle_tf/turtle_tf_listener.py)

auto-starting new master
process[master]: started with pid [32685]
ROS_MASTER_URI=http://localhost:11311

setting /run_id to 6051b604-155c-11e9-8475-8cec4b8e96d3
process[rosout-1]: started with pid [32698]
started core service [/rosout]
process[sim-2]: started with pid [32705]
process[teleop-3]: started with pid [32716]
process[turtle1_tf_broadcaster-4]: started with pid [32717]
Reading from keyboard
---------------------------
Use arrow keys to move the turtle.
process[turtle2_tf_broadcaster-5]: started with pid [32728]
process[turtle_pointer-6]: started with pid [32733]

檢視rosparam及節點

~ rosparam list
/background_b
/background_g
/background_r
/rosdistro
/roslaunch/uris/host_tangshp_optiplex_7060__33679
/rosversion
/run_id
/scale_angular
/scale_linear
/turtle1_tf_broadcaster/turtle
/turtle2_tf_broadcaster/turtle
➜  ~ rosparam get /
background_b: 255
background_g: 86
background_r: 69
rosdistro: 'kinetic

  '
roslaunch:
  uris: {host_tangshp_optiplex_7060__33679: 'http://tangshp-OptiPlex-7060:33679/'}
rosversion: '1.12.14

  '
run_id: 6051b604-155c-11e9-8475-8cec4b8e96d3
scale_angular: 2.0
scale_linear: 2.0
turtle1_tf_broadcaster: {turtle: turtle1}
turtle2_tf_broadcaster: {turtle: turtle2}

在這裡插入圖片描述
由上圖可知:通過鍵盤輸入,節點/teleop接收到鍵盤輸入後,釋出話題/turtle1/cmd_vel控制節點/sim中的烏龜運動
內容如下:

linear: 
  x: 2.38418579102e-07
  y: 0.0
  z: 0.0
angular: 
  x: 0.0
  y: 0.0
  z: 0.0
---

檢視TF座標變化

~ rosrun tf tf_echo turtle1 turtle2
At time 1547184173.690
- Translation: [0.000, 0.000, 0.000]
- Rotation: in Quaternion [0.000, 0.000, 0.769, 0.639]
            in RPY (radian) [0.000, -0.000, 1.755]
            in RPY (degree) [0.000, -0.000, 100.558]

rviz顯示座標關係

~ rosrun rviz rviz -d'rospack find turtle_tf' /rviz/turtle_rviz.rviz
#-d 表示執行單引號的語句
~ rosrun tf view_frames
在當前資料夾下生成frames.pdf