-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.m
47 lines (37 loc) · 1.69 KB
/
main.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
%% 参数设置
% 设置参数结构体
params = struct();
% 螺旋路径参数
params.spiral = struct(...
'd', 1, ... % 每层偏移距离
'minArea', 5, ... % 面积停止阈值
'maxSegLength', 1, ... % 每个采样线段的最大长度
'curvature', 0.2, ... % 曲率参数
'numCurvePts', 10, ... % 曲线上采样点数
'extendedGap', 1); % 沿路径方向延长的距离
% 平滑路径参数
params.smooth = struct(...
'radius', 1, ... % 平滑半径
'numCurvePts', 10, ... % 平滑曲线采样点数
'angleThreshold', pi/4); % 转角阈值
%% 读取地图数据
mapData = readVectorMapData();
%% 获取区域边界点与初始车道
boundary_points = getCustomArea(mapData);
[laneStartPt, laneEndPt] = getInitialLaneSegment(mapData);
lanePt = [laneStartPt; laneEndPt];
%% 区域边界与初始车道可视化
visualizeArea(boundary_points, lanePt, '区域边界与初始车道');
%% 生成螺旋路径
% 不使用S曲线连接
spiral_path = spiralPathGen(params.spiral, boundary_points, false, mapData);
plotSpiralPath(spiral_path, boundary_points, lanePt, '常规螺旋路径');
%% 生成用S曲线平滑连接的螺旋路径
% 使用S曲线连接
spiral_path = spiralPathGen(params.spiral, boundary_points, true, mapData);
plotSpiralPath(spiral_path, boundary_points, lanePt, '每层间使用S曲线平滑连接的螺旋路径');
%% 平滑路径中的转角
smooth_path = smoothCorners(spiral_path, params.smooth);
plotSpiralPath(smooth_path, boundary_points, lanePt, '再对转角进行平滑处理后的螺旋路径');
%% 将路径保存到VectorMap中
saveSmoothPathToVectorMap(smooth_path, mapData);