如何使用Matlab进行道路布局设计的编程

639 阅读7分钟

使用Matlab进行道路布局的程序化设计

简介

在设计道路布局时,我们使用drivingscenario 函数。scenario 函数可以模拟现实世界中的活动或结构。

你可以使用Drivingscenario ,通过在二维或三维图形中绘制道路布局图来创建不同的道路布局设计。它是通过使用函数roadCentre=[]; 指定道路中心的坐标和道路宽度,然后将这些点绘制在图形上。

前提条件

要跟上本教程,你需要。

  • 安装[MATLAB]。
  • 对MATLAB基础知识的[正确理解]。

目标

本文将使用Matlab函数讨论以下道路布局的设计。

  • 直线道路。
  • 有车道的道路。
  • 相交的道路。
  • 弯曲的道路布局。
  • 环岛布局。
  • 高架道路布局。
  • 立交桥道路布局。

直线道路

直线道路布局有一个固定的宽度。它可以通过定义道路中心坐标的两点和指定的宽度来设计。图轴以米为单位标示。

设计任何道路布局的第一步是定义scenarioscenario=drivingScenario

在声明场景函数后,指定道路中心坐标。对于我们的案例,我们将使用(0 10)(60 10) ,道路宽度为8米。

最终的道路布局是通过绘制scenario 、道路中心线和宽度得到的。结果图中会有一个笔直的道路布局。

scenario = drivingScenario; %declering the scenario function
road_center = [0 10;60 10]; %specifying road center coordinates
road_width = 8; %specified road width
road(scenario,road_center,road_width); %road properties
plot(scenario,'RoadCenters','on','Centerline','on')

straight road layout

有车道的道路

道路车道可以通过提供车道规格来创建。道路车道通过告知司机边界来控制交通流。车道也可以决定道路的承载能力。

在Matlab中,道路车道以两个数字的形式指定,与道路中心协调,第一个数字呈现道路前半部分的车道数,而第二个数字呈现道路后半部分的车道数。

在道路布局上制作车道时使用的函数是lanespec([]); 。例如,lanespec([2 2]); 将产生总共四条车道,每一半道路有两条车道,而lanespec([3 2]); 将产生总共五条车道,前一半有三条车道,后一半有两条车道。

下面的代码展示了总共四条车道的形成,道路中心的每一侧有两条车道。

scenario = drivingScenario; %declaring scenario function
road_centers = [0 10;50 10]; %specifying road centers
road(scenario,road_Centers,'lanes',lanespec([2 2])); % road properties
plot (scenario,'Roadcenters','on');

Laned road

道路交叉口

道路交叉口是指两条朝向不同方向的道路交叉,形成一个类似十字架的结构。

在Matlab中,只要有两条道路相交,就会自动创建交叉点。

要制作一个道路交叉口布局,必须制作两条不同的道路。这两条路中的一条将是垂直方向的,而另一条则是水平方向的。

为了演示,我们将截取两条直路。垂直的道路将有道路中心坐标[0 10; 50 10] 。水平方向的道路的中心坐标为[30 -30; 30 30]

以下代码演示了创建道路交叉口的过程。

scenario = drivingScenario;
road_Centre = [0 10;50 10]; %specifying road centre

% defining the first road
road_Centers =[0 10;50 10];
road(scenario,road_Centers,'lanes',lanespec([1 1]));

% defining the second road
road_Centers =[30 -30;30 30];
road(scenario,road_Centers,'lanes',lanespec([1 1]));

% plotting the two roads
plot(scenario,'RoadCenters','on');

Intersecting road layout

弯曲的道路布局

你可以使用三个或更多的点来指定道路中心坐标来生成弯曲的道路。道路将有一个固定的宽度,你必须指定未提及的车道的宽度。

制作曲线道路布局的代码语法与制作直线道路的代码语法几乎相似,唯一的区别是使用三个或更多的点来绘制道路中心,而在直线道路布局中,两个点就足以制作道路。

使用的道路中心坐标越多,形成的曲线道路就越复杂。

下面的代码说明了曲线道路布局的制作过程。我们将使用四点坐标来定义道路中心,即[0 0; 13 10; 30 -10; 50 -25]

使用的宽度将是8米。

scenario=drivingScenario; %declaring scenario function
road_Centers = [0 0; 13 -10; 30 -10; 50 -25]; %defining road centre coordinates
road_width =8; % specifing the road width
road(scenario,road_Centers,road_width,'lanes',lanespec(2)); % road properties
plot(scenario,'RoadCenters','on');

Curve road layout

环形道路布局

环岛路是圆形的,有四条现有的道路。当设计一个环形道路时,圆形部分是通过指定clothoid曲线的中心形成的。

在坐标描述的结尾处,会重复布土曲线的第一个坐标,形成一个连续的圆形环。

然后在环形道路上增加四条道路以完成道路布局。最后,应定义出口道路坐标,将环形道路周长切成四分之一。

下面的例子说明了环形路布局的设计。

首先,我们定义圆形路段的道路中心坐标为[-20 -20; 20 -20; 20 20; -20 20; -20 -20];

四条存在的道路使用四条不同的直路,其坐标被定义为[-35 0; -30 0];,[30 0; 35 0];,[0 35; 0 30];, 和[0 -30; 0 -35]; 。下面的代码显示了这个过程。

scenario = drivingScenario;
% defining coordinates of the circular part of the layout
roadCenter = [-20 -20
              20 -20
              20 20
              -20 20
              -20 -20];
road(scenario,roadCenter,'lanes',lanespec(1));

% defining the four exist roads coordinates
road(scenario,[-35 0; -30 0],'lanes',lanespec([1 1]));
road(scenario,[30 0; 35 0],'lanes',lanespec([1 1]));
road(scenario,[0 35; 0 30],'lanes',lanespec([1 1]));
road(scenario,[0 -30; 0 -35],'lanes',lanespec([1 1]));

% plotting the defined roads
plot(scenario,'RoadCenters','on')

Roundabout road layout

高架道路布局

可以通过引入z 坐标,在更高的地方设计道路布局,在三维图形上绘制显示。坐标将以(x,y,z) 的形式出现。z 坐标主要定义道路的纬度。例如,高原上的道路海拔较高,因此有较高的纬度。

高架道路的布局是通过定义道路中心坐标与3点坐标来实现的。

Z轴坐标的值决定了高程的大小。

下面的代码展示了高架道路的布局。道路中心坐标是[0 0 0; 30 0 6; 60 0 0] ,四条车道平均分布在两半。道路的最高点将在坐标中定义的海平面以上6米。

scenario = drivingScenario; % declering scenario type

% defining road center coordinates
roadCenter= [0 0 0
             30 0 6
             60 0 0];

% plotting the road layout            
road(scenario,roadCenter,'lanes',lanespec([2 2]));
plot(scenario,'RoadCenters','on');
view(30 24)  

Elevated road

立交桥道路

立交桥布局是指道路相互交叉而不相交。一条道路将在另一条道路之上;因此布局是用三点坐标定义的(x y z)

为了演示,我们将设计一条道路在另一条道路上方10米处通过。

立交桥的高度在Z轴上定义。该布局将加入一条弯曲的道路,形成一个连续的循环。

scenario = drivingScenario;

% road center coordinates
roadCenters = [0 0 0
               15 -25 0
               15 25 10
              -25 -25 10
              -25 15 0
               0 0 0];

% ploting the road coordiantes
road(scenario,roadCenter,'lanes',lanespec([2 2])); 
plot(scenario,'RoadCenters','on');
view(40,25)

Overpass road

总结

Matlab提供了一个设计道路布局的平台,可以使用驾驶场景设计器的应用程序或以编程方式设计,如文中所示。道路布局设计技术适用于交通模拟、道路规划和游戏开发。在这篇文章中,我们看了上述的各种组件来设计道路布局。