首页 > 编程语言 >EGO-Planner算法仿真环境搭建

EGO-Planner算法仿真环境搭建

时间:2024-08-02 09:40:35浏览次数:12  
标签:仿真 Planner rosnoetic vscode 编译 planner EGO ego VirtualBox

EGO-Planner算法仿真环境搭建

欢迎关注我的B站:https://space.bilibili.com/379384819

欢迎交流学习,vx:18074116692

参考教程:

ZJU-FAST-Lab/自我规划师 (github.com)

1. 查看系统环境

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

查看ubuntu版本:

rosnoetic@rosnoetic-VirtualBox:~$ lsb_release -a

No 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 -d

melodic

可知,当前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.git

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

2.3 编译

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

rosnoetic@rosnoetic-VirtualBox:~$ cd ego-planner/

rosnoetic@rosnoetic-VirtualBox:~/ego-planner$ catkin_make
  • 编译过程

3. 运行

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

rosnoetic@rosnoetic-VirtualBox:~$ cd ego-planner/

rosnoetic@rosnoetic-VirtualBox:~/ego-planner$ source ./devel/setup.bash 

rosnoetic@rosnoetic-VirtualBox:~/ego-planner$ roslaunch ego_planner simple_run.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 /swapfile
    
    rosnoetic@rosnoetic-VirtualBox:~$ sudo swapon /swapfile
    

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

    也可以查看分区的大小

    rosnoetic@rosnoetic-VirtualBox:~$ free -m
    

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

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

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

4. 使用IDE

为了便于后续代码的查阅,我们配置IDE以自动完成代码跳转。

(1)在vscode安装C++CMake扩展

(2)ctrl+alt+T打开终端,执行如下指令重新编译代码:

rosnoetic@rosnoetic-VirtualBox:~$ cd ego-planner/

rosnoetic@rosnoetic-VirtualBox:~/ego-planner$ catkin_make -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=Yes
  • 重新编译过程

它将导出一个编译命令文件,该文件可以帮助 vscode 确定代码架构。

(3)启动 vscode 并选择要打开的 ego-planner 文件夹。

rosnoetic@rosnoetic-VirtualBox:~$ cd ego-planner/

rosnoetic@rosnoetic-VirtualBox:~/ego-planner$ code .

vscode 中按 Ctrl+Shift+B 编译代码。此命令在 .vscode/tasks.json 中定义。 您可以在“args”后面添加自定义参数。默认值为“-DCMAKE_BUILD_TYPE=Release”

(4)关闭并重新启动vscode,你会看到vscode已经理解了代码架构,可以执行自动补全和跳转。

标签:仿真,Planner,rosnoetic,vscode,编译,planner,EGO,ego,VirtualBox
From: https://www.cnblogs.com/windandchimes/p/18338036

相关文章