20210107
18.04
台式机 + i5-7500
CPU 3.40 GhZ1050
Ti 驱动 Driver Version: 440.95.01
CUDA Version: 10.2
注册github
,注册epic games
,UE 4.24
账号连接github
,邮箱确认邀请,成功后执行克隆,出现下面结果方为正确。
git clone -b 4.24 https://github.com/EpicGames/UnrealEngine.git
Cloning into 'UnrealEngine'...
Username for 'https://github.com': 你的github邮箱地址
Password for 'https://你的邮箱[email protected]': 输入github密码
remote: Enumerating objects: 430, done.
remote: Counting objects: 100% (430/430), done.
remote: Compressing objects: 100% (306/306), done.
Receiving objects: 2% (69138/2855915), 24.67 MiB | 954.00 KiB/s
按官方要求运行脚本,配置依赖环境
./Setup.sh
setup
到99%失败,由于网络原因,重新setup
,提示是否覆盖改动,选择yes
,中间提示是否注册unreal engine types
,选择yes
,中间截图和成功setup
截图如下。
运行工程配置脚本
./GenerateProjectFiles.sh
输出如下流程
./GenerateProjectFiles.sh
Attempting to set up UE4 pretty printers for gdb (existing UE4Printers.py, if any, will be overwritten)...
updated UE4Printers.py
no ~/.gdbinit file found - creating a new one.
Setting up Unreal Engine 4 project files...
Fixing inconsistent case in filenames.
Setting up Mono
Generating data for project indexing... 100%
Generating data for project indexing... 100%
Writing project files... 100%
Generating data for project indexing... 100%
Generating data for project indexing... 100%
Generating data for project indexing... 100%
Generating data for project indexing... 100%
Writing project files... 100%
开始编译UE,运行make命令,哗啦啦输出
make
bash "/home/user/Software/UnrealEngine/Engine/Build/BatchFiles/Linux/Build.sh" CrashReportClient Linux Shipping
Fixing inconsistent case in filenames.
Setting up Mono
Building CrashReportClient...
Using 'git status' to determine working set for adaptive non-unity build (/home/jqf/Software/UnrealEngine).
Creating makefile for CrashReportClient (no existing makefile)
Creating makefile for UnrealHeaderTool (no existing makefile)
------- Build details --------
Using toolchain located at '/home/user/Software/UnrealEngine/Engine/Extras/ThirdPartyNotUE/SDKs/HostLinux/Linux_x64/v15_clang-8.0.1-centos7/x86_64-unknown-linux-gnu'.
Using clang (/home/jqf/Software/UnrealEngine/Engine/Extras/ThirdPartyNotUE/SDKs/HostLinux/Linux_x64/v15_clang-8.0.1-centos7/x86_64-unknown-linux-gnu/bin/clang++) version '8.0.1' (string), 8 (major), 0 (minor), 1 (patch)
Using bundled libc++ standard C++ library.
Using lld linker
Using llvm-ar : /home/jqf/Software/UnrealEngine/Engine/Extras/ThirdPartyNotUE/SDKs/HostLinux/Linux_x64/v15_clang-8.0.1-centos7/x86_64-unknown-linux-gnu/bin/llvm-ar
Using fast way to relink circularly dependent libraries (no FixDeps).
------------------------------
Performing 35 actions (4 in parallel)
[3/35] Compile BuildSettings.cpp
[2/35] Compile PCH.CoreUObject.h
...#类似的编译过程在不断书输出,机器轰鸣,风扇高速运转
中间截图
最后总共花费将近1.5小时编译结束,所幸没有报错。
在编译目录下找到UE编辑器,打开后报错
$ cd ~/UnrealEngine/Engine/Binaries/Linux on git:4.24 o [5:13:51]
$ ./UE4Editor
... #输出一堆消息
Failed to load Vulkan Driver which is required to run the engine.
The engine no longer fallbacks to OpenGL4 which has been deprecated.
经由谷歌搜索,对于N卡和A卡需要不同的Vulkan安装命令,参考文章 Install And Test Vulkan On Linux。
$ sudo apt-get install vulkan-utils #NVIDIA
$ sudo apt install libvulkan1 mesa-vulkan-drivers vulkan-utils #AMD 没测试过
再次进入目录下,打开UE编辑器,没有报错,正在加载,机器再次轰鸣…
等待一段时间,经过稍显漫长(10分钟)的初始化后,这回成功打开了熟悉的界面。
那么以我们对linux下编译各种玩意儿的经验来看,还是等shaders都编译完了再操作,以免出什么妖娥子。大概又过了10分钟,shaders都编译完了,尝试打开一个简单的项目看看。这里我们还没有配置c++的编译环境,先新建一个蓝图的工程。
测试一下运行,看看那有没有问题。OK,不仅没有问题,还很流畅。
先克隆仓库
# go to the folder where you clone GitHub projects
git clone https://github.com/Microsoft/AirSim.git
cd AirSim
插播一句官方的提示,解释了AirSim构建的要求,利用官方脚本会安装正确版本的依赖工具。
By default AirSim uses clang 8 to build for compatibility with UE 4.24. The setup script will install the right version of cmake, llvm, and eigen.
配置AirSim依赖环境
./setup.sh
中间截图,就是在不断的下载和安装…
最后出现下面的输出即为成功
************************************
AirSim setup completed successfully!
************************************
编译AirSim,提示可以加入debug参数来设置debug模式,当然了,我们肯定需要debug的。
# ./build.sh #普通release编译
./build.sh --debug #to build in debug mode
继续等待编译完成,机器又一次轰鸣起来,好在这次很快就完成了编译,输出以下结果应该就是没问题了。
==================================================================
AirSim plugin is built! Here's how to build Unreal project.
==================================================================
If you are using Blocks environment, its already updated.
If you are using your own environment, update plugin using,
rsync -a --delete Unreal/Plugins path/to/MyUnrealProject
For help see:
https://github.com/Microsoft/AirSim/blob/master/docs/build_linux.md
==================================================================
编译过程到这里就结束了。
继续按照官网的流程来测试
Once AirSim is setup:
Go to UnrealEngine installation folder and start Unreal by running ./Engine/Binaries/Linux/UE4Editor.
When Unreal Engine prompts for opening or creating project, select Browse and choose AirSim/Unreal/Environments/Blocks (or your custom Unreal project).
Alternatively, the project file can be passed as a commandline argument. For Blocks: ./Engine/Binaries/Linux/UE4Editor /Unreal/Environments/Blocks/Blocks.uproject
If you get prompts to convert project, look for More Options or Convert-In-Place option. If you get prompted to build, choose Yes. If you get prompted to disable AirSim plugin, choose No.
After Unreal Editor loads, press Play button.
通过命令行进入UE文件夹打开editor,之前加载过一次,这次就很快了,按照官方提示,先测试一下例子环境,打开AirSim下的UE工程。
提示需要转换项目,按官方流程,选择more option后选择Convert-In-Place option。
在这里稍作等待…
编译完成后,进入编辑器加载等待…
进入编辑器,等待shader编译完后,点击播放,选择yes是小车仿真,no是飞行器仿真,飞行器需要python来控制,这里我们先选yes看看效果。
小车可以通过方向键来控制,左侧有物理信息显示,下面测试一下飞行器,还是播放,这回选No,然后打开命令行,运行控制脚本。
cd ~/AirSim/PythonClient/multirotor
python hello_drone.py
Traceback (most recent call last):
File "hello_drone.py", line 2, in <module>
import airsim
File "/home/jqf/Software/AirSim/PythonClient/airsim/__init__.py", line 1, in <module>
from .client import *
File "/home/jqf/Software/AirSim/PythonClient/airsim/client.py", line 3, in <module>
from .utils import *
File "/home/jqf/Software/AirSim/PythonClient/airsim/utils.py", line 9, in <module>
import cv2 # pip install opencv-python
报错后首先配置一下python的pip源,使用ustc的源。安装python-opencv。
# 使用本镜像站来升级 pip
pip install -i https://mirrors.ustc.edu.cn/pypi/web/simple pip -U
pip config set global.index-url https://mirrors.ustc.edu.cn/pypi/web/simple
pip install opencv-python
...
Successfully installed opencv-python-4.4.0.42
再次测试python控制脚本
import msgpackrpc #install as admin: pip install msgpack-rpc-python
ModuleNotFoundError: No module named 'msgpackrpc'
按提示安装这个库
pip install msgpack-rpc-python
...
Successfully installed msgpack-python-0.5.6 msgpack-rpc-python-0.4.1 tornado-4.5.3
这里冒出一堆红字,只是提示未来可能出现的问题,但是安装是成功的,再次运行控制脚本,这次成功启动,输出如下:
python hello_drone.py
Connected!
Client Ver:1 (Min Req: 1), Server Ver:1 (Min Req: 1)
...
Press any key to takeoff
随便按键来启动飞行器,按照提示依次执行一遍,就是一个简单的启动飞行展示。到这里UE 4.24 + AirSim 的测试已经完成。
配置环境,官方流程。
sudo apt-get install gcc-8 g++-8 # Install gcc >= 8.0.0:
gcc-8 --version # Verify installation by
#Ubuntu 18.04 Install ROS melodic
#Install tf2 sensor and mavros packages:
sudo apt-get install ros-melodic-tf2-sensor-msgs ros-melodic-mavros* #所有都装
#Install catkin_tools
sudo apt-get install python-catkin-tools # or pip install catkin_tools
gcc验证,这里注意查看的是gcc8的版本,系统默认版本仍然是7+。
gcc-8 --version
gcc-8 (Ubuntu 8.4.0-1ubuntu1~18.04) 8.4.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
安装完毕后,回到AirSim的目录下,编译,这次很快,因为编译过一次。
cd AirSim;
./setup.sh;
./build.sh --debug
进入ros目录下,编译,这个build与catkin_make是有很大区别的,catkin_make, cmake, catkin build区别。
cd ros
catkin build # or catkin_make
错误原因是缺少这个头文件,看看网上的解决方法,原来是我仓促了,官方贴心的提示的要注意gcc的版本。
If your default GCC isn't 8 or greater (check using gcc --version), then compilation will fail. In that case, use gcc-8 explicitly as follows-
我的默认gcc查看后是7+版本,所以要用下面这条来编译
catkin build -DCMAKE_C_COMPILER=gcc-8 -DCMAKE_CXX_COMPILER=g++-8
这次编译成功了,ros下也生成了相应的devel,build,更新环境变量
source devel/setup.zsh
roslaunch airsim_ros_pkgs airsim_node.launch
roslaunch airsim_ros_pkgs rviz.launch
这里launch文件运行报错,查无此文件
上网一查,官方的issues2591
里提到尝试catkin clean
后重新编译,可能是由于我们一开始gcc的问题导致的,那么我们重新编译一下,回到ros的路径,清理空间。
catkin clean
重新按照gcc>8的条件编译,完成后source,然后roslaunch。成功。
roslaunch airsim_ros_pkgs airsim_node.launch
rviz的运行也没有问题,ros包的测试就完成了。
运行官方ROS例子,为了让UE也能检测到ROS的环境变量,在这里特意source了一下,官方需要把json配置文件拷贝到Documents里面,可是我里面没有建立过这个文件夹,我打开了之前的Blocks环境,先让飞机飞起来,尝试运行后面的ros节点看看是否成功。Rviz是成功启动了,可是话题数据明显没有传过来。看来这个复制操作是必不可少的。整理一下操作顺序,按下面的命令来执行。
#拷贝settings文件
roscd airsim_tutorial_pkgs
cp settings/front_stereo_and_center_mono.json ~/Documents/AirSim/settings.json
#ros环境变量下启动UE工程
cd ~/Software/UnrealEngine/Engine/Binaries/Linux
source ~/Software/AirSim/ros/devel/setup.zsh
./UE4Editor #选择了我之前用过的Blocks环境
#新开terminal
source ~/Software/AirSim/ros/devel/setup.zsh
roslaunch airsim_ros_pkgs airsim_node.launch
#新开terminal
source ~/Software/AirSim/ros/devel/setup.zsh
roslaunch airsim_tutorial_pkgs front_stereo_and_center_mono.launch
上述流程走完,UE启动正常,打开UE后先play,然后再去启动节点,如json文件中的描述,有相机和Lidar数据的输出,rviz一切正常,查看话题列表也正常,IMU数据正常。
到这里,基本的ROS+UE4+AirSim就通畅了,下面的工作就是替换场景,从自定义场景加载插件,替换模型,修改节点文件。