• 欢迎访问开心洋葱网站,在线教程,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站,欢迎加入开心洋葱 QQ群
  • 为方便开心洋葱网用户,开心洋葱官网已经开启复制功能!
  • 欢迎访问开心洋葱网站,手机也能访问哦~欢迎加入开心洋葱多维思维学习平台 QQ群
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏开心洋葱吧~~~~~~~~~~~~~!
  • 由于近期流量激增,小站的ECS没能经的起亲们的访问,本站依然没有盈利,如果各位看如果觉着文字不错,还请看官给小站打个赏~~~~~~~~~~~~~!

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

人工智能 zhangrelay 1497次浏览 0个评论

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

使用机器人操作系统ROS 2和仿真软件Gazebo 9搭建机器人教程(一)

 

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

 

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

 

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

 

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

 

$ ros2 launch mobot world.launch.py

 

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

 

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

 

节点

$ 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] [–include-hidden-topics]
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.
—————————
Moving around:
u i o
j k l
m , .

For Holonomic mode (strafing), hold down the shift key:
—————————
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的变化。

 

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

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

 

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

 

行动

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

 

启动

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

 

工具

rqt和rviz2。

 

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

 

节点图

 

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

 

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

 

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

 

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

 

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

 

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

 

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

 

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

 

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


开心洋葱 , 版权所有丨如未注明 , 均为原创丨未经授权请勿修改 , 转载请注明使用机器人操作系统ROS 2和仿真软件Gazebo 9命令遥控可视化教程(二)
喜欢 (0)

您必须 登录 才能发表评论!

加载中……