classdef ParkingLot < handle
% MAP = ParkingLot(FREEIDXS) creates a parking lot with the free spots
% specified in the array FREEIDXS.
%
% MAP is a struct containing the following fields:
% 1. XLimits - map X limits
% 2. YLimits - map Y limits
% 3. SpotLocations = [x y] of occupied spaces
% 4. OccupiedSpots = binary array of size 1x64, 1 occupied, 0 free
% 5. TotalSpots - total number of parking spots
% 6. AxesHandle - axes handle of the figure
%
% Total number of parking spots in this parking lot is 64 (non-tunable).
% Copyright 2020 The MathWorks, Inc.
properties
VehiclePose = [20 16 0]
TrainingZoneXLimits = [36.5 59]
TrainingZoneYLimits = [0 20]
end
properties (SetAccess = private)
XLimits = [0 100]
YLimits = [0 60]
SpotDimensions = [4.5 7]
ObstacleDimensions = [4.7 2.5]
VehicleDimensions = [4.7 1.8]
Wheelbase = 2.8
PassageWidth = 16
MaxSpots = 64
SpotLocations = zeros(64,2)
SensorLocations = zeros(64,2)
OccupiedSpots = ones(1,64)
ObstacleMatrix
end
properties (Hidden)
Figure
VehicleBodyHandle
VehicleAxlesHandle
VehicleWheelsHandle
LidarLinesHandle
LidarCrossHandle
CameraFOVHandle
TrainZoneHandle
VehicleStatusHandle
ControllerStatusHandle
TimeDisplayHandle
ReferencePathRect
ReferencePathCurvature = 0.3
end
methods
function map = ParkingLot(freeidxs)
arguments
freeidxs (1,1) double {localValidateIdx}
end
map.OccupiedSpots(freeidxs) = 0;
map.ReferencePathRect = [ map.XLimits(1)+map.SpotDimensions(2)+0.5*map.PassageWidth, ...
map.YLimits(1)+map.SpotDimensions(2)+0.5*map.PassageWidth, ...
diff(map.XLimits)-2*(map.SpotDimensions(2)+0.5*map.PassageWidth), ...
diff(map.YLimits)-2*(map.SpotDimensions(2)+0.5*map.PassageWidth) ];
buildFigure(map);
initializeMap(map);
map.ObstacleMatrix = getObstacles(map, find(map.OccupiedSpots==1));
map.Figure.Visible = 'on';
end
function show(map)
% show(map) displays the map in a figure.
if isempty(map.Figure)
updateMap(map);
else
map.Figure.Visible = 'on';
end
end
function buildFigure(map)
% Build the figure
map.Figure = figure;
map.Figure.Position = [435 200 1290 740];
map.Figure.Name = 'Auto Parking Valet';
map.Figure.NumberTitle = 'off';
%map.Figure.MenuBar = 'none';
%map.Figure.CloseRequestFcn = @localHideFigure;
ax = gca(map.Figure);
legend(ax,'off');
hold(ax, 'on');
ax.XLimMode = 'manual';
ax.YLimMode = 'manual';
ax.XLim = map.XLimits;
ax.YLim = map.YLimits;
end
function highlight(map,idx)
% highlight(map,idx) highlights a spot in the map specified in idx.
arguments
map
idx (1,1) double
end
ax = gca(map.Figure);
iseastspot = idx >= 15 && idx <= 22;
iswestspot = idx >= 37 && idx <= 40;
if iseastspot || iswestspot
posx = map.SpotLocations(idx,1) - 0.5*map.ObstacleDimensions(1) - 0.5;
posy = map.SpotLocations(idx,2) - 0.5*map.ObstacleDimensions(2) - 0.5;
len = map.ObstacleDimensions(1) + 1;
wid = map.ObstacleDimensions(2) + 1;
else
posx = map.SpotLocations(idx,1) - 0.5*map.ObstacleDimensions(2) - 0.5;
posy = map.SpotLocations(idx,2) - 0.5*map.ObstacleDimensions(1) - 0.5;
len = map.ObstacleDimensions(2) + 1;
wid = map.ObstacleDimensions(1) + 1;
end
hlight = findobj(ax,'Tag','hlight');
if isempty(hlight)
rectangle(ax,'Position',[posx posy len wid],'EdgeColor','g','LineWidth',2,'Tag','hlight')
else
hlight.Position = [posx posy len wid];
end
drawnow;
end
function setFree(map,idxs)
% setFree(map,idxs) frees the spots with index IDXS.
localValidateIdx(idxs)
map.OccupiedSpots(idxs) = 0;
map.ObstacleMatrix = getObstacles(map, find(map.OccupiedSpots==1));
initializeMap(map);
end
function setOccupied(map,idxs)
% setOccupied(map,idxs) occupies the spots with index IDXS.
localValidateIdx(idxs)
map.OccupiedSpots(idxs) = 1;
map.ObstacleMatrix = getObstacles(map, find(map.OccupiedSpots==1));
initializeMap(map);
end
function obs = getObstacles(map,spotidx)
% obs = getObstacles(map) returns the list of obstacles in the
% parking lot in [x y xlen ylen theta] format.
%
% obs = getObstacles(map,spotidx) returns the obstacle at the
% spot index spotidx in [x y xlen ylen theta] format.
arguments
map
spotidx (1,:) double = find(map.OccupiedSpots)
end
obs = zeros(numel(spotidx)+11,5);
ct = 1;
while ct <= numel(spotidx)
iseastspot = spotidx(ct) >= 15 && spotidx(ct) <= 22;
iswestspot = spotidx(ct) >= 37 && spotidx(ct) <= 40;
if iseastspot || iswestspot
obs(ct,1) = map.SpotLocations(spotidx(ct),1);
obs(ct,2) = map.SpotLocations(spotidx(ct),2);
obs(ct,3) = map.ObstacleDimensions(1);
obs(ct,4) = map.ObstacleDimensions(2);
obs(ct,5) = 0;
else
obs(ct,1) = map.SpotLocations(spotidx(ct),1);
obs(ct,2) = map.SpotLocations(spotidx(ct),2);
obs(ct,3) = map.ObstacleDimensions(2);
obs(ct,4) = map.ObstacleDimensions(1);
obs(ct,5) = 0;
end
ct = ct + 1;
end
% add obstacles at corners
obs(ct:ct+5,:) = [9.25 3.35 16.5 4.7 0; ...
90.75 3.35 16.5 4.7 0; ...
96.35 8.5 4.7 5 0; ...
96.35 51.5 4.7 5 0; ...
90.75 56.35 16.5 4.7 0; ...
9.25 56.35 16.5 4.7 0];
% add obstacles at map boundary
obs(ct+6:end,:) = ...
[50 0.25 100 0.5 0; ...
99.75 30 0.5 60 0; ...
50 59.75 100 0.5 0; ...
0.25 30 0.5 60 0; ...
50 30 54 0.5 0];
end
function pose = createTargetPose(map,idx)
% pose = createTargetPose(map,idx,wbase,theta) returns a target
% pose for the vehicle based on the specified parking spot index
% idx and wheelbase length wbase.
arguments
map
idx (1,1) double {mustBePositive,mustBeInteger}
end
wbase = map.Wheelbase;
loc = map.SpotLocations(idx,:);
issouthspot = idx <= 14;
iseastspot = idx >= 15 && idx <= 22;
isnorthspot = idx >= 23 && idx <= 36;
iswestspot = idx >= 37 && idx <= 40; %#ok<NASGU>
if issouthspot
pose(1) = loc(1);
pose(2) = loc(2) + 0.5*wbase;
pose(3) = -pi/2;
els
没有合适的资源?快使用搜索试试~ 我知道了~
泊车基于matlab强化学习智能泊车【含Matlab源码 2269期】.zip
共39个文件
m:16个
mat:14个
png:3个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 3 下载量 120 浏览量
2022-12-09
15:04:37
上传
评论 2
收藏 13.22MB ZIP 举报
温馨提示
CSDN海神之光上传的全部代码均可运行,亲测可用,尽我所能,为你服务; 1、代码压缩包内容 主函数:GDPSO.m; 调用函数:其他m文件;无需运行 运行结果效果图; 2、代码运行版本 Matlab 2019b;若运行有误,根据提示修改;若不会,可私信博主; 3、运行操作步骤 步骤一:将所有文件放到Matlab的当前文件夹中; 步骤二:双击打开GDPSO.m文件; 步骤三:点击运行,等程序运行完得到结果; 4、物理应用 仿真:导航、地震、电磁、电路、电能、机械、工业控制、水位控制、直流电机、平面电磁波、管道瞬变流 光学:光栅、杨氏双缝、单缝、多缝、圆孔、矩孔衍射、夫琅禾费、干涉、拉盖尔高斯、光束、光波、涡旋 定位问题:chan、taylor、RSSI、music、卡尔曼滤波UWB 气动学:弹道、气体扩散、龙格库弹道 运动学:倒立摆、泊车 天体学:卫星轨道、姿态
资源推荐
资源详情
资源评论
收起资源包目录
【泊车】基于matlab强化学习智能泊车【含Matlab源码 2269期】.zip (39个子文件)
【泊车】基于matlab强化学习智能泊车【含Matlab源码 2269期】
LIDARSensor.m 8KB
Main.m 3KB
vehicleStateFcn.m 376B
ParkingLotSimulator.m 5KB
6_Self_rlAutoParkingValetAgent.mat 10.16MB
parkingVehicleStateJacobianFcnRRT.m 553B
parkingVehicleStateFcnRRT.m 401B
autoParkingValetResetFcn.m 1003B
rlAutoParkingValet.slxc 8KB
createMPCForParking.m 2KB
getRefTraj.m 732B
1.png 59KB
Camera.m 6KB
vehicleStateJacobianFcnDT.m 861B
__MACOSX
._TrainAutomaticParkingValetExample (Open source) 210B
getCarSegmentLengths.m 848B
rlAutoParkingValetAgent.mat 1.34MB
slprj
_sfprj
EMLReport
s4pcQVi77kT0D4HfgPfSqMF.mat 143KB
emlReportAccessInfo.mat 981B
sauxN0t3q4Jd1d59ODOl52
sWU3PqPsNrcCANUow0Y0lJB
s4pcQVi77kT0D4HfgPfSqMF
svQHz9c48j2iAPE61jSUriC
stED4Z86JSC8UW44rTgtRl.mat 6KB
sV9IXewWqunqnUOOc94O0pC
sdSGrBkqDh2yEk6VUbICKwH
sOrstfk5jCL7Q2TocSJexAD
sauxN0t3q4Jd1d59ODOl52.mat 5KB
sEg1MtXke8fN8uNqSoFEcrF
sEg1MtXke8fN8uNqSoFEcrF.mat 117KB
sdSGrBkqDh2yEk6VUbICKwH.mat 5KB
sV9IXewWqunqnUOOc94O0pC.mat 6KB
sOrstfk5jCL7Q2TocSJexAD.mat 207KB
svQHz9c48j2iAPE61jSUriC.mat 113KB
stED4Z86JSC8UW44rTgtRl
sWU3PqPsNrcCANUow0Y0lJB.mat 29KB
sim
varcache
rlAutoParkingValet
varInfo.mat 9KB
tmwinternal
simulink_cache.xml 376B
checksumOfCache.mat 392B
autoParkingValetParams.m 1KB
lidarSegmentIntersections.m 2KB
4.png 57KB
ParkingLot.m 33KB
rlAutoParkingValet.slx.original 78KB
rlAutoParkingValet.slx 86KB
3.png 58KB
rect2segs.m 448B
TrainAutomaticParkingValetExample.mlx 1.12MB
共 39 条
- 1
资源评论
- weixin_569278092023-02-03资源不错,内容挺好的,有一定的使用价值,值得借鉴,感谢分享。
- weixin_431153672023-05-17发现一个宝藏资源,赶紧冲冲冲!支持大佬~
- 风娑飒踏2024-05-01实在是宝藏资源、宝藏分享者!感谢大佬~
海神之光
- 粉丝: 3w+
- 资源: 2095
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功