-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* course * course * course * coures * course * coure * course * course * course * course * course * course --------- Co-authored-by: zoudai <2184819232>
- Loading branch information
1 parent
5bef06e
commit 7b8b2fa
Showing
16 changed files
with
337 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# 交通拥堵模拟 | ||
|
||
`generate_traffic.py` 是一个用于模拟交通的脚本。通过多次运行该脚本,可以模拟和分析不同交通流量下的交通拥堵情况,并进行数据统计和优化评估。 | ||
|
||
## 功能介绍 | ||
|
||
1. **交通拥堵模拟**:通过多次运行脚本生成大量车辆,模拟不同场景下的交通流量变化。 | ||
2. **[统计分析](traffic_indicators.md)**:对多次模拟过程中的拥堵情况进行数据采集和统计分析。 | ||
3. **效果评估**:评估不同交通优化措施对缓解交通拥堵的影响。 | ||
|
||
# generate_traffic.py 使用说明文档 | ||
|
||
## 概述 | ||
|
||
`generate_traffic.py` 是一个用于模拟交通拥堵的脚本。通过多次运行该脚本,可以模拟和分析不同交通流量下的交通拥堵情况,并进行数据统计和优化评估。 | ||
|
||
## 功能介绍 | ||
|
||
1. **交通拥堵模拟**:通过多次运行脚本生成大量车辆,模拟不同场景下的交通流量变化。 | ||
2. **统计分析**:对多次模拟过程中的拥堵情况进行数据采集和统计分析。 | ||
3. **效果评估**:评估不同交通优化措施对缓解交通拥堵的影响。 | ||
|
||
## 使用方法 | ||
|
||
### 依赖环境 | ||
|
||
在运行 `generate_traffic.py` 之前,请确保安装了以下依赖包: | ||
|
||
- `CARLA`仿真环境的搭建。 | ||
- Carla,Numpy等依赖包的安装。 | ||
|
||
### 脚本运行 | ||
|
||
使用以下命令运行脚本: | ||
|
||
``` | ||
python generate_traffic.py | ||
``` | ||
|
||
## 多次运行模拟交通拥堵 | ||
|
||
为了模拟不同交通流量下的拥堵情况,可以多次运行 [**generate_traffic.py**](../../src/examples/generate_traffic.py) 脚本。 | ||
|
||
使用[**traffic_indicators.py**](../../src/course/traffic%20indicators.py)脚本对路口交通流量、路口车均延误、路口饱和、排队长度四种路口真实性评价指标分析。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# 区域宏观 | ||
|
||
此示例支持联合虚拟引擎仿真模拟实验,得到 **3D** 宏观区域场景演示。 | ||
|
||
## 环境依赖 | ||
|
||
- [**roadrunner**](https://pan.baidu.com/s/15T1hGoWJ70tVmsTX7-zcSw?pwd=hutb ) | ||
|
||
- **carla编辑器** [**配置教程**](https://zhuanlan.zhihu.com/p/552983835) | ||
|
||
|
||
## 场景设计 | ||
|
||
针对大区域的场景设计,支持从 **[openstreet](https://www.openstreetmap.org/)** 官网导出路网文件作为模版,然后导入到 **roadrunner** 中进行道路修改。 | ||
|
||
![](../img/traffic_course_img/roadnet.png) | ||
|
||
## 导入到虚幻引擎 | ||
|
||
本示例使用的为 **carla** 插件作为渲染引擎,进行建筑、树、山等的设计。 | ||
|
||
![](../img/traffic_course_img/regional_macro.png) | ||
|
||
| ||
|
||
## 导出可执行程序进行仿真模拟实验 | ||
|
||
运行下述exe程序作为服务端,采用python脚本与其通信。 | ||
|
||
![](../img/traffic_course_img/execu.png) | ||
|
||
## 宏观地图 | ||
|
||
将地图调整到全局俯视位置。 | ||
|
||
![](../img/traffic_course_img/regional_macro.gif) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
# 路网评价 | ||
|
||
#### **介绍** | ||
|
||
[该代码](../../src/course/roadnet_evaluation.py)用于评估CARLA仿真环境中的路网质量。评估的指标包括路网覆盖率、路口数量、交通灯数量和道路平均宽度。评估结果可以帮助了解仿真环境中的道路网络结构和配置。 | ||
|
||
#### **环境配置** | ||
|
||
要运行该代码,需要以下软件和库: | ||
|
||
- [CARLA仿真器](https://pan.baidu.com/s/15T1hGoWJ70tVmsTX7-zcSw?pwd=hutb) | ||
- Python 3.x | ||
- `carla` Python API | ||
- `geopandas`库 | ||
- `shapely`库 | ||
|
||
安装所需库的命令: | ||
|
||
``` | ||
pip install carla==0.9.15 | ||
pip install geopandas shapely | ||
``` | ||
|
||
#### **功能结构** | ||
|
||
该功能包含以下主要部分: | ||
|
||
1. **计算路网覆盖率** | ||
2. **计算路口数量** | ||
3. **计算交通灯数量** | ||
4. **计算道路平均宽度** | ||
|
||
##### 计算路网覆盖率 | ||
|
||
将道路几何信息转换为GeoPandas数据框,并计算道路覆盖的总长度和感兴趣区域的总面积,最后计算覆盖率。 | ||
|
||
``` | ||
def road_coverage(world): | ||
road_geometries = get_road_geometries(world) | ||
road_lines = [LineString(road_geometries)] | ||
road_gdf = gpd.GeoDataFrame(geometry=road_lines) | ||
area_of_interest = Polygon([(-500, -500), (-500, 500), (500, 500), (500, -500)]) | ||
area_gdf = gpd.GeoDataFrame(geometry=[area_of_interest]) | ||
total_road_length = road_gdf.length.sum() | ||
total_area = area_gdf.area.sum() | ||
coverage_ratio = total_road_length / total_area | ||
return coverage_ratio | ||
``` | ||
|
||
##### 计算路口数量 | ||
|
||
通过遍历所有路点,找到位于路口的路点并获取唯一的路口ID。 | ||
|
||
``` | ||
def intersection_num(world): | ||
carla_map = world.get_map() | ||
waypoints = carla_map.generate_waypoints(distance=2.0) | ||
junction_ids = set() | ||
for waypoint in waypoints: | ||
if waypoint.is_junction: | ||
junction = waypoint.get_junction() | ||
junction_ids.add(junction.id) | ||
return len(junction_ids) | ||
``` | ||
|
||
##### 计算交通灯数量 | ||
|
||
它通过获取所有交通灯的演员对象并计数来实现。 | ||
|
||
``` | ||
def traffic_num(world): | ||
traffic_lights = world.get_actors().filter('traffic.traffic_light') | ||
return len(traffic_lights) | ||
``` | ||
|
||
##### 计算道路平均宽度 | ||
|
||
它遍历所有路点,累计车道宽度并计算平均值。 | ||
|
||
``` | ||
def road_width(world): | ||
carla_map = world.get_map() | ||
waypoints = carla_map.generate_waypoints(2.0) | ||
total_width = 0.0 | ||
lane_count = 0 | ||
for waypoint in waypoints: | ||
total_width += waypoint.lane_width | ||
lane_count += 1 | ||
if lane_count > 0: | ||
average_width = total_width / lane_count | ||
return average_width | ||
else: | ||
return 0 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,19 +6,19 @@ | |
|
||
## RoadRunner简介 | ||
|
||
RoadRunner是一个交互式编辑器,可以让您设计3D场景来仿真和测试自动驾驶系统。它可以用来创建道路布局和伴随的opdrive和几何信息。[在这里了解更多关于RoadRunner的信息](https://github.com/OpenHUTB/carla_doc/blob/master/docs/rr_home)。 | ||
RoadRunner是一个交互式编辑器,可以让您设计3D场景来仿真和测试自动驾驶系统。它可以用来创建道路布局和伴随的opdrive和几何信息。 | ||
|
||
RoadRunner是MATLAB校园许可的一部分,因此许多大学可以提供无限制的学术访问。[检查](https://github.com/OpenHUTB/carla_doc/blob/master/docs/rr_eligibility)一下你的大学是否有访问权限。如果有任何关于可访问性的问题或麻烦,请联系[[email protected]](mailto:[email protected])。[还有一个试用版](https://github.com/OpenHUTB/carla_doc/blob/master/docs/[rr_trial_version)。 | ||
RoadRunner是MATLAB校园许可的一部分,因此许多大学可以提供无限制的学术访问。检查一下你的大学是否有访问权限。如果有任何关于可访问性的问题或麻烦,请联系[[email protected]](mailto:[email protected])。 | ||
|
||
参加 Carla 排行榜的每个人都可以获得RoadRunner的许可证。[点击这里了解更多信息](https://github.com/OpenHUTB/carla_doc/blob/master/docs/rr_leaderboard)。 | ||
参加 Carla 排行榜的每个人都可以获得RoadRunner的许可证。 | ||
|
||
**[RoadRunner R2022b 安装包](https://pan.baidu.com/s/1n2fJvWff4pbtMe97GOqtvQ?pwd=hutb)**,如下图所示,解压后直接运行里面的exe程序。 | ||
|
||
![](../img/traffic_course_img/1.png) | ||
|
||
------ | ||
|
||
## RoadRunner基本使用 | ||
## RoadRunner基本使用<span id="sceneEditing"></span> | ||
|
||
RoadRunner界面分为Scene Editing和Scenario Editing,下图所示为roadrunner软件的Scene Editing(静态路网编辑)基本功能界面: | ||
|
||
|
@@ -38,13 +38,13 @@ RoadRunner界面分为Scene Editing和Scenario Editing,下图所示为roadrunn | |
|
||
------ | ||
|
||
### 使用公开道路地图生成道路网络 | ||
### 使用公开道路地图生成道路网络<span id="generateMapByOpenMap"></span> | ||
|
||
**[OpenStreetMap](https://www.openstreetmap.org/)**是一个开放、可编辑的地图项目,由全球志愿者贡献数据,其数据包括道路、建筑物、地理特征、交通设施等地理信息。使用者可以搜索相应的道路信息,选择导出**osm**路网文件。 | ||
|
||
![](../img/traffic_course_img/3.png) | ||
|
||
**还可以进行对该网站的编辑修改**:**[OpenStreetMap地图编辑](https://openhutb.github.io/carla_doc/adv_edit_openstreetmap/)** | ||
**还可以进行对该网站的编辑修改**:**[OpenStreetMap地图编辑](../../adv_edit_openstreetmap/)** | ||
|
||
|
||
|
||
|
@@ -58,12 +58,12 @@ RoadRunner界面分为Scene Editing和Scenario Editing,下图所示为roadrunn | |
|
||
## 在RoadRunner进行车辆模拟仿真 | ||
|
||
**Scenario Editing**为动态路网编辑,可以添加/删除车辆,进行车辆速度设置、轨迹的可视化规划等, 并支持编辑器内播放,用于可视化场景并连接到其他场景 用于协同仿真的模拟器。右上角的下拉栏可进行动/静编辑切换。相关学习链接可参考:**[Scenario]([设计和模拟场景 - MATLAB 和 Simulink - MathWorks 中国](https://ww2.mathworks.cn/help/roadrunner-scenario/design-and-simulate-scenarios.html))** | ||
**Scenario Editing**为动态路网编辑,可以添加/删除车辆,进行车辆速度设置、轨迹的可视化规划等, 并支持编辑器内播放,用于可视化场景并连接到其他场景 用于协同仿真的模拟器。右上角的下拉栏可进行动/静编辑切换。 | ||
|
||
------ | ||
|
||
# 基于Carla与RoadRunner的联合仿真 | ||
|
||
参考链接:**[联合仿真](https://zhuanlan.zhihu.com/p/552983835)** | ||
|
||
[RoadRunner导出大地图教程](https://openhutb.github.io/carla_doc/tuto_M_generate_map/) | ||
[RoadRunner导出大地图教程](../..//tuto_M_generate_map/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.