原文参考:金书世界
参考:https://ww2.mathworks.cn/help/driving/ug/select-waypoints-for-3d-simulation.html
sceneName = 'LargeParkingLot';
[sceneImage, sceneRef] = helperGetSceneImage(sceneName);
sceneRef.XWorldLimits % (in meters)
sceneRef.YWorldLimits % (in meters)
显示如下
hScene = figure;
helperShowSceneImage(sceneImage, sceneRef)
title(sceneName)
存在报错但是不影响后续测试
开始描绘路线
hFig = helperSelectSceneWaypoints(sceneImage, sceneRef);
在图像开始描绘路线(如果不描绘直接执行下一步就是使用的默认路线)
点击按钮后显示如下
点击去定按钮后显示如下(需要注意上述的wayPoints1和refPoses1,需要后面的代码输入的一致)
% Load variables to workspace if they do not exist
if exist('refPoses', 'var')==0 || exist('wayPoints', 'var')==0
% Load MAT-file containing preselected waypoints
data = load('waypointsLargeParkingLot');
data = data.waypointsLargeParkingLot;
% Assign to caller workspace
assignin('caller', 'wayPoints', {data.waypoints1});%需要修改waypoints1
assignin('caller', 'refPoses', {data.refPoses1});%需要修改refPoses1
end
numPoses = size(refPoses1{1}, 1);%需要修改refPoses1
refDirections = ones(numPoses,1); % Forward-only motion
numSmoothPoses = 50 * numPoses; % Increase this to increase the number of returned poses
[smoothRefPoses,~,cumLengths] = smoothPathSpline(refPoses1{1}, refDirections, numSmoothPoses);%需要修改refPoses1
if ~ispc
error(['3D Simulation is only supported on Microsoft', char(174), ' Windows', char(174), '.']);
end
modelName = 'VisualizeVehiclePathIn3DSimulation';
open_system(modelName);
snapnow;
显示如下
右侧的红框内的是没有的需要我们手动的添加
找到上述两个工具后添加到界面就和上述的界面显示相同了
配置左视的摄像头
双击Simulation 3D Fisheye Camera进入到一下界面并设置参数如下
双击To Multimedia File进入到一下界面并设置参数如下
左视的配置完成
同理设置右视
双击Simulation 3D Fisheye Camera进入到一下界面并设置参数如下
双击To Multimedia File进入到一下界面并设置参数如下
右视的配置完成
同理设置前视
双击Simulation 3D Fisheye Camera进入到一下界面并设置参数如下
双击To Multimedia File进入到一下界面并设置参数如下
前视的配置完成
同理设置后视
双击Simulation 3D Fisheye Camera进入到一下界面并设置参数如下
双击To Multimedia File进入到一下界面并设置参数如下
后视的配置完成
输入一下代码
% Configure the model to stop simulation at 5 seconds.
simStopTime = 50;%需要修改 决定运行的快慢
set_param(gcs, 'StopTime', num2str(simStopTime));
% Create a constant velocity profile by generating a time vector
% proportional to the cumulative path length.
timeVector = normalize(cumLengths, 'range', [0, simStopTime]);
% Create variables required by the Simulink model
refPosesX = [timeVector, smoothRefPoses(:,1)];
refPosesY = [timeVector, smoothRefPoses(:,2)];
refPosesT = [timeVector, smoothRefPoses(:,3)];
配置完成后开始运行
sim(modelName);%运行
显卡在燃烧
输出的结果视频保存路径
输出的测试视频
如果没有显卡或者想直接获取当前的视频直接使用请使用百度网盘下载
链接:https://pan.baidu.com/s/1Pqn6_t_eUPIBhLdjXq8Xxg?pwd=sqim 提取码:sqim