首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往
20 篇文章
1
ROS1&2机器人操作系统免安装在线自主学习平台简介和官方第三方教程列表
2
机器人操作系统二(ROS2)- 启程 Departure
3
机器人操作系统二(ROS2)- 修行 Taoism
4
机器人操作系统二(ROS2)- 仿真 Simulation
5
机器人操作系统二(ROS2)- 实践 Practice
6
ROS2与Arduino发布订阅
7
ROS2网络多机通信DDS和安全加密SROS(多机器人系统)
8
ROS2实时性案例分析之倒立摆系统使用(Inverted pendulum)
9
机器人实践课程镜像分享及使用说明(Arduino+ROS1+ROS2+Gazebo+SLAM+...)
10
使用机器人操作系统ROS 2和仿真软件Gazebo 9搭建机器人教程(一)
11
使用机器人操作系统ROS 2和仿真软件Gazebo 9命令遥控可视化教程(二)
12
使用机器人操作系统ROS 2和仿真软件Gazebo 9环境综合测试教程(三)
13
使用机器人操作系统ROS 2和仿真软件Gazebo 9目标跟踪实践(四)
14
使用机器人操作系统ROS 2和仿真软件Gazebo 9多机器人实践(五)
15
使用机器人操作系统ROS 2和仿真软件Gazebo 9激光传感器算法进阶(六)
16
使用机器人操作系统ROS 2和仿真软件Gazebo 9主题进阶实战(七)- mobot速度发布与里程计订阅
17
使用机器人操作系统ROS 2和仿真软件Gazebo 9服务进阶实战(八)- mobot行驶至目标位置
18
使用机器人操作系统ROS 2和仿真软件Gazebo 9行动进阶实战(九)- mobot区域巡逻
19
ROS 2 Foxy Fitzroy遇见Ubuntu 20.04
20
使用ROS2机器人操作系统进行多机器人编程技术实践(Multi-Robot Programming Via ROS2 )

使用机器人操作系统ROS 2和仿真软件Gazebo 9命令遥控可视化教程(二)

上一篇,已经在Gazebo 9中放入了一个支持ROS 2的仿真机器人,具体参考:


本篇,通过此案例学习并熟练掌握ROS2的如下内容:

  • ROS2常用命令回顾
  • 遥控机器人在环境中运动
  • rqt和rviz2
  • 摄像头图像显示和激光数据可视化

ROS2入门介绍参考https://zhuanlan.zhihu.com/p/96940278

$ ros2 launch mobot world.launch.py

具体流程参考下图,配置不同会有路径和目录的差异:

节点

$ ros2 node usage: ros2 node -h                  Call ros2 node <command> -h for more detailed usage. ... Various node related sub-commands optional arguments:   -h, --help            show this help message and exit Commands:   info  Output information about a node   list  Output a list of available nodes   Call ros2 node <command> -h for more detailed usage.

使用其中list:

$ ros2 node list /launch_ros /gazebo /mobot/camera_controller /mobot/gazebo_ros_head_hokuyo_controller /mobot/skid_steer_drive_controller

第一个为ros接口,第二个为gazebo,第三到五个,为Gazebo插件的控制器对应摄像头、激光测距和运动驱动。

如果需要查看更具体的节点信息,如camera:

$ ros2 node info /mobot/camera_controller  /mobot/camera_controller   Subscribers:     /clock: rosgraph_msgs/msg/Clock     /mobot/parameter_events: rcl_interfaces/msg/ParameterEvent   Publishers:     /mobot/camera/image: sensor_msgs/msg/Image     /mobot/camera/image/camera_info: sensor_msgs/msg/CameraInfo     /mobot/parameter_events: rcl_interfaces/msg/ParameterEvent     /mobot/rosout: rcl_interfaces/msg/Log   Services:     /mobot/camera_controller/describe_parameters: rcl_interfaces/srv/DescribeParameters     /mobot/camera_controller/get_parameter_types: rcl_interfaces/srv/GetParameterTypes     /mobot/camera_controller/get_parameters: rcl_interfaces/srv/GetParameters     /mobot/camera_controller/list_parameters: rcl_interfaces/srv/ListParameters     /mobot/camera_controller/set_parameters: rcl_interfaces/srv/SetParameters     /mobot/camera_controller/set_parameters_atomically: rcl_interfaces/srv/SetParametersAtomically     /mobot/set_camera_info: sensor_msgs/srv/SetCameraInfo

此处需要注意,Dashing和Eloquent信息有一些的差异哦!

如果使用是Eloquent,如下:

$ ros2 node info /mobot/camera_controller  /mobot/camera_controller   Subscribers:     /clock: rosgraph_msgs/msg/Clock     /mobot/parameter_events: rcl_interfaces/msg/ParameterEvent   Publishers:     /mobot/camera/image: sensor_msgs/msg/Image     /mobot/camera/image/camera_info: sensor_msgs/msg/CameraInfo     /mobot/parameter_events: rcl_interfaces/msg/ParameterEvent     /mobot/rosout: rcl_interfaces/msg/Log   Service Servers:     /mobot/camera_controller/describe_parameters: rcl_interfaces/srv/DescribeParameters     /mobot/camera_controller/get_parameter_types: rcl_interfaces/srv/GetParameterTypes     /mobot/camera_controller/get_parameters: rcl_interfaces/srv/GetParameters     /mobot/camera_controller/list_parameters: rcl_interfaces/srv/ListParameters     /mobot/camera_controller/set_parameters: rcl_interfaces/srv/SetParameters     /mobot/camera_controller/set_parameters_atomically: rcl_interfaces/srv/SetParametersAtomically     /mobot/set_camera_info: sensor_msgs/srv/SetCameraInfo   Service Clients:   Action Servers:   Action Clients:

如上所见,该节点正在发布、订阅和由该节点提供的服务以及该节点充当客户端的服务的所有主题都会列出。

主题

$ ros2 topic  usage: ros2 topic -h                   Call ros2 topic <command> -h for more detailed usage. ... Various topic related sub-commands optional arguments:   -h, --help            show this help message and exit   --include-hidden-topics                         Consider hidden topics as well Commands:   bw     Display bandwidth used by topic   delay  Display delay of topic from timestamp in header   echo   Output messages from a topic   find   Output a list of available topics of a given type   hz     Print the average publishing rate to screen   info   Print information about a topic   list   Output a list of available topics   pub    Publish a message to a topic   type   Print a topic's type   Call ros2 topic <command> -h for more detailed usage.

例如list:

$ ros2 topic list  /clock /mobot/camera/image /mobot/camera/image/camera_info /mobot/cmd_vel /mobot/odom /mobot/parameter_events /mobot/rosout /mobot/scan /parameter_events /rosout /tf

来看看图像数据和激光数据需要的带宽吧?

$ ros2 topic bw /mobot/camera/image Subscribed to /mobot/camera/image average: 27.89MB/s     mean: 1.92MB/s min: 1.92MB/s max: 1.92MB/s window: 12 average: 28.39MB/s     mean: 1.92MB/s min: 1.92MB/s max: 1.92MB/s window: 27 average: 25.82MB/s     mean: 1.92MB/s min: 1.92MB/s max: 1.92MB/s window: 38 average: 26.60MB/s     mean: 1.92MB/s min: 1.92MB/s max: 1.92MB/s window: 53 ros2 topic bw /mobot/scan  Subscribed to /mobot/scan average: 169.85KB/s     mean: 5.83KB/s min: 5.83KB/s max: 5.83KB/s window: 29 average: 163.58KB/s     mean: 5.83KB/s min: 5.83KB/s max: 5.83KB/s window: 56 average: 163.45KB/s     mean: 5.83KB/s min: 5.83KB/s max: 5.83KB/s window: 84 average: 164.86KB/s     mean: 5.83KB/s min: 5.83KB/s max: 5.83KB/s window: 100

再比如:

$ ros2 topic info /mobot/cmd_vel Type: geometry_msgs/msg/Twist Publisher count: 0 Subscriber count: 1

如果发布消息告知机器人运动呢?

/mobot/skid_steer_drive_controller订阅/mobot/cmd_vel

目前,没有消息发布,使用teleop_twist_keyboard。

服务

此部分教程不涉及,后续补充^_^

参数

默认节点通过修改参数可提高通用性!

Dashing:

sudo apt install ros-dashing-teleop-twist-keyboard

Eloquent:

sudo apt install ros-eloquent-teleop-twist-keyboard

命令:

$ ros2 run teleop_twist_keyboard teleop_twist_keyboard --ros-args -r __ns:=/mobot

This node takes keypresses from the keyboard and publishes them as Twist messages. It works best with a US keyboard layout.undefined Moving around:    u    i    o    j    k    l    m    ,    . For Holonomic mode (strafing), hold down the shift key:undefined    U    I    O    J    K    L    M    <    > t : up (+z) b : down (-z) anything else : stop q/z : increase/decrease max speeds by 10% w/x : increase/decrease only linear speed by 10% e/c : increase/decrease only angular speed by 10% CTRL-C to quit currently:    speed 0.5    turn 1.0 

这部分和工具同步给出示例。

使用键盘可以控制机器人在环境中运动,观察rqt和rviz2的变化。

遥控靠近白色球体,转到工具章节。

行动

此部分教程不涉及,后续补充^_^

启动

此部分教程不涉及,后续补充^_^

工具

rqt和rviz2。

节点图

摄像头图像(Gazebo时间2:31:57)

激光数据可视化(Gazebo时间2:31:57)

摄像头图像(Gazebo时间2:46:31)

激光数据可视化(Gazebo时间2:46:31)

接下来,将会继续介绍使用C++节点编写程序处理激光和图像信息,自主驱动mobot。

下一篇
举报
领券