对TF坐标变换的理解

版权声明:唐成 https://blog.csdn.net/weixin_43175145/article/details/86297711

对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

猜你喜欢

转载自blog.csdn.net/weixin_43175145/article/details/86297711