Ubuntu 18 2022无人机大赛模拟器构建说明
问题描述
官网提供的构建流程,基于Ubuntu20,ROS noetic,不适用于Ubuntu18,另外Ubuntu22装不了ROS,只有ROS2,两者不兼容,使用Ubuntu22可以考虑使用docker安装。
Ubuntu18系统使用的gcc版本默认为7,在构建时可能存在问题(主要为部分头文件位置不同),另外,据组委会描述还存在ue4运行库缺失问题(我在安装stage2_rgb时未遇到),具体参考以下编译安装流程(修改自官方编译指南)。
编译安装流程
下载模拟器(按需下载)
赛项一+RGBD:
git clone https://github.com/RoboMaster/IntelligentUAVChampionshipSimulator.git -b stage1_RGBD
赛项二+RGBD:
git clone https://github.com/RoboMaster/IntelligentUAVChampionshipSimulator.git -b stage2_RGBD
赛项一+双目:
git clone https://github.com/RoboMaster/IntelligentUAVChampionshipSimulator.git -b stage1_stereo
赛项二+双目:
git clone https://github.com/RoboMaster/IntelligentUAVChampionshipSimulator.git -b stage2_stereo
赛项三:
git clone https://github.com/RoboMaster/IntelligentUAVChampionshipSimulator.git -b stage3
下载资源文件到特定位置
cd IntelligentUAVChampionshipSimulator
wget -P ./stage2_RGBD/complex/Content/Paks/ https://stg-robomasters-hz-q0o2.oss-cn-hangzhou.aliyuncs.com/simulator/stage2/complex-LinuxNoEditor.pak
wget -P ./stage2_RGBD/complex/Binaries/Linux/ https://stg-robomasters-hz-q0o2.oss-cn-hangzhou.aliyuncs.com/simulator/stage2/complex
安装 ROS melodic
注:官方给出的
noetic
为Ubuntu20版本的ros,使用Ubuntu18需要将下文所有出现的noetic
替换为melodic
ROS melodic安装参考博客
安装 catkin 管理工具
sudo apt install python3-catkin-tools
进入模拟器文件stageX_XXX的根目录
cd /path/to/stageX_XXX
构建roswrapper
sudo cp -rf /usr/include/eigen3/Eigen /usr/include/Eigen -R
(需要先安装Eigen3
库,sudo apt install libeigen3-dev
)
sudo apt install ros-melodic-mavros ros-melodic-mavros-extras
sudo apt install ros-melodic-tf2-sensor-msgs
source /opt/ros/melodic/setup.bash
(使用的shell如果不是bash,按照个人情况修改,如是zsh需要再运行source /opt/ros/melodic/setup.zsh
)
cd $PWD/roswrapper/ros
($PWD
原来是指当前目录,这里应该指stageX_XXX的根目录)
catkin build
对于Ubuntu18用户而言多数会出现make failed情况,参考下文常见错误解决
使用脚本启动模拟器
cd /path/to/stageX_XXX
./simulator.sh
当看到如下画面时说明模拟器启动成功
Q&A
启动模拟器和roswrapper后,roswrapper显示无法连接自己的服务器,需要安装docker服务来新建相关子网。
安装docker:
sudo apt-get install ca-certificates gnupg lsb-release
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
编译常见问题
fatal error: filesystem: No such file or directory
--> #include <filesystem>
原因分析参考stackoverflow,官方给的代码应该是Ubuntu20环境,gcc版本号较高,filesystem
在低版本时是作为实验性功能在experimental
下的,故将#include <filesystem>
改为 #include <experimental/filesystem>
,同时修改using namespace std::filesystem
为using namespace std::experimental::filesystem
具体需要修改的文件为stageX_XXX/roswrapper/MavLinkCom/MavLinkTest
下的Commands.cpp
和main.cpp