主要内容

模拟a Mobile Robot in a Warehouse Using Gazebo

此示例显示了如何在凉亭中模拟仓库机器人。凉亭使您能够模拟使用范围传感器的移动机器人,同时在模拟环境中执行某些任务。此示例详细介绍了如何使用模拟器应用Execute Tasks for a Warehouse Robot例如,机器人在仓库方案中提供包裹。该机器人利用凉亭中的模拟范围传感器来检测与动态环境的可能碰撞并避免它们。

Prerequisites

模型概述

Open the model.

open_system('simulateWarehouseRobotInGazebo.slx')

这model can be divided into the following elements:

  • Sense:Read data from sensors in Gazebo.

  • 日程:为机器人分配软件包和计划路径以交付包装。

  • Control:Generate commands to follow the predefined path and avoid obstacles.

  • 攻击:Send commands to Gazebo to actuate the robot in the environment.

Schedule

这robot performs the task of going between the charging station, the loading station, and the unloading station as guided by theScheduler.

Sense

这current robot pose, the wheel speeds, and the range sensor readings are read from the simulated environment in Gazebo. The figure below is the expanded view of theRead From Gazebo Sensors子系统。

Control

这controller generates control commands for following the waypoints using the纯粹的追求堵塞。If the range sensor on the robot detects an obstacle within the避免使用阈值,机器人停止。另外,机器人在足够接近目标的地方停止。

一种ctuate

Based on the generated control commands, thePioneer Wheel Control子系统为每个车轮生成扭矩值。扭矩被用作一种pplyJointTorquecommand.

Setup

Warehouse Facility

加载example map file,地图, which is a matrix of logical values indicating occupied space in the warehouse. Invert this matrix to indicate free space, and make abinaryOccupancyMapobject. Specify a resolution of 100 cells per meter.

这地图is based off of thewarehouseExtensions.world文件,该文件是在与下面提到的相同缩放系数上使用构建编辑器制成的。一种.png可以使用collision_map_creator_pluginplugin to generate the map matrix. The details on how to install the plugin can be found atCollision Map Creator Plugin.

mapscalingFactor = 100;加载gazeboWarehouseMap.mat地图逻辑图=〜地图;map = binaryoccupancymap(逻辑图,mapscalingFactor);显示地图)

一种ssign thexy-locations of the charging station, sorting station, and the unloading location near shelves in the warehouse. The values chosen are based on the simlated world in Gazebo.

chargingstn = [12,5];loadingstn = [24,5];unloadingstn = [15,24];

Show the various locations on the map.

hold;文本(chargingstn(1),chagingstn(2),1,'收费');plotTransforms([chargingStn, 0], [1 0 0 0]) text(loadingStn(1), loadingStn(2), 1,“分类站”);plotTransforms([loadingStn, 0], [1 0 0 0]) text(unloadingStn(1), unloadingStn(2), 1,“卸载站”);plotTransForms([[unloadingstn,0],[1 0 0 0])保持离开;

Range Sensor

Read Lidar Scanblock in the感应部分用于读取模拟范围传感器的范围值。这warehouseExtensions.world文件包含场景中各种模型和参与者(仓库工人)的详细信息。因为<演员>tags are static links with only visual meshes, the sensor type of the range sensor isgpu_ray.

此外,范围传感器使用640范围,但默认值为128。这需要修改在此处使用的总线Read Lidar Scan堵塞。加载examplehelperwarehouserobotwithgazebobuses.matfile to get a modified bus withGazebo_SL_Bus_gazebo_msgs_LaserScan.rangeset to 640. The modified buses were saved to a.matfile using the Bus Editor.

加载examplehelperwarehouserobotwithgazebobuses.mat

Collision Avoidance

这actors in the world are walking a predefined trajectory. The robot makes use of a range sensor to check for obstacles within a range of 2.0 m (避免使用)with range angles from[-pi/10,pi/10]在该范围和视图内进行非零读数后,机器人停止,并且仅在清晰后才恢复。“传感障碍物上的停止机器人”功能块包含了此逻辑。

While running the simulation, the停止当机器人感觉到继续前进时,灯变绿色。如果停止,灯会变成红色。

避免使用= 2;

模拟

要模拟场景,请建立与凉亭的连接。

First, run the Gazebo Simulator. In the virtual machine, click the凉亭仓库机器人icon. If the Gazebo simulator fails to open, you may need to reinstall the plugin. See安装凉亭插件手动inPerform Co-Simulation between Simulink and Gazebo.

在Si金宝appmulink中,打开凉亭起搏器块并单击配置凉亭网络和仿真设置. Specify theNetwork Addressas风俗,theHostname/IP Address用于您的凉亭模拟和Port14581, which is the default port for Gazebo. The desktop of the VM displays the IP address.

有关连接到凉亭以启用共同模拟的更多信息,请参见Perform Co-Simulation between Simulink and Gazebo.

点击Initialize Modelbutton at the top of the model to intialize all the variables declared above.

Runthe simulation. The robot drives around the environment and stops whenever a worker gets within the defined threshold.