您的位置:首页 > 财经 > 产业 > EGO-Swarm 仿真环境搭建

EGO-Swarm 仿真环境搭建

2024/10/6 0:36:05 来源:https://blog.csdn.net/qq_42995238/article/details/140878028  浏览:    关键词:EGO-Swarm 仿真环境搭建

EGO-Swarm仿真环境搭建

参考教程:

https://github.com/ZJU-FAST-Lab/ego-planner-swarm

EGO-Swarm是一种分散的异步系统解决方案,用于仅使用机载资源在未知的障碍物丰富的场景中进行多机器人自主导航。

1. 查看系统环境

要运行本仿真程序,需要保证当前环境为ubuntu18.04+ros-melodic-desktop-full

查看ubuntu版本:

rosnoetic@rosnoetic-VirtualBox:~$ lsb_release -aNo LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 18.04.6 LTS
Release:	18.04
Codename:	bionic

可知,当前ubuntu版本满足18.04

查看ros版本:

rosnoetic@rosnoetic-VirtualBox:~$ rosversion -dmelodic

可知,当前ros版本满足melodic

2. 环境部署

2.1 Armadillo下载

Armadillo的官网链接如下所示:

http://arma.sourceforge.net/

执行如下指令安装Armadillo,程序中的uav_simulator需要Armadillo

rosnoetic@rosnoetic-VirtualBox:~$ sudo apt-get install libarmadillo-dev

2.2 EGO源码下载

执行如下指令下载EGO源码

rosnoetic@rosnoetic-VirtualBox:~$ git clone https://github.com/ZJU-FAST-Lab/ego-planner-swarm.git

下载好后即可在主目录下看到如下文件:

2.3 编译

multi_map_server文件夹下的4.h头文件拖拽到虚拟机的

/home/rosnoetic/ego-planner-swarm/src/uav_simulator/Utils/multi_map_server/include/multi_map_server目录下

ctrl+allt+T打开终端,执行如下指令进行编译

rosnoetic@rosnoetic-VirtualBox:~$ cd ego-planner-swarm/rosnoetic@rosnoetic-VirtualBox:~/ego-planner-swarm$ catkin_make -DCMAKE_BUILD_TYPE=Release -j1

  • 如果出现错误:fatal error: multi_map_server/MultiOccupancyGrid.h: 没有那个文件或目录

    参考教程:

    multi_map_server/MultiOccupancyGrid.h:没有那个文件或目录_fatal error: multi_map_server/multioccupancygrid.h-CSDN博客

    出现该错误的原因还是因为缺少了MultiOccupancyGrid.h的头文件,与之前的添加MultiOccupancyGrid.h方式不同,此时我们需要直接添加在编译后的/home/rosnoetic/ego-planner-swarm/devel/include/multi_map_server文件夹下

    接着重新编译(注意此时不需要删除builddevel文件夹)

    rosnoetic@rosnoetic-VirtualBox:~/ego-planner-swarm$ catkin_make -DCMAKE_BUILD_TYPE=Release -j1
    

    就可以发现剩下的内容编译成功

3. 运行

ctrl+alt+T打开一个新的终端,输入如下指令,进行rviz可视化和交互

rosnoetic@rosnoetic-VirtualBox:~$ cd ego-planner-swarm/rosnoetic@rosnoetic-VirtualBox:~/ego-planner-swarm$ source ./devel/setup.bash rosnoetic@rosnoetic-VirtualBox:~/ego-planner-swarm$ roslaunch ego_planner rviz.launch

可以打开一个rviz界面

ctrl+alt+T再打开一个新的终端,输入如下指令,实现仿真规划

rosnoetic@rosnoetic-VirtualBox:~/ego-planner-swarm$ source ./devel/setup.bash rosnoetic@rosnoetic-VirtualBox:~/ego-planner-swarm$ roslaunch ego_planner swarm.launch

完成上述步骤后,我们看到如下所示的结果。

注:虚拟机环境下运行起来会很卡,需要等待一段时间,可以通过增加交换空间的方式来使得运行更加流畅:

  • 增加交换空间

    首先关闭交换分区

    rosnoetic@rosnoetic-VirtualBox:~$ sudo swapoff /swapfile
    

    接着创建分区, 4 * 1024 = 4096创建 4 G 的内存分区

    rosnoetic@rosnoetic-VirtualBox:~$ sudo dd if=/dev/zero of=/swapfile bs=1M count=4096
    

    继续执行如下指令:

    rosnoetic@rosnoetic-VirtualBox:~$ sudo mkswap /swapfilerosnoetic@rosnoetic-VirtualBox:~$ sudo swapon /swapfile
    

    创建完交换分区之后就可以继续编译。

    也可以查看分区的大小

    rosnoetic@rosnoetic-VirtualBox:~$ free -m
    

    编译若是还不成功,试着创建更大的分区。

    如果编译使用完成后,可以关闭内存。

    rosnoetic@rosnoetic-VirtualBox:~$ sudo swapoff /swapfilerosnoetic@rosnoetic-VirtualBox:~$ sudo rm /swapfile
    

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com