Ignition入门教程-使用ros_ign_bridge
Ignition入门教程-使用ros_ign_bridge
说明:
- 介绍如何使用ros_ign_bridge
- ros_ign_bridge是联系ros与Ignition的桥梁
用法
- 新开终端, 输入如下命令,
ros2 run ros_ign_bridge parameter_bridge -h
- 效果如下:
$ ros2 run ros_ign_bridge parameter_bridge -h
Bridge a collection of ROS2 and Ignition Transport topics.
parameter_bridge <topic@ROS2_type@Ign_type> .. <topic@ROS2_type@Ign_type>
The first @ symbol delimits the topic name from the message types.
Following the first @ symbol is the ROS message type.
The ROS message type is followed by an @, [, or ] symbol where
@ == a bidirectional bridge,
[ == a bridge from Ignition to ROS,
] == a bridge from ROS to Ignition.
Following the direction symbol is the Ignition Transport message type.
A bidirectional bridge example:
parameter_bridge /chatter@std_msgs/String@ignition.msgs.StringMsg
A bridge from Ignition to ROS example:
parameter_bridge /chatter@std_msgs/String[ignition.msgs.StringMsg
A bridge from ROS to Ignition example:
parameter_bridge /chatter@std_msgs/String]ignition.msgs.StringMsg
演示1:
- Ignition发布消息,ROS2订阅消息
- 默认新开终端都已经加载了ros2环境
- 新开终端,发布ros2消息与Ignition消息之间的桥接
ros2 run ros_ign_bridge parameter_bridge /chatter@std_msgs/msg/String@ignition.msgs.StringMsg
- 新开终端,订阅ros2消息
ros2 topic echo /chatter
- 新开终端,发布Ignition消息
ign topic pub -t /chatter -m ignition.msgs.StringMsg -p 'data:"Hello"'
- 可以再上面的订阅窗口,看到发布的Hello信息
$ ros2 topic echo /chatter
data: Hello
---
data: Hello
---
演示2:
- ROS2发布消息, Ignition订阅消息
- 默认新开终端都已经加载了ros2环境
- 新开终端,发布ros2消息与Ignition消息之间的桥接
ros2 run ros_ign_bridge parameter_bridge /chatter@std_msgs/msg/String@ignition.msgs.StringMsg
- 新开终端,订阅Ignition消息
ign topic -e -t /chatter
- 新开终端,发布ROS2消息
$ ros2 topic pub /chatter std_msgs/msg/String "data: 'Hi'" --once
publisher: beginning loop
publishing #1: std_msgs.msg.String(data='Hi')
- 可以再上面的订阅窗口,看到发布的Hi信息
$ ign topic -e -t /chatter
data: "Hi"
data: "Hi"
演示3:
- 新开终端,启动Ignition
ign gazebo sensors_demo.sdf
- 效果图:
- 查看Ignition 图像话题
$ ign topic -l | grep image
/rgbd_camera/depth_image
/rgbd_camera/image
- 查看Ignition所有话题
$ ign topic -l
/camera
/camera_alone
/camera_alone/performance_metrics
/camera_info
/clock
/depth_camera
/depth_camera/performance_metrics
/depth_camera/points
/gazebo/resource_paths
/gui/camera/pose
/gui/record_video/stats
/lidar
/lidar/points
/lidar/points/performance_metrics
/rgbd_camera/camera_info
/rgbd_camera/depth_image
/rgbd_camera/image
/rgbd_camera/performance_metrics
/rgbd_camera/points
/stats
/thermal_camera
/world/lidar_sensor/clock
/world/lidar_sensor/dynamic_pose/info
/world/lidar_sensor/pose/info
/world/lidar_sensor/scene/deletion
/world/lidar_sensor/scene/info
/world/lidar_sensor/state
/world/lidar_sensor/stats
- 新开终端, 开启桥接
ros2 run ros_ign_bridge parameter_bridge /rgbd_camera/image@sensor_msgs/msg/Image@ignition.msgs.Image
- ros2订阅图像话题
ros2 run rqt_image_view rqt_image_view /rgbd_camera/image
- 效果图:
- 注意:要点一下Ignition的左下角三角形的播放按钮,才显示图像。
参考:
获取最新文章: 扫一扫右上角的二维码加入“创客智造”公众号