【泊车】基于强化学习实现智能泊车附matlab代码

简介: 【泊车】基于强化学习实现智能泊车附matlab代码

✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信。

🍎个人主页:Matlab科研工作室

🍊个人信条:格物致知。

更多Matlab仿真内容点击👇

智能优化算法  神经网络预测雷达通信 无线传感器

信号处理图像处理路径规划元胞自动机无人机 电力系统

⛄ 内容介绍

基于强化学习的数字孪生智慧停车方法,为智慧城市信息物理融合物联网构建提供了一个智能,易用的系统模型.该智慧停车系统支持对实际场景下多车辆自动泊车过程进行实时控制,并能有效避免碰撞,降低人工停车时间成本,减少人为操作失误安全事故的发生.

⛄ 部分代码

clear all; close all;

freeSpotIdx = 26;

map = ParkingLot(freeSpotIdx);

egoInitialPose = [20, 15, 0];

egoTargetPose = createTargetPose(map,freeSpotIdx)

autoParkingValetParams

mdl = 'rlAutoParkingValet';

open_system(mdl)

createMPCForParking


numObservations = 16;

observationInfo = rlNumericSpec([numObservations 1]);

observationInfo.Name = 'observations';


steerMax = pi/4;

discreteSteerAngles = -steerMax : deg2rad(1) : steerMax;

actionInfo = rlFiniteSetSpec(num2cell(discreteSteerAngles));

actionInfo.Name = 'actions';

numActions = numel(actionInfo.Elements);


blk = [mdl '/RL Controller/RL Agent'];

env = rlSimulinkEnv(mdl,blk,observationInfo,actionInfo);


env.ResetFcn = @autoParkingValetResetFcn;


rng(0)

criticNetwork = [

   featureInputLayer(numObservations,'Normalization','none','Name','observations')

   fullyConnectedLayer(128,'Name','fc1')

   reluLayer('Name','relu1')

   fullyConnectedLayer(128,'Name','fc2')

   reluLayer('Name','relu2')

   fullyConnectedLayer(128,'Name','fc3')

   reluLayer('Name','relu3')

   fullyConnectedLayer(1,'Name','fc4')];


criticOptions = rlRepresentationOptions('LearnRate',1e-3,'GradientThreshold',1);

critic = rlValueRepresentation(criticNetwork,observationInfo,...

   'Observation',{'observations'},criticOptions);



actorNetwork = [

   featureInputLayer(numObservations,'Normalization','none','Name','observations')

   fullyConnectedLayer(128,'Name','fc1')

   reluLayer('Name','relu1')

   fullyConnectedLayer(128,'Name','fc2')

   reluLayer('Name','relu2')

   fullyConnectedLayer(numActions, 'Name', 'out')

   softmaxLayer('Name','actionProb')];


actorOptions = rlRepresentationOptions('LearnRate',2e-4,'GradientThreshold',1);

actor = rlStochasticActorRepresentation(actorNetwork,observationInfo,actionInfo,...

   'Observation',{'observations'},actorOptions);


agentOpts = rlPPOAgentOptions(...

   'SampleTime',Ts,...

   'ExperienceHorizon',512,...

   'ClipFactor',0.2,...

   'EntropyLossWeight',0.01,...

   'MiniBatchSize',64,...

   'NumEpoch',3,...

   'AdvantageEstimateMethod',"gae",...

   'GAEFactor',0.95,...

   'DiscountFactor',0.99);

%     'DiscountFactor',0.998);

agent = rlPPOAgent(actor,critic,agentOpts);



trainOpts = rlTrainingOptions(...

   'MaxEpisodes',10000,...

   'MaxStepsPerEpisode',200,...

   'ScoreAveragingWindowLength',200,...

   'Plots','training-progress',...

   'StopTrainingCriteria','AverageReward',...

   'StopTrainingValue',80,...

   'UseParallel',true);


doTraining =0;

if doTraining

   tic

   trainingStats = train(agent,env,trainOpts);

   toc

   save('7_Self_rlAutoParkingValetAgent.mat');

else

   load('6_Self_rlAutoParkingValetAgent.mat','agent');

end


set(gcf,'position',[500 600 1500 1000])

pause(1)

freeSpotIdx = 26;  % free spot location

sim(mdl);

% save('Self_rlAutoParkingValetAgent.mat');

% load('Self_rlAutoParkingValetAgent.mat');


⛄ 运行结果

⛄ 参考文献

[1]肖蓬勃. 基于MATLAB中高档轿车智能泊车系统开发及应用研究[D]. 桂林电子科技大学.

[2]陈慧, 宋绍禹, 孙宏伟,等. 一种基于模型强化学习的智能泊车方法:.

⛄ Matlab代码关注

❤️部分理论引用网络文献,若有侵权联系博主删除
❤️ 关注我领取海量matlab电子书和数学建模资料


相关文章
|
19天前
|
存储 人工智能 机器人
【Matlab】Matlab电话拨号音合成与识别(代码+论文)【独一无二】
【Matlab】Matlab电话拨号音合成与识别(代码+论文)【独一无二】
|
2月前
|
机器学习/深度学习 算法 计算机视觉
霍夫变换车道线识别-车牌字符识别代码(matlab仿真与图像处理系列第5期)
霍夫变换车道线识别-车牌字符识别代码(matlab仿真与图像处理系列第5期)
30 2
|
2月前
|
算法
MATLAB | 插值算法 | 一维interpl插值法 | 附数据和出图代码 | 直接上手
MATLAB | 插值算法 | 一维interpl插值法 | 附数据和出图代码 | 直接上手
40 0
|
2月前
|
算法
MATLAB | 插值算法 | 二维interp2插值法 | 附数据和出图代码 | 直接上手
MATLAB | 插值算法 | 二维interp2插值法 | 附数据和出图代码 | 直接上手
82 0
|
3月前
|
Perl
【MFAC】基于全格式动态线性化的无模型自适应控制(Matlab代码)
【MFAC】基于全格式动态线性化的无模型自适应控制(Matlab代码)
|
3月前
【数值分析】迭代法求方程的根(附matlab代码)
【数值分析】迭代法求方程的根(附matlab代码)
|
3月前
【数值分析】Jacobi、Seidel和Sor迭代法求解线性方程组(附matlab代码)
【数值分析】Jacobi、Seidel和Sor迭代法求解线性方程组(附matlab代码)
|
3月前
【数值分析】二分法求方程的根(附matlab代码)
【数值分析】二分法求方程的根(附matlab代码)
|
7月前
|
机器学习/深度学习 传感器 算法
基于同步压缩的多变量数据时频分析附 matlab代码
基于同步压缩的多变量数据时频分析附 matlab代码
|
2月前
|
算法
MATLAB | 插值算法 | 二维griddata插值法 | 附数据和出图代码 | 直接上手
MATLAB | 插值算法 | 二维griddata插值法 | 附数据和出图代码 | 直接上手
43 0

热门文章

最新文章