ROS2机器人实验报告提示03➡迷雾⬅

2021-12-02 13:10:10 浏览数 (1)

机器人必然会有传感器、调试工具如果用图形化则比命令行更容易使用,本节主要围绕可视化,拨开枯燥的数字迷雾,并将其形象的展示出来。

  1. rqt
  2. rviz2

文档中的内容,都有对应源码,参考如下文件夹:

本节使用案例三维点云,扩展案例为摄像头数据。输入如下命令:
  • source install/setup.bash
  • ros2 run examples_rclpy_pointcloud_publisher pointcloud_publisher
  • rviz2
  • rqt
  • ros2 topic echo /test_cloud

以其中两组完整数据展示:

非常枯燥并且不知道是啥???

代码语言:javascript复制
header:
  stamp:
    sec: 1634160052
    nanosec: 358446349
  frame_id: map
height: 1
width: 10000
fields:
- name: x
  offset: 0
  datatype: 7
  count: 1
- name: y
  offset: 4
  datatype: 7
  count: 1
- name: z
  offset: 8
  datatype: 7
  count: 1
- name: intensity
  offset: 12
  datatype: 7
  count: 1
is_bigendian: false
point_step: 16
row_step: 160000
data:
- 0
- 0
- 0
- 192
- 0
- 0
- 0
- 192
- 20
- 103
- 146
- 190
- 20
- 103
- 146
- 190
- 10
- 212
- 250
- 191
- 0
- 0
- 0
- 192
- 153
- 174
- 135
- 190
- 153
- 174
- 135
- 190
- 21
- 168
- 245
- 191
- 0
- 0
- 0
- 192
- 220
- 38
- 120
- 190
- 220
- 38
- 120
- 190
- 31
- 124
- 240
- 191
- 0
- 0
- 0
- 192
- 234
- 81
- 95
- 190
- 234
- 81
- 95
- 190
- 41
- 80
- 235
- 191
- 0
- 0
- 0
- 192
- 220
- 7
- 69
- 190
- 220
- 7
- 69
- 190
- 52
- 36
- 230
- 191
- 0
- 0
- 0
- 192
- 157
- 116
- 41
- 190
- 157
- 116
- 41
- 190
- 62
- 248
- 224
- 191
- 0
- 0
- 0
- 192
- 64
- 198
- 12
- 190
- 64
- 198
- 12
- 190
- 72
- 204
- 219
- 191
- 0
- 0
- 0
- 192
- 95
- 89
- 222
- 189
- 95
- 89
- 222
- 189
- '...'
is_dense: false
---
header:
  stamp:
    sec: 1634160052
    nanosec: 418641040
  frame_id: map
height: 1
width: 10000
fields:
- name: x
  offset: 0
  datatype: 7
  count: 1
- name: y
  offset: 4
  datatype: 7
  count: 1
- name: z
  offset: 8
  datatype: 7
  count: 1
- name: intensity
  offset: 12
  datatype: 7
  count: 1
is_bigendian: false
point_step: 16
row_step: 160000
data:
- 0
- 0
- 0
- 192
- 0
- 0
- 0
- 192
- 232
- 86
- 158
- 190
- 232
- 86
- 158
- 190
- 10
- 212
- 250
- 191
- 0
- 0
- 0
- 192
- 149
- 207
- 148
- 190
- 149
- 207
- 148
- 190
- 21
- 168
- 245
- 191
- 0
- 0
- 0
- 192
- 162
- 79
- 138
- 190
- 162
- 79
- 138
- 190
- 31
- 124
- 240
- 191
- 0
- 0
- 0
- 192
- 51
- 209
- 125
- 190
- 51
- 209
- 125
- 190
- 41
- 80
- 235
- 191
- 0
- 0
- 0
- 192
- 17
- 91
- 101
- 190
- 17
- 91
- 101
- 190
- 52
- 36
- 230
- 191
- 0
- 0
- 0
- 192
- 188
- 101
- 75
- 190
- 188
- 101
- 75
- 190
- 62
- 248
- 224
- 191
- 0
- 0
- 0
- 192
- 147
- 28
- 48
- 190
- 147
- 28
- 48
- 190
- 72
- 204
- 219
- 191
- 0
- 0
- 0
- 192
- 45
- 173
- 19
- 190
- 45
- 173
- 19
- 190
- '...'
is_dense: false
---

rviz2可视化效果如下:

关于此部分全部内容参考:

点云发布(pointcloud_publisher)之ROS2案例

数据之美由此可见。

节点图:

turtlesim画曲线:
  • ros2 run turtlesim turtlesim_node

发布速度:

对比速度和位姿数据差异性。

发布频率:
代码语言:javascript复制
zhangrelay@cslg:~/code/ros2_ws$ ros2 topic echo /turtle1/cmd_vel 
linear:
  x: 0.6
  y: 0.0
  z: 0.0
angular:
  x: 0.0
  y: 0.0
  z: 0.3
---
linear:
  x: 0.6
  y: 0.0
  z: 0.0
angular:
  x: 0.0
  y: 0.0
  z: 0.3
---
zhangrelay@cslg:~/code/ros2_ws$ ros2 topic echo /turtle1/pose
x: 3.555169105529785
y: 7.3056793212890625
theta: -1.4535272121429443
linear_velocity: 0.6000000238418579
angular_velocity: 0.30000001192092896
---
x: 3.55633807182312
y: 7.2961506843566895
theta: -1.4487272500991821
linear_velocity: 0.6000000238418579
angular_velocity: 0.30000001192092896
---
更多二维曲线绘制,参考:

plotjuggler⬅ROS1/ROS2画轨迹神器➡rqt_plot rqt_multiplot之超级加强版

请阅读并尽量完成镜像中如下部分:

ROS2基础部分到此结束。

0 人点赞