原文参考:金书世界
在matlab主页选项卡,在环境部分找到附加功能,选择获取附加功能。
如果一切顺利的话就直接搜索并安装一下两个应用
Vehicle Dynamics Blockset Interface for Unreal Engine 4 Projects
Automated Driving Toolbox Interface for Unreal Engine 4 Projects
如果显示界面如下(安装方式需要先下载在安装),点击MathWorks 软件维护
在打开的网页中搜索上述的两个应用并下载
下载完成后在matlab上安装即可
安装完成后打开matlab软件后输入一下指令
%% STEP1
% Specify the location of the support package project files and a local folder destination
% Note: Only one path is supported. Select latest download path.
dest_root = "I:\Local";%路径需要根据自己的环境设置,用于保存两盒测试的虚拟换可以创建一个空的文件夹
src_root = fullfile(matlabshared.supportpkg.getSupportPackageRoot, ...
"toolbox", "shared", "sim3dprojects", "automotive");
%% STEP2
% Specify the location of the Unreal Engine installation.
ueInstFolder = "I:\ue5\Epic Games\UE_4.23";%自己设置的ue安装路径
%% STEP3
% Copy the MathWorksSimulation plugin to the Unreal Engine plugin folder.
mwPluginName = "MathWorksSimulation";
mwPluginFolder = fullfile(src_root, "PluginResources", "UE423"); % choose UE version
uePluginFolder = fullfile(ueInstFolder, "Engine", "Plugins");
uePluginDst = fullfile(uePluginFolder, "Marketplace", "MathWorks");
cd(uePluginFolder)
foundPlugins = dir("**/" + mwPluginName + ".uplugin");
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 remove plugin folder(s) and try again.";
msg = msg1 + msg2 + msg3;
warning(msg);
else
copyfile(mwPluginFolder, uePluginDst);
disp("Successfully copied MathWorksSimulation plugin to UE4 engine plugins!")
end
%% STEP4
% Copy the support package folder that contains the AutoVrtlEnv.uproject
% files to the local folder destination.
projFolderName = "AutoVrtlEnv";
projSrcFolder = fullfile(src_root, projFolderName);
projDstFolder = fullfile(dest_root, projFolderName);
if ~exist(projDstFolder, "dir")
copyfile(projSrcFolder, projDstFolder);
end
上述步骤完成后会将环境复制到目标的路径I:\Local\AutoVrtlEnv的路径下
如果上述的路径为空需要手动的复制,使用everything搜索AutoVrtlEnv
复制这个文件夹到I:\Local\
完成环境的配置
打开虚拟的引擎
openExample('vdynblks/SceneInterrogationReferenceApplicationExample')
显示的窗体如下(可能会打开的比较慢需要等待一会)
选择Simulation 3D Scene Configuration模块双击进入编辑界面,在scene source中选择Unreal Editor并在下面的project中选择I:\Local
首次载入比较慢,显示如下所示
显示如下所示就表示环境搭建成功