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

  • 手機站
  • 小程序

    汽車測試網(wǎng)

  • 公眾號
    • 汽車測試網(wǎng)

    • 在線課堂

    • 電車測試

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

2020-12-09 22:47:31·  來源:自動駕駛仿真  
 
RoadRuner是MathWorks新收購的自動駕駛場景構(gòu)建工具,Unreal Engine是商業(yè)游戲引擎。RoadRunner創(chuàng)建駕駛場景,導(dǎo)入到Unreal Engine,與Simulink聯(lián)合仿真。這種方
RoadRuner是MathWorks新收購的自動駕駛場景構(gòu)建工具,Unreal Engine是商業(yè)游戲引擎。RoadRunner創(chuàng)建駕駛場景,導(dǎo)入到Unreal Engine,與Simulink聯(lián)合仿真。這種方法兼具RoadRunner創(chuàng)建場景之便捷性和Unreal Engine渲染的高保真度。本文將對這個工作流程進行詳細介紹。
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,詳見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(無需關(guān)注此鏈接中其他內(nèi)容)。 https://www.mathworks.com/help/releases/R2020a/vdynblks/ug/support-package-for-customizing-scenes.html
2.  安裝基礎(chǔ)軟件
MATLAB 和 VS 的安裝順序沒有特別要求。 VS 需在 Ureal Engine 之前安裝,否則有可能 Unreal 的 .uproject 文件沒法找到 VS 進行編譯。
2.1 安裝Visual Studio2017
參照以下鏈接。
https://docs.unrealengine.com/zh-CN/ProductionPipelines/DevelopmentSetup/VisualStudioSetup/index.html
請確保在工作量(Workloads)下選擇“用C++開發(fā)游戲(Game developmentwith C++)”。在右側(cè)的摘要(Summary)工具欄中,展開用C++開發(fā)游戲(Game development with C++),并勾選可選(Optional)下的虛幻引擎安裝程序(Unreal Engine installer)。注意,不要勾選Windows 10 SDK (10.0.17763.0)。



              
另外,如果用戶需要使用Simulink Real-Time工具箱,需要同時參照以下鏈接。
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
進入 Unreal Engine 官網(wǎng),點擊右上角的下載,注冊賬號,下載 Epic Games Launcher 并安裝。



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



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



點擊上圖中RoadRunner的license,在以下界面Download Products。



點擊Manage Users→Add User。



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



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



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



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



在界面中搜索 unreal 。



點開上圖紅框鏈接(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è)定,上述代碼會把支持包自帶的Unreal工程拷貝到該文件夾。
ueInstFolder ="C:\Program Files\Epic Games\UE_4.23",此處是指明Unreal Engine 4.23的安裝路徑。如果您的安裝路徑不是C:\ProgramFiles\Epic Games\UE_4.23,需要調(diào)整成實際路徑。
執(zhí)行結(jié)束后,會有兩個現(xiàn)象:
①   localFolder中出現(xiàn)支持包自帶的Unreal工程。



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



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



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



在該路徑下新建一個Plugins文件夾。



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



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



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



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



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



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



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



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



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



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



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



單擊“Open Unreal Editor”,Unreal Editor將打開并從您的項目中加載場景。 第一次從 MATLAB 打開 Unreal Editor 時,可能會要求您重新編譯 UE4Editor DLL 文件,點擊 “Yes” 以重新編譯。
當(dāng) UnrealEditor 打開時,您可以忽略有關(guān)名稱“ _BuiltData ”加載失敗的文件的所有警告消息。
如果您收到“the lighting needs to be rebuilt”的警告,請從Unreal Editor窗口上方的工具欄中,選擇“Build”→“Build Lighting Only”。首次打開場景或向場景中添加新元素時,Unreal Editor會發(fā)出此警告。
另外,如果是自定義的場景,單擊“Open Unreal Editor”后,在出現(xiàn)的Unreal Editor中需要重設(shè)藍圖父項,具體操作如下。
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.
實際操作步驟如下:



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



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



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