日本无码免费高清在线|成人日本在线观看高清|A级片免费视频操逼欧美|全裸美女搞黄色大片网站|免费成人a片视频|久久无码福利成人激情久久|国产视频一二国产在线v|av女主播在线观看|五月激情影音先锋|亚洲一区天堂av

  • 手機(jī)站
  • 小程序

    汽車測(cè)試網(wǎng)

  • 公眾號(hào)
    • 汽車測(cè)試網(wǎng)

    • 在線課堂

    • 電車測(cè)試

MATLAB R2020a+RoadRunner+Unreal Engine4.23 聯(lián)合仿真詳細(xì)流程

2020-12-09 22:47:31·  來(lái)源:自動(dòng)駕駛仿真  
 
RoadRuner是MathWorks新收購(gòu)的自動(dòng)駕駛場(chǎng)景構(gòu)建工具,Unreal Engine是商業(yè)游戲引擎。RoadRunner創(chuàng)建駕駛場(chǎng)景,導(dǎo)入到Unreal Engine,與Simulink聯(lián)合仿真。這種方
RoadRuner是MathWorks新收購(gòu)的自動(dòng)駕駛場(chǎng)景構(gòu)建工具,Unreal Engine是商業(yè)游戲引擎。RoadRunner創(chuàng)建駕駛場(chǎng)景,導(dǎo)入到Unreal Engine,與Simulink聯(lián)合仿真。這種方法兼具RoadRunner創(chuàng)建場(chǎng)景之便捷性和Unreal Engine渲染的高保真度。本文將對(duì)這個(gè)工作流程進(jìn)行詳細(xì)介紹。
1.  電腦軟硬件要求
軟件要求:
Windows® 64-bitplatform
Unreal Editor 4.23
Visual Studio® 2017or higher
Microsoft® DirectX® —— If this software is not already installedon your machine and you try to simulate in the 3D environment, Vehicle DynamicsBlockset prompts you to install it. once you install the software, you mustrestart the simulation.
Automated DrivingToolbox Interface for Unreal Engine 4 Projects,詳見(jiàn)3.1
最低硬件要求:
Graphics card (GPU)— Virtual reality-ready GPU with 8 GB of onboard RAM
Processor (CPU) —2.60 GHz
Memory (RAM) — 12 GB
如果要獲得流暢的仿真效果,建議配置高性能顯卡。以上信息,引自以下鏈接中的Support Package for Customizing Scenes(無(wú)需關(guān)注此鏈接中其他內(nèi)容)。 https://www.mathworks.com/help/releases/R2020a/vdynblks/ug/support-package-for-customizing-scenes.html
2.  安裝基礎(chǔ)軟件
MATLAB 和 VS 的安裝順序沒(méi)有特別要求。 VS 需在 Ureal Engine 之前安裝,否則有可能 Unreal 的 .uproject 文件沒(méi)法找到 VS 進(jìn)行編譯。
2.1 安裝Visual Studio2017
參照以下鏈接。
https://docs.unrealengine.com/zh-CN/ProductionPipelines/DevelopmentSetup/VisualStudioSetup/index.html
請(qǐng)確保在工作量(Workloads)下選擇“用C++開(kāi)發(fā)游戲(Game developmentwith C++)”。在右側(cè)的摘要(Summary)工具欄中,展開(kāi)用C++開(kāi)發(fā)游戲(Game development with C++),并勾選可選(Optional)下的虛幻引擎安裝程序(Unreal Engine installer)。注意,不要勾選Windows 10 SDK (10.0.17763.0)。



              
另外,如果用戶需要使用Simulink Real-Time工具箱,需要同時(shí)參照以下鏈接。
https://ww2.mathworks.cn/matlabcentral/answers/348269-how-do-i-set-up-microsoft-visual-studio-2017-for-slrt
2.2 安裝MATLAB R2020a
必備工具箱是Automated Driving Toolbox和Vehicle Dynamics Blockset。并使用mex -setup命令將MATLAB的編譯器設(shè)置成VS2017。
2.3 安裝Unreal Engine4.23
進(jìn)入 Unreal Engine 官網(wǎng),點(diǎn)擊右上角的下載,注冊(cè)賬號(hào),下載 Epic Games Launcher 并安裝。



登陸 Epic Games Launcher ,在“庫(kù)”界面中選擇 Unreal Engine 4.23 并安裝。



安裝完成后,可在上圖界面啟動(dòng) Unreal Editor 4.23 。
2.4 安裝RoadRunner和RoadRunner Asset Library
用正版或者申請(qǐng)?jiān)囉冒?,點(diǎn)擊以下鏈接可申請(qǐng)?jiān)囉冒妗?br /> https://www.mathworks.com/campaigns/products/trials.html?prodcode=RD
點(diǎn)擊以下鏈接,查看RoadRunner和RoadRunnerAsset Library的下載安裝指南。
https://www.mathworks.com/help/roadrunner/ug/install-and-activate-roadrunner.html
我們以Windows平臺(tái)下的individual license為例,加以說(shuō)明。在MathWorks官網(wǎng)個(gè)人賬戶的my account中,查看License。



點(diǎn)擊上圖中RoadRunner的license,在以下界面Download Products。



點(diǎn)擊Manage Users→Add User。



Add User中設(shè)置郵箱和姓名等信息。接著Intall and Activate→Activate。



在下圖界面中填寫即將安裝RoadRunner的電腦的一些信息。



Host ID——MAC地址或C盤序列號(hào)
如使用C盤序列號(hào),在Windows command prompt中執(zhí)行vol c:獲得信息。



Computer Login Name
在Windows command prompt中執(zhí)行set username獲得信息。
Activation Label——自行定義
提交上述信息后,網(wǎng)站會(huì)生成一個(gè)包含上述信息的RoadRunner license文件,將它下載到電腦中。最后安裝之前下載的程序,當(dāng)提示輸入license文件時(shí),選擇上一步下載的license文件。此時(shí),已完成安裝和激活工作。
3.  安裝插件
注意:完成上述步驟后,再裝插件。
3.1 安裝MATLAB的Unreal支持包和Unreal的MathWorks插件
參見(jiàn):
https://www.mathworks.com/help/releases/R2020a/driving/ug/install-and-configure-support-package-for-customizing-scenes.html
打開(kāi)MATLAB的Add On/附加功能界面。



在界面中搜索 unreal 。



點(diǎn)開(kāi)上圖紅框鏈接(Automated Driving ToolboxInterface for Unreal Engine 4 Projects),選擇安裝。



安裝完成后,需要在MATLAB中執(zhí)行以下代碼。
supportPackageFolder= fullfile( ...
   matlabshared.supportpkg.getSupportPackageRoot, ...
    "toolbox","shared","sim3dprojects","driving");
localFolder = "C:\Local";
projectFolderName= "AutoVrtlEnv";
projectSupportPackageFolder= fullfile(supportPackageFolder,projectFolderName);
projectLocalFolder= fullfile(localFolder,projectFolderName);
if~exist(projectLocalFolder,"dir")
   copyfile(projectSupportPackageFolder,projectLocalFolder);
end
ueInstallFolder= "C:\Program Files\Epic Games\UE_4.23";
supportPackageFolder= fullfile( ...
   matlabshared.supportpkg.getSupportPackageRoot, ...
    "toolbox","shared","sim3dprojects","driving");
mwPluginName = "MathWorksSimulation.uplugin";
mwPluginFolder =fullfile(supportPackageFolder,"PluginResources","UE423");
uePluginFolder =fullfile(ueInstallFolder,"Engine","Plugins");
uePluginDestination= fullfile(uePluginFolder,"Marketplace","MathWorks");
cd(uePluginFolder)
foundPlugins =dir("**/" + mwPluginName);
if~isempty(foundPlugins)
   numPlugins = size(foundPlugins,1);
   msg2 = cell(1,numPlugins);
   pluginCell = struct2cell(foundPlugins);
   msg1 = "Plugin(s)already exist here:" + newline + newline;
    for n = 1:numPlugins
       msg2{n} = "   " + pluginCell{2,n}+ newline;
    end
   msg3 = newline + "Please removeplugin folder(s) and try again.";
   msg = msg1 + msg2 + msg3;
   warning(msg);
else
   copyfile(mwPluginFolder,uePluginDestination);
   disp("Successfullycopied MathWorksSimulation plugin to UE4 engine plugins!")
end
以上代碼引自以下鏈接的Set Up Scene Customization UsingSupport Package。
https://www.mathworks.com/help/releases/R2020a/driving/ug/install-and-configure-support-package-for-customizing-scenes.html
值得注意的是:
localFolder ="C:\Local",該路徑可自行設(shè)定,上述代碼會(huì)把支持包自帶的Unreal工程拷貝到該文件夾。
ueInstFolder ="C:\Program Files\Epic Games\UE_4.23",此處是指明Unreal Engine 4.23的安裝路徑。如果您的安裝路徑不是C:\ProgramFiles\Epic Games\UE_4.23,需要調(diào)整成實(shí)際路徑。
執(zhí)行結(jié)束后,會(huì)有兩個(gè)現(xiàn)象:
①   localFolder中出現(xiàn)支持包自帶的Unreal工程。



②   Unreal Editor中出現(xiàn)MathWorks插件。在Unreal Editor中點(diǎn)擊“編輯”→“插件”可進(jìn)行查看。



3.2 新建Unreal工程,安裝Unreal的RoadRunner插件
引自:
https://www.mathworks.com/help/roadrunner/ug/Exporting-to-Unreal.html
打開(kāi)Unreal,設(shè)置項(xiàng)目文件夾和項(xiàng)目名稱后,創(chuàng)建一個(gè)項(xiàng)目,如下圖。



創(chuàng)建項(xiàng)目后,項(xiàng)目文件夾如下圖。注意,路徑中不要出現(xiàn)空格。



在該路徑下新建一個(gè)Plugins文件夾。



接著,點(diǎn)擊以下鏈接,下載Unreal的RoadRunner插件。
https://www.mathworks.com/help/roadrunner/ug/Downloading-Plugins.html
將插件文件夾中的RoadRunnerimporter和RoadRunnerMaterials文件夾(如下圖)都復(fù)制到上圖的Plugins文件夾中。每個(gè)unreal工程都得拷貝一次,否則roadrunner導(dǎo)出的信息沒(méi)法加載到Unreal。



然后,右鍵剛才新建的unreal 工程demo1.uproject,點(diǎn)擊Generate Visual Studio project files。之后,雙擊打開(kāi)demo1.uproject,在彈出的窗口中選擇“是”。(引自https://www.mathworks.com/help/roadrunner/ug/Exporting-to-Unreal.html)



在彈出Unreal Editor中,可以在“編輯”→“插件”中查看到Unreal已經(jīng)加載了RoadRunner的插件。



4.  RoadRunner的場(chǎng)景導(dǎo)出到Unreal
參見(jiàn):
https://www.mathworks.com/help/roadrunner/ug/Exporting-to-Unreal.html
我們以RoadRunner自帶的FourWaySignal場(chǎng)景為例,將它導(dǎo)出到Unreal。
4.1 將RoadRunner場(chǎng)景導(dǎo)出成文件
打開(kāi)RoadRunner,新建場(chǎng)景/New Scene。在RoadRunner界面中,“File”→“Open Scene”選擇打開(kāi)自帶的場(chǎng)景文件FourWaySignal.rrscene(如下圖)。



選擇“File”→“Export”→“Unreal (.fbx + .xml)”。



設(shè)定導(dǎo)出的目標(biāo)文件夾和文件名,如下圖。



導(dǎo)出完成后,目標(biāo)文件夾中就包含了導(dǎo)出的文件。



4.2 將導(dǎo)出文件加載到Unreal
打開(kāi)Unreal Editor,在內(nèi)容瀏覽器中點(diǎn)擊“導(dǎo)入”。



選擇4.1中Exports文件夾中的fbx文件。



接著,導(dǎo)入的設(shè)置。設(shè)置界面如下圖。



具體如何設(shè)置,參考以下鏈接。導(dǎo)入完成后,注意保存,保存時(shí)設(shè)置MAP名稱。
https://www.mathworks.com/help/roadrunner/ug/Exporting-to-Unreal.html
5.  MATLAB與UnrealEditor聯(lián)合仿真聯(lián)合仿真
Unreal的場(chǎng)景能以兩種形式與MATLAB聯(lián)合仿真:
①   Unreal Editor直接運(yùn)行場(chǎng)景,聯(lián)合仿真時(shí)需要打開(kāi)Unreal Editor
②   Unreal場(chǎng)景導(dǎo)出成可執(zhí)行文件(exe),聯(lián)合仿真時(shí)無(wú)需打開(kāi)Unreal Editor
此節(jié)介紹第一種方式。
5.1 從MATLAB打開(kāi)Unreal Editor
引自:
https://www.mathworks.com/help/releases/R2020a/driving/ug/customize-scenes-using-simulink-and-unreal-editor.html
如果直接在Unreal Editor中打開(kāi)項(xiàng)目文件,則MATLAB和Simulink不會(huì)與Unreal Editor建立連接,因此也將無(wú)法聯(lián)合仿真。需要從MATLAB打開(kāi)Unreal Editor。
雙擊Simulink模型的Simulation 3D SceneConfiguration模塊,將Scene source參數(shù)設(shè)置為Unreal Editor。在Project參數(shù)中,瀏覽到包含場(chǎng)景的項(xiàng)目文件。



單擊“Open Unreal Editor”,Unreal Editor將打開(kāi)并從您的項(xiàng)目中加載場(chǎng)景。 第一次從 MATLAB 打開(kāi) Unreal Editor 時(shí),可能會(huì)要求您重新編譯 UE4Editor DLL 文件,點(diǎn)擊 “Yes” 以重新編譯。
當(dāng) UnrealEditor 打開(kāi)時(shí),您可以忽略有關(guān)名稱“ _BuiltData ”加載失敗的文件的所有警告消息。
如果您收到“the lighting needs to be rebuilt”的警告,請(qǐng)從Unreal Editor窗口上方的工具欄中,選擇“Build”→“Build Lighting Only”。首次打開(kāi)場(chǎng)景或向場(chǎng)景中添加新元素時(shí),Unreal Editor會(huì)發(fā)出此警告。
另外,如果是自定義的場(chǎng)景,單擊“Open Unreal Editor”后,在出現(xiàn)的Unreal Editor中需要重設(shè)藍(lán)圖父項(xiàng),具體操作如下。
If this is your first time opening a customproject in Unreal Editor 4.23, you may need to associate, or reparent, thisproject with the Sim3dLevelscriptActor level blueprint used in Vehicle DynamicsBlockset. The level blueprint controls how objects interact once placed withinin the Unreal environment. If you do not reparent the project to this levelblueprint, the simulation returns an error.
Toreparent the level blueprint:
In theUnreal Editor toolbar above the editor window, select Blueprints > OpenLevel Blueprint.
In theLevel Blueprint window, select File > Reparent Blueprint.
Click theSim3dLevelscriptActor blueprint and close the Level Blueprint window.
If you do not see this blueprint, make surethat you have the MathWorksSimulation plugin installed and enabled.
Navigate back to the editor window. In thetoolbar above this window, select Settings > Plugins.
In the Plugins window, verify that theMathWorks Interface plugin appears. This plugin refers to theMathWorksSimulation.uplugin file that you copied into your local Unreal Editorinstallation from the Vehicle Dynamics Blockset Support Package for UnrealEngine 4 Projects.
If you editor installation includes theplugin, then when you open a project in the editor for the first time, you areprompted to enable this plugin. If you do not see the MathWorks Interfaceplugin in this window, repeat the steps under and reopen the editor fromMATLAB.
Select the Enabled check box.
Close the editor, reopen it from MATLAB, andrepeat the steps to reparent the blueprint.
實(shí)際操作步驟如下:



如果沒(méi)找到名為Sim3dLevelscriptActor的藍(lán)圖,那要先確認(rèn)Unreal是否啟用了MathWorks插件。查看插件的方式,3.1有說(shuō)明,正常的狀態(tài)如下圖。



5.2 聯(lián)合仿真
在UnrealEditor中可以通過(guò)數(shù)字鍵切換視角,如下圖。



對(duì)于自定義的場(chǎng)景,如果也要實(shí)現(xiàn)這個(gè)功能,需要把DefaultInput.ini從如下路徑
C:\ProgramData\MATLAB\SupportPackages\\toolbox\shared\sim3dprojects\driving\AutoVrtlEnv\Config
拷貝到下面的路徑
分享到:
 
反對(duì) 0 舉報(bào) 0 收藏 0 評(píng)論 0
滬ICP備11026917號(hào)-25