1. 程式人生 > >Windows下AirSIM的環境搭建(三、Build Unity示例專案及資源)

Windows下AirSIM的環境搭建(三、Build Unity示例專案及資源)

文章目錄

Unity


Build Unity Project

Go inside the AirSim\Unity directory: cd Unity.

Build the unity project: build.cmd.

Additionally, there is a free environment Windridge City

which you can download from Unity Asset Store. And, of course, you can always create your own environment.


Build

在這裡插入圖片描述
在這裡插入圖片描述
出錯,應該是VS2017缺少元件 Windows SDK 10.0.16299.0,這個版本的元件有四個,我只安裝瞭如下兩個
在這裡插入圖片描述
在這裡插入圖片描述
這個warning不用管,至此就build完成了,生成了AirLibWrapper外掛。

Windridge City

在Unity Asset Store中購買(免費)該資源後,用unity開啟,開始下載。
在這裡插入圖片描述
在這裡插入圖片描述
下載完成後,匯入即可
在這裡插入圖片描述


第一次使用,當然是全部匯入啦
在這裡插入圖片描述
匯入完成後,場景是這樣的,很棒
在這裡插入圖片描述
但是好像有編譯錯誤,不能直接執行
在這裡插入圖片描述
在原始碼中有如下解釋

 // NOTE: If you are getting errors of the sort that say something like:
 //     "The type or namespace name `PostProcessing' does not exist in the namespace"
 // it is because the Post Processing Stack V2 module has not been installed in your project.
 //
 // To make the errors go away, you can either:
 //   1 - Download PostProcessing V2 and install it into your project
 // or
 //   2 - Delete the CinemachinePostProcessingV2 folder from your project

postprocessingwiki-install說明文件如下

First, make sure you don't already have the Postprocessing package installed or it will conflict 
with a source installation. If you do, you can remove it using the package manager (Window -> Package Manager).

Then you can use your Git client to clone the post-processing repository into your Assets folder. 

If you don't want to use a Git client you can also download a zip archive by clicking the green 
button that says "Clone or download" at the top of the repository and extract it into your project. 

在window->package manager裡,也有安裝的方法
在這裡插入圖片描述
將下載好的postprocessing解壓縮到project-asset目錄下,等待unity載入完新資源,此時error就沒了。
運行當前場景,移動滑鼠可以環視四周,安裝postprocessing之後,就能看到視覺特效啦。
在這裡插入圖片描述

示例專案

Usage


Start Unity and click Open project.
Select the folder AirSim\Unity\UnityDemo, and then hit the button Select Folder.
In the bottom pane, Click on Projects->Assets->Scenes. Then, Double-click on SimModeSelector, DroneDemo, or CarDemo.
Hit the play button to start the simulation (and hit play again to stop the simulation. .
Alternatively, you can change the SimMode in your Settings.json file. (you can read more about it here)


開啟專案,雙擊開啟SimModeSelector場景。(如果直接開啟另外兩個場景去執行,編輯器會崩潰)
在這裡插入圖片描述直接play,會讀取Settings.json
在這裡插入圖片描述
我這裡沒有這個路徑,所以生成失敗,到"C:\Users\name\Documents"目錄下建立"AirSIM"資料夾,再次點選play,即成功執行場景。
如未在Settings.json中設定模擬模式,會首先彈出提示框,用於選擇模擬模式。
在這裡插入圖片描述
選擇Car進入CarDemo場景,模擬模擬無人車
選擇Multirotor進入DroneDemo場景,模擬模擬無人機
在這裡插入圖片描述
示例專案啟動完成

Operation


Controlling the car:
Use WASD or the Arrow keys or the AirSim client.
Controlling the drone:
Use the PageUP/PageDown with WASD/Arrow keys.
Changing camera views:
Keys 0, 1, 2, 3 are used to toggle windows of different camera views.
Recording simulation data:
Press Record button(Red button) located at the right bottom corner of the screen, to toggle recording of the simulation data. The recorded data can be found at Documents\AirSim(Date of recording)


以下為操作方式的翻譯

  • WASD或方向鍵控制Car移動
  • Page UP/Page Down控制Drone上升/下落,WASD或方向鍵控制移動
  • 0,1,2,3控制攝像機
  • 從左到右分別為1,2,3控制攝像機開關,0可為反選攝像機狀態在這裡插入圖片描述
  • 紅色按鈕“RE”為recording,錄製短片,錄製實驗結果等用途。

事實上,在原始碼裡,我沒找到怎麼控制無人機,這裡暫時留個坑不填,需要準備一下畢業開題的事情,最近會主要看神經網路…