ROS2入门教程-发布joint states和TF
ROS2入门教程-发布joint states和TF
说明:
- 通过一个简单的演示来介绍如何发布joint states和TF
前提准备
- 正确安装ros2(beta1以上)、ros1(kinetic)和ros1 bridge
进行演示
- 在
~/.bashrc
文件中配置ros1和ros2的环境变量
source /opt/ros/kinetic/setup.bash
source ~/ros2_ws/install/setup.bash
- 新终端,启动ros1核心
roscore
- 新终端,使用ros1 bridge
ros2 run ros1_bridge dynamic_bridge --bridge-all-2to1-topics
- 新终端,执行演示的bringup文件
launch ~/ros2_ws/install/share/dummy_robot_bringup/launch/dummy_robot_bringup.py
- 执行成功的界面
launch ~/ros2_ws/install/share/dummy_robot_bringup/launch/dummy_robot_bringup.py
(0) pid 52556: ['dummy_laser'] (stderr > stdout, all > console)
(1) pid 52557: ['dummy_map_server'] (stderr > stdout, all > console)
(2) pid 52558: ['robot_state_publisher', '/Users/karsten/workspace/osrf/ros2_ws/src/ros2/demos/dummy_robot/dummy_robot_bringup/launch/single_rrbot.urdf'] (stderr > stdout, all > console)
(3) pid 52559: ['dummy_joint_states'] (stderr > stdout, all > console)
[2] Initialize urdf model from file: /Users/karsten/workspace/osrf/ros2_ws/src/ros2/demos/dummy_robot/dummy_robot_bringup/launch/single_rrbot.urdf
[2] Parsing robot urdf xml string.
[2] Link single_rrbot_link1 had 1 children
[2] Link single_rrbot_link2 had 1 children
[2] Link single_rrbot_link3 had 2 children
[2] Link single_rrbot_camera_link had 0 children
[2] Link single_rrbot_hokuyo_link had 0 children
[2] got segment single_rrbot_camera_link
[2] got segment single_rrbot_hokuyo_link
[2] got segment single_rrbot_link1
[2] got segment single_rrbot_link2
[2] got segment single_rrbot_link3
[2] got segment world
[2] Adding fixed segment from world to single_rrbot_link1
[2] Adding moving segment from single_rrbot_link1 to single_rrbot_link2
[2] Adding moving segment from single_rrbot_link2 to single_rrbot_link3
[2] Adding fixed segment from single_rrbot_link3 to single_rrbot_camera_link
[2] Adding fixed segment from single_rrbot_link3 to single_rrbot_hokuyo_link
新终端,打开rviz
After you configured your RViz accordingly, you should see a similar picture:
# upload the robot description for the robot model
rosparam set robot_description "`cat ~/ros2_ws/install/share/dummy_robot_bringup/launch/single_rrbot.urdf`"
rviz
What's happening?
通过查看launch文件,可得知可以同时启动几个节点
dummy_map_server
dummy_laser
dummy_joint_states
robot_state_publisher
dummy_map_server
节点会不断发布带有周期更新的空地图dummy_laser
节店发布模拟的激光扫描信息dummy_laser
节点会发布模拟的joint state数据。当发布一个只有两个关节的RRbot时, 这个节点发布了这两节的joint state值robot_state_publisher
节点解析给定的URDF文件, 提取机器人模型, 并监听传入的joint state。通过这些信息, 其为机器人发布了TF值, 然后将它们连接起来, 最后在RViz中进行可视化
Experimental
在Ardent Apalone开始,ROS2将会支持RViz2。这可以在没有任何桥接的情况下,独自在ROS2环境中可视化您的机器人。此功能将会持续不断地更新。
打开RViz2,可视化机器人的TF
$ rviz2
- 如果dummy_robot_bringup仍在启动,可以配置相关的TF显示插件项和配置全局坐标系
参考链接
获取最新文章: 扫一扫右上角的二维码加入“创客智造”公众号