Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
12 changes: 12 additions & 0 deletions src/V2X_edge_intelligence/src/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# 路侧感知数据集预处理模块(Carla适配)
## 模块说明
本模块针对Carla模拟器生成的车路协同路侧感知数据,实现轻量化预处理(数据生成、增强、划分),全程无第三方依赖,直接运行出结果。

## 运行环境
- Python 3.6+(无需任何第三方库,仅用内置模块)
- 操作系统:Windows/Linux/macOS均可

## 运行步骤
1. 进入模块目录:
```bash
cd C:\Users\21015\PycharmProjects\nn2\V2X_edge_intelligence\src
92 changes: 92 additions & 0 deletions src/V2X_edge_intelligence/src/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
路侧感知数据集预处理(Carla适配)
零第三方依赖(仅Python内置库),完全无报错!
运行方式:python main.py
"""
import json
import os
import random


# ===================== 第一步:生成模拟Carla数据(纯文本,不用图片) =====================
def generate_demo_data():
"""生成模拟Carla标注数据(纯文本,无需图片/OpenCV,零报错)"""
os.makedirs("demo_carla_data", exist_ok=True)
# 生成Carla场景标注(纯JSON文本,模拟感知数据)
anno_data = {
"carla_scenes": [
{"scene_id": 1001, "frame_id": 0,
"obstacles": [{"type": "car", "bbox": [100, 100, 200, 200], "distance": 8.5}]},
{"scene_id": 1002, "frame_id": 1,
"obstacles": [{"type": "person", "bbox": [150, 150, 250, 250], "distance": 5.2}]}
]
}
with open("demo_carla_data/carla_anno.json", "w", encoding="utf-8") as f:
json.dump(anno_data, f, indent=2)
print("✅ 模拟Carla标注数据生成完成 → demo_carla_data/carla_anno.json")


# ===================== 第二步:数据增强(文本层面模拟,无需图片) =====================
def simple_augment():
"""模拟数据增强(文本层面扩充,比如添加噪声、复制数据)"""
with open("demo_carla_data/carla_anno.json", "r", encoding="utf-8") as f:
data = json.load(f)

# 模拟增强:为每个场景添加随机噪声(模拟图像增强)
augmented_data = []
for scene in data["carla_scenes"]:
# 复制场景并添加噪声
aug_scene = scene.copy()
aug_scene["aug_type"] = "random_brightness" # 模拟亮度增强
# 给障碍物距离加随机噪声
for obs in aug_scene["obstacles"]:
obs["distance"] = round(obs["distance"] + random.uniform(-0.5, 0.5), 2)
augmented_data.append(aug_scene)

# 保存增强后数据
with open("demo_carla_data/carla_anno_augmented.json", "w", encoding="utf-8") as f:
json.dump({"carla_scenes_augmented": augmented_data}, f, indent=2)
print("✅ 数据增强完成 → demo_carla_data/carla_anno_augmented.json")


# ===================== 第三步:数据集划分(纯文本,内置库实现) =====================
def split_dataset():
"""划分数据集(8:1:1,纯文本处理)"""
with open("demo_carla_data/carla_anno.json", "r", encoding="utf-8") as f:
data = json.load(f)

scenes = data["carla_scenes"]
random.shuffle(scenes) # 随机打乱
total = len(scenes)
train_size = int(total * 0.8)
val_size = int((total - train_size) / 2)

# 划分数据
train_data = scenes[:train_size]
val_data = scenes[train_size:train_size + val_size]
test_data = scenes[train_size + val_size:]

# 保存划分结果
split_result = {
"train_scenes": train_data,
"val_scenes": val_data,
"test_scenes": test_data,
"split_ratio": "train:80% | val:10% | test:10%"
}
with open("demo_carla_data/carla_split_result.json", "w", encoding="utf-8") as f:
json.dump(split_result, f, indent=2)
print("✅ 数据集划分完成 → demo_carla_data/carla_split_result.json")
print(f" 划分结果:训练集{len(train_data)}条 | 验证集{len(val_data)}条 | 测试集{len(test_data)}条")


# ===================== 主函数:一键运行 =====================
if __name__ == "__main__":
print("===== 路侧感知数据集预处理(Carla适配) =====\n")
generate_demo_data()
simple_augment()
split_dataset()
print("\n🎉 所有步骤运行完成!生成文件列表:")
for file in os.listdir("demo_carla_data"):
print(f" - demo_carla_data/{file}")
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "pip" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
Empty file.
54 changes: 54 additions & 0 deletions src/V2X_edge_intelligence/src/road_side_perception/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# 神经网络实现代理

利用神经网络/ROS 实现 Carla(车辆、行人的感知、规划、控制)、AirSim、Mujoco 中人和载具的代理。

## 环境配置

* 平台:Windows 10/11,Ubuntu 20.04/22.04
* 软件:Python 3.7-3.12(需支持3.7)、Pytorch(尽量不使用Tensorflow)
* 相关软件下载 [链接](https://pan.baidu.com/s/1IFhCd8X9lI24oeYQm5-Edw?pwd=hutb)

## 功能模块表
| 模块类别 | 模块名 | 链接 | 其他 |
|-------------------|------------|-------------------------------------------------------------------------------|---------------------------------------------------------------------|
| 规划 | 车辆全局路径规划 | [carla_slam_gmapping](https://github.com/OpenHUTB/nn/tree/main/src/carla_slam_gmapping) | - |


## 贡献指南

准备提交代码之前,请阅读 [贡献指南](https://github.com/OpenHUTB/.github/blob/master/CONTRIBUTING.md) 。
代码的优化包括:注释、[PEP 8 风格调整](https://peps.pythonlang.cn/pep-0008/) 、将神经网络应用到Carla模拟器中、撰写对应 [文档](https://openhutb.github.io/nn/) 、添加 [源代码对应的自动化测试](https://docs.github.com/zh/actions/use-cases-and-examples/building-and-testing/building-and-testing-python) 等(从Carla场景中获取神经网络所需数据或将神经网络的结果输出到场景中)。

### 约定

* 每个模块位于`src/{模块名}`目录下,`模块名`需要用2-3个单词表示,首字母不需要大写,下划线`_`分隔,不能宽泛,越具体越好
* 每个模块的入口须为`main.`开头,比如:main.py、main.cpp、main.bat、main.sh等,提供的ROS功能以`main.launch`文件作为启动配置文件
* 每次pull request都需要保证能够通过main脚本直接运行整个模块,在提交信息中提供运行动图或截图;Pull Request的标题不能随意,需要概括具体的修改内容;README.md文档中提供运行环境和运行步骤的说明
* 仓库尽量保存文本文件,二进制文件需要慎重,如运行需要示例数据,可以保存少量数据,大量数据可以通过提供网盘链接并说明下载链接和运行说明


### 文档生成

测试生成的文档:
1. 安装python 3.11,并使用以下命令安装`mkdocs`和相关依赖:
```shell
pip install mkdocs -i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com
pip install -r requirements.txt
```
(可选)安装完成后使用`mkdocs --version`查看是否安装成功。

2. 在命令行中进入`nn`目录下,运行:
```shell
mkdocs build
mkdocs serve
```
然后使用浏览器打开 [http://127.0.0.1:8000](http://127.0.0.1:8000),查看文档页面能否正常显示。

## 参考

* [代理模拟器文档](https://openhutb.github.io)
* 已有相关 [无人车](https://openhutb.github.io/doc/used_by/) 、[无人机](https://openhutb.github.io/air_doc/third/used_by/) 、[具身人](https://openhutb.github.io/doc/pedestrian/humanoid/) 的实现
* [神经网络原理](https://github.com/OpenHUTB/neuro)

通过网盘分享的文件:supercombo.h5
链接: https://pan.baidu.com/s/1yYc4aPBLnXRuWXEb0hyKMA?pwd=1234 提取码: 1234
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
47 changes: 47 additions & 0 deletions src/V2X_edge_intelligence/src/road_side_perception/mkdocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
site_name: 神经网络
# 参考链接:https://blog.csdn.net/m0_63203517/article/details/129765689

#repo_url: https://github.com/carla-simulator/carla
#docs_dir: Docs
#edit_uri: 'edit/master/Docs/'


# 设置编译页面的链接的前缀
repo_url: https://github.com/OpenHUTB/nn

# 页面右上角添加直接编辑页面的按钮
edit_uri: edit/master/docs/

theme:
name: readthedocs
sticky_navigation: True
navigation_depth: 3
features:
- search.suggest # 在目录栏中的搜索框中输入一些字母时推荐补全整个单词
extra_css: [extra.css]



# mathjax用于单独公式展示
extra_javascript:
- extra.js
- https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.4/MathJax.js?config=TeX-AMS-MML_HTMLorMML

plugins:
# - mkdocs-video
- search:
lang: ja
separator: '[\s\-\.]+'
min_search_length: 3

extra:
generator: false

nav:
- 首页: 'index.md'


# - mdx_math 用于行内公式显示
markdown_extensions:
- admonition
- mdx_math
Empty file.
Empty file.
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.
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.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Empty file.
Loading
Loading