From d06d0b245e6e3c59cd8d94e5c84fe3546daf0ea8 Mon Sep 17 00:00:00 2001 From: "Zimin,Liu" <1115457645@qq.com> Date: Sat, 13 Dec 2025 02:47:43 +0000 Subject: [PATCH 1/4] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E8=B4=A1=E7=8C=AE?= =?UTF-8?q?=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/Conpute_involvement.yml | 37 ++++++ Contribution_analysis.py | 131 ++++++++++++++++++++++ 2 files changed, 168 insertions(+) create mode 100644 .github/workflows/Conpute_involvement.yml create mode 100644 Contribution_analysis.py diff --git a/.github/workflows/Conpute_involvement.yml b/.github/workflows/Conpute_involvement.yml new file mode 100644 index 0000000000..8f32dbb5b4 --- /dev/null +++ b/.github/workflows/Conpute_involvement.yml @@ -0,0 +1,37 @@ + +name: compute involvement degree + +# 触发条件:每次 push 代码时运行 +on: [push] + +jobs: + compute: + # 使用矩阵策略,同时在 ubuntu 和 windows 上运行 + strategy: + matrix: + os: [ubuntu-latest, windows-latest] # 添加 windows-latest + + # 运行环境 + runs-on: ${{ matrix.os }} + + steps: + # 1. 拉取完整 Git 历史(必须保留,否则无法统计所有提交和代码行数) + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + # 2. 设置 Python 环境 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.x' + architecture: 'x64' + + # 3. 安装依赖 + # 在 Windows 上 pip 命令相同,但 GitPython 在 Windows 下也能正常工作 + - name: Install Python dependencies + run: python -m pip install --upgrade pip requests gitpython + + # 4. 执行你的贡献统计脚本 + - name: Display involvement degree (${{ matrix.os }}) + run: python Contribution_analysis.py -t ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/Contribution_analysis.py b/Contribution_analysis.py new file mode 100644 index 0000000000..a024328b99 --- /dev/null +++ b/Contribution_analysis.py @@ -0,0 +1,131 @@ +import requests # 用于发起网络请求 +import argparse # 用于解析命令行参数 +import os # 用于操作系统级别的操作 +from collections import defaultdict, Counter # 用于数据结构操作 +import git # 用于操作Git库 + +# 设置命令行参数解析 +#通过argparse库,代码定义了一个命令行工具,允许用户通过命令行传入GitHub的访问令牌 +argparser = argparse.ArgumentParser(description='Involvement Degree') +argparser.add_argument('-t', '--token', help='your personal github access token') +args = argparser.parse_args() + +# 获取GitHub访问令牌 +TOKEN = args.token +#设置请求头包含授权信息 +# 设置请求头 +headers = { + 'Authorization': f'token {TOKEN}', + 'Accept': 'application/vnd.github.v3+json' +} + +# 仓库信息 +owner = 'OpenHUTB' # 仓库所有者 +repo = 'nn' # 仓库名称 + +######################################### +####### 统计代码添加和删除行数 ######## +######################################### +def commit_info(): + from git.repo import Repo + + # 初始化本地仓库路径 + local_path = os.path.join('.') + repo = Repo(local_path) + + # 获取提交日志,格式为作者名字 + log_info = repo.git.log('--pretty=format:%an') + authors = log_info.splitlines() + + # 定义别名映射 + alias_map = { + '刘子民': 'ziminliu', + } + + # 标准化作者名字 + normalized_authors = [alias_map.get(author, author) for author in authors] + + # 统计每个作者的提交次数 + author_counts = Counter(normalized_authors) + print("提交次数:") + for author, count in author_counts.most_common(): + print(f"{author}: {count} 次提交") + + # 获取提交日志,格式为作者名字,并包含增删行数 + log_data = repo.git.log('--pretty=format:%an', '--numstat') + + # 统计每个作者的增加行数 + author_stats = defaultdict(lambda: {'added': 0, 'deleted': 0}) + #初始化当前作者为None + current_author = None + #遍历日志的每一行 + for line in log_data.splitlines(): + #如果行中不包括制表符(\t)或者行内容为空 + if '\t' not in line or line.isdigit(): + #将当前作者设为该行内容(去除首尾空白字符) + current_author = line.strip() + elif '\t' in line: + added, deleted, _ = line.split('\t') + if added != '-': + author_stats[current_author]['added'] += int(added) + if deleted != '-': + author_stats[current_author]['deleted'] += int(deleted) + + # 输出每个作者的增加行数 + for author, stats in author_stats.items(): + print(f"{author}: 添加 {stats['added']} 行, 删除 {stats['deleted']} 行") + +commit_info() + +######################################### +####### 统计用户提问和评论数 ############## +######################################### +issue_counts = {} +comment_counts = {} + +page = 1 +while True: + url = f'https://api.github.com/repos/{owner}/{repo}/issues?state=all&per_page=100&page={page}' + response = requests.get(url, headers=headers) +#处理API响应 + if response.status_code != 200: + print("请求失败,请检查网络连接或GitHub令牌。") + break + + #将响应数据解析为JSON格式 + issues = response.json() + if not issues: + #跳出循环 + break + + #遍历所有问题 + for issue in issues: + if 'pull_request' in issue: + #跳过当前循环,继续下一个问题的处理 + continue + + #获取问题的用户登陆名 + user = issue['user']['login'] + #更新用户提出问题的计数 + issue_counts[user] = issue_counts.get(user, 0) + 1 + + comments_url = issue['comments_url'] + comments_response = requests.get(comments_url, headers=headers) + comments = comments_response.json() + + for comment in comments: + commenter = comment['user']['login'] + comment_counts[commenter] = comment_counts.get(commenter, 0) + 1 + + page += 1 + +sorted_issue_counts = dict(sorted(issue_counts.items(), key=lambda item: item[1], reverse=True)) +sorted_comment_counts = dict(sorted(comment_counts.items(), key=lambda item: item[1], reverse=True)) +#将统计结果按照次数从高到低排序并打印出来 +print("提问次数:") +for user, count in sorted_issue_counts.items(): + print(f"{user}: {count}") + +print("\n回答次数:") +for user, count in sorted_comment_counts.items(): + print(f"{user}: {count}") \ No newline at end of file From 19cecafec22d3ee00d7a68ad1d4aa82ab9345363 Mon Sep 17 00:00:00 2001 From: qq1115457645 <1115457645@qq.com> Date: Sun, 8 Mar 2026 14:42:35 +0800 Subject: [PATCH 2/4] add_contribution_actions --- .github/workflows/Conpute_involvement.yml | 37 ---- .github/workflows/compute_involvement.yml | 62 +++++-- contribution_analysis.py | 211 ++++++++-------------- ignore_users.json | 5 + 4 files changed, 127 insertions(+), 188 deletions(-) delete mode 100644 .github/workflows/Conpute_involvement.yml create mode 100644 ignore_users.json diff --git a/.github/workflows/Conpute_involvement.yml b/.github/workflows/Conpute_involvement.yml deleted file mode 100644 index 8f32dbb5b4..0000000000 --- a/.github/workflows/Conpute_involvement.yml +++ /dev/null @@ -1,37 +0,0 @@ - -name: compute involvement degree - -# 触发条件:每次 push 代码时运行 -on: [push] - -jobs: - compute: - # 使用矩阵策略,同时在 ubuntu 和 windows 上运行 - strategy: - matrix: - os: [ubuntu-latest, windows-latest] # 添加 windows-latest - - # 运行环境 - runs-on: ${{ matrix.os }} - - steps: - # 1. 拉取完整 Git 历史(必须保留,否则无法统计所有提交和代码行数) - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - # 2. 设置 Python 环境 - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.x' - architecture: 'x64' - - # 3. 安装依赖 - # 在 Windows 上 pip 命令相同,但 GitPython 在 Windows 下也能正常工作 - - name: Install Python dependencies - run: python -m pip install --upgrade pip requests gitpython - - # 4. 执行你的贡献统计脚本 - - name: Display involvement degree (${{ matrix.os }}) - run: python Contribution_analysis.py -t ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/compute_involvement.yml b/.github/workflows/compute_involvement.yml index 6bd66a7994..0e759d94f4 100644 --- a/.github/workflows/compute_involvement.yml +++ b/.github/workflows/compute_involvement.yml @@ -1,22 +1,29 @@ - name: compute involvement degree -# 触发条件:每次 push 代码时运行 -on: [repository_dispatch] +# 修正后的触发器:支持手动输入时间、自动推送到 main、以及远程触发 +on: + push: + branches: + - main + repository_dispatch: + types: [opened, deleted, custom-event] + workflow_dispatch: + inputs: + since: + description: '统计开始时间 (例如: 2026-03-05 12:00)' + required: false + until: + description: '统计结束时间 (例如: 2026-03-07 12:00)' + required: false jobs: compute: - # 使用矩阵策略,同时在 ubuntu 和 windows 上运行 - strategy: - matrix: - os: [ubuntu-latest] # 添加 windows-latest - - # 运行环境 - runs-on: ${{ matrix.os }} + runs-on: ubuntu-latest steps: - # 1. 拉取完整 Git 历史(必须保留,否则无法统计所有提交和代码行数) - - uses: actions/checkout@v4 + # 1. 拉取完整 Git 历史(逻辑不变:SHA 追溯必须获取所有 commit) + - name: Checkout Code + uses: actions/checkout@v4 with: fetch-depth: 0 @@ -25,13 +32,28 @@ jobs: uses: actions/setup-python@v5 with: python-version: '3.x' - architecture: 'x64' - # 3. 安装依赖 - # 在 Windows 上 pip 命令相同,但 GitPython 在 Windows 下也能正常工作 + # 3. 核心改动:安装 requests 库,因为新脚本需要调用 GitHub API - name: Install Python dependencies - run: python -m pip install --upgrade pip requests gitpython - - # 4. 执行你的贡献统计脚本 - - name: Display involvement degree (${{ matrix.os }}) - run: python contribution_analysis.py -t ${{ secrets.GITHUB_TOKEN }} + run: | + python -m pip install --upgrade pip + pip install requests + + # 4. 执行新的统计脚本 + # 注意:增加了 -r 参数传递当前仓库名,并匹配了 workflow_dispatch 的输入 + - name: Execute SHA-based Analysis + run: | + python contribution_analysis.py \ + -t ${{ secrets.GITHUB_TOKEN }} \ + -r ${{ github.repository }} \ + --ignore "ignore_users.json" \ + --since "${{ github.event.inputs.since }}" \ + --until "${{ github.event.inputs.until }}" \ + --output "contribution_report.csv" + + # 5. 自动上传产物(确保你能在 Actions 页面直接下载 CSV) + - name: Upload Artifact + uses: actions/upload-artifact@v4 + with: + name: commit-stats-report + path: contribution_report.csv \ No newline at end of file diff --git a/contribution_analysis.py b/contribution_analysis.py index a024328b99..70c62dc70d 100644 --- a/contribution_analysis.py +++ b/contribution_analysis.py @@ -1,131 +1,80 @@ -import requests # 用于发起网络请求 -import argparse # 用于解析命令行参数 -import os # 用于操作系统级别的操作 -from collections import defaultdict, Counter # 用于数据结构操作 -import git # 用于操作Git库 - -# 设置命令行参数解析 -#通过argparse库,代码定义了一个命令行工具,允许用户通过命令行传入GitHub的访问令牌 -argparser = argparse.ArgumentParser(description='Involvement Degree') -argparser.add_argument('-t', '--token', help='your personal github access token') -args = argparser.parse_args() - -# 获取GitHub访问令牌 -TOKEN = args.token -#设置请求头包含授权信息 -# 设置请求头 -headers = { - 'Authorization': f'token {TOKEN}', - 'Accept': 'application/vnd.github.v3+json' -} - -# 仓库信息 -owner = 'OpenHUTB' # 仓库所有者 -repo = 'nn' # 仓库名称 - -######################################### -####### 统计代码添加和删除行数 ######## -######################################### -def commit_info(): - from git.repo import Repo - - # 初始化本地仓库路径 - local_path = os.path.join('.') - repo = Repo(local_path) - - # 获取提交日志,格式为作者名字 - log_info = repo.git.log('--pretty=format:%an') - authors = log_info.splitlines() - - # 定义别名映射 - alias_map = { - '刘子民': 'ziminliu', - } - - # 标准化作者名字 - normalized_authors = [alias_map.get(author, author) for author in authors] - - # 统计每个作者的提交次数 - author_counts = Counter(normalized_authors) - print("提交次数:") - for author, count in author_counts.most_common(): - print(f"{author}: {count} 次提交") - - # 获取提交日志,格式为作者名字,并包含增删行数 - log_data = repo.git.log('--pretty=format:%an', '--numstat') - - # 统计每个作者的增加行数 - author_stats = defaultdict(lambda: {'added': 0, 'deleted': 0}) - #初始化当前作者为None - current_author = None - #遍历日志的每一行 - for line in log_data.splitlines(): - #如果行中不包括制表符(\t)或者行内容为空 - if '\t' not in line or line.isdigit(): - #将当前作者设为该行内容(去除首尾空白字符) - current_author = line.strip() - elif '\t' in line: - added, deleted, _ = line.split('\t') - if added != '-': - author_stats[current_author]['added'] += int(added) - if deleted != '-': - author_stats[current_author]['deleted'] += int(deleted) - - # 输出每个作者的增加行数 - for author, stats in author_stats.items(): - print(f"{author}: 添加 {stats['added']} 行, 删除 {stats['deleted']} 行") - -commit_info() - -######################################### -####### 统计用户提问和评论数 ############## -######################################### -issue_counts = {} -comment_counts = {} - -page = 1 -while True: - url = f'https://api.github.com/repos/{owner}/{repo}/issues?state=all&per_page=100&page={page}' - response = requests.get(url, headers=headers) -#处理API响应 - if response.status_code != 200: - print("请求失败,请检查网络连接或GitHub令牌。") - break - - #将响应数据解析为JSON格式 - issues = response.json() - if not issues: - #跳出循环 - break - - #遍历所有问题 - for issue in issues: - if 'pull_request' in issue: - #跳过当前循环,继续下一个问题的处理 - continue - - #获取问题的用户登陆名 - user = issue['user']['login'] - #更新用户提出问题的计数 - issue_counts[user] = issue_counts.get(user, 0) + 1 - - comments_url = issue['comments_url'] - comments_response = requests.get(comments_url, headers=headers) - comments = comments_response.json() - - for comment in comments: - commenter = comment['user']['login'] - comment_counts[commenter] = comment_counts.get(commenter, 0) + 1 - - page += 1 - -sorted_issue_counts = dict(sorted(issue_counts.items(), key=lambda item: item[1], reverse=True)) -sorted_comment_counts = dict(sorted(comment_counts.items(), key=lambda item: item[1], reverse=True)) -#将统计结果按照次数从高到低排序并打印出来 -print("提问次数:") -for user, count in sorted_issue_counts.items(): - print(f"{user}: {count}") - -print("\n回答次数:") -for user, count in sorted_comment_counts.items(): - print(f"{user}: {count}") \ No newline at end of file +import subprocess +import argparse +import csv +import json +import os +import requests +from collections import Counter + +def get_login_by_sha(sha, repo, token, cache): + """通过 Commit SHA 获取真实的 GitHub Login ID (带缓存)""" + if sha in cache: + return cache[sha] + + url = f"https://api.github.com/repos/{repo}/commits/{sha}" + headers = {"Authorization": f"token {token}"} + try: + response = requests.get(url, headers=headers, timeout=10) + if response.status_code == 200: + data = response.json() + author_obj = data.get("author") + if author_obj: + login = author_obj.get("login") + cache[sha] = login + return login + except Exception as e: + print(f"SHA查询异常({sha}): {e}") + return None + +def load_ignore_users(file_path): + """从外部 JSON 加载屏蔽名单""" + if not os.path.exists(file_path): + return set() + try: + with open(file_path, 'r', encoding='utf-8') as f: + return {str(u).strip().lower() for u in json.load(f)} + except: + return set() + +def run_analysis(): + parser = argparse.ArgumentParser() + parser.add_argument("-t", "--token", required=True) + parser.add_argument("-r", "--repo", required=True) + parser.add_argument("--since") + parser.add_argument("--until") + parser.add_argument("--ignore", default="ignore_users.json") + parser.add_argument("--output", default="commit_stats.csv") + args = parser.parse_args() + + ignore_set = load_ignore_users(args.ignore) + + # 获取本地 Git 仓库的 Commit SHA 列表 + cmd = ["git", "log", "--pretty=%H"] + if args.since: cmd.append(f"--since={args.since}") + if args.until: cmd.append(f"--until={args.until}") + + result = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) + if result.returncode != 0: + return + + shas = [s.strip() for s in result.stdout.split('\n') if s.strip()] + login_counts = Counter() + sha_to_login_cache = {} + + print(f"检测到 {len(shas)} 个提交,正在追溯归属...") + + for sha in shas: + login = get_login_by_sha(sha, args.repo, args.token, sha_to_login_cache) + if login and login.lower() not in ignore_set: + login_counts[login] += 1 + + # 导出 + sorted_stats = sorted(login_counts.items(), key=lambda x: x[1], reverse=True) + with open(args.output, "w", newline="", encoding="utf-8") as f: + writer = csv.writer(f) + writer.writerow(["GitHub_Login", "Commits"]) + writer.writerows(sorted_stats) + print(f"分析完成,导出至 {args.output}") + +if __name__ == "__main__": + run_analysis() \ No newline at end of file diff --git a/ignore_users.json b/ignore_users.json new file mode 100644 index 0000000000..ed695fe839 --- /dev/null +++ b/ignore_users.json @@ -0,0 +1,5 @@ +[ + "Haidong Wang", + "donghaiwang", + "whd@hutb.edu.cn" +] \ No newline at end of file From e261c5d34f2c9905c5a5aca0005c81e2c57743cc Mon Sep 17 00:00:00 2001 From: "Zimin,Liu" <1115457645@qq.com> Date: Sun, 8 Mar 2026 23:40:29 +0800 Subject: [PATCH 3/4] Delete Contribution_analysis.py --- Contribution_analysis.py | 131 --------------------------------------- 1 file changed, 131 deletions(-) delete mode 100644 Contribution_analysis.py diff --git a/Contribution_analysis.py b/Contribution_analysis.py deleted file mode 100644 index a024328b99..0000000000 --- a/Contribution_analysis.py +++ /dev/null @@ -1,131 +0,0 @@ -import requests # 用于发起网络请求 -import argparse # 用于解析命令行参数 -import os # 用于操作系统级别的操作 -from collections import defaultdict, Counter # 用于数据结构操作 -import git # 用于操作Git库 - -# 设置命令行参数解析 -#通过argparse库,代码定义了一个命令行工具,允许用户通过命令行传入GitHub的访问令牌 -argparser = argparse.ArgumentParser(description='Involvement Degree') -argparser.add_argument('-t', '--token', help='your personal github access token') -args = argparser.parse_args() - -# 获取GitHub访问令牌 -TOKEN = args.token -#设置请求头包含授权信息 -# 设置请求头 -headers = { - 'Authorization': f'token {TOKEN}', - 'Accept': 'application/vnd.github.v3+json' -} - -# 仓库信息 -owner = 'OpenHUTB' # 仓库所有者 -repo = 'nn' # 仓库名称 - -######################################### -####### 统计代码添加和删除行数 ######## -######################################### -def commit_info(): - from git.repo import Repo - - # 初始化本地仓库路径 - local_path = os.path.join('.') - repo = Repo(local_path) - - # 获取提交日志,格式为作者名字 - log_info = repo.git.log('--pretty=format:%an') - authors = log_info.splitlines() - - # 定义别名映射 - alias_map = { - '刘子民': 'ziminliu', - } - - # 标准化作者名字 - normalized_authors = [alias_map.get(author, author) for author in authors] - - # 统计每个作者的提交次数 - author_counts = Counter(normalized_authors) - print("提交次数:") - for author, count in author_counts.most_common(): - print(f"{author}: {count} 次提交") - - # 获取提交日志,格式为作者名字,并包含增删行数 - log_data = repo.git.log('--pretty=format:%an', '--numstat') - - # 统计每个作者的增加行数 - author_stats = defaultdict(lambda: {'added': 0, 'deleted': 0}) - #初始化当前作者为None - current_author = None - #遍历日志的每一行 - for line in log_data.splitlines(): - #如果行中不包括制表符(\t)或者行内容为空 - if '\t' not in line or line.isdigit(): - #将当前作者设为该行内容(去除首尾空白字符) - current_author = line.strip() - elif '\t' in line: - added, deleted, _ = line.split('\t') - if added != '-': - author_stats[current_author]['added'] += int(added) - if deleted != '-': - author_stats[current_author]['deleted'] += int(deleted) - - # 输出每个作者的增加行数 - for author, stats in author_stats.items(): - print(f"{author}: 添加 {stats['added']} 行, 删除 {stats['deleted']} 行") - -commit_info() - -######################################### -####### 统计用户提问和评论数 ############## -######################################### -issue_counts = {} -comment_counts = {} - -page = 1 -while True: - url = f'https://api.github.com/repos/{owner}/{repo}/issues?state=all&per_page=100&page={page}' - response = requests.get(url, headers=headers) -#处理API响应 - if response.status_code != 200: - print("请求失败,请检查网络连接或GitHub令牌。") - break - - #将响应数据解析为JSON格式 - issues = response.json() - if not issues: - #跳出循环 - break - - #遍历所有问题 - for issue in issues: - if 'pull_request' in issue: - #跳过当前循环,继续下一个问题的处理 - continue - - #获取问题的用户登陆名 - user = issue['user']['login'] - #更新用户提出问题的计数 - issue_counts[user] = issue_counts.get(user, 0) + 1 - - comments_url = issue['comments_url'] - comments_response = requests.get(comments_url, headers=headers) - comments = comments_response.json() - - for comment in comments: - commenter = comment['user']['login'] - comment_counts[commenter] = comment_counts.get(commenter, 0) + 1 - - page += 1 - -sorted_issue_counts = dict(sorted(issue_counts.items(), key=lambda item: item[1], reverse=True)) -sorted_comment_counts = dict(sorted(comment_counts.items(), key=lambda item: item[1], reverse=True)) -#将统计结果按照次数从高到低排序并打印出来 -print("提问次数:") -for user, count in sorted_issue_counts.items(): - print(f"{user}: {count}") - -print("\n回答次数:") -for user, count in sorted_comment_counts.items(): - print(f"{user}: {count}") \ No newline at end of file From 92deaf28ad68d6e640f5eb102a58fba7b0cc4924 Mon Sep 17 00:00:00 2001 From: qq1115457645 <1115457645@qq.com> Date: Thu, 19 Mar 2026 16:17:49 +0800 Subject: [PATCH 4/4] first commit to readme --- .../README.md | 140 ++++++++++++++++++ .../requirements.txt | 3 + 2 files changed, 143 insertions(+) create mode 100644 src/Vehicle_Object_Detection_Simulation/README.md create mode 100644 src/Vehicle_Object_Detection_Simulation/requirements.txt diff --git a/src/Vehicle_Object_Detection_Simulation/README.md b/src/Vehicle_Object_Detection_Simulation/README.md new file mode 100644 index 0000000000..f475919a0a --- /dev/null +++ b/src/Vehicle_Object_Detection_Simulation/README.md @@ -0,0 +1,140 @@ +# 车辆物体检测仿真 + +## 项目简介 + +这是一个基于MuJoCo物理引擎的小车物体检测仿真项目。该项目模拟了一辆小车在环境中行驶,并使用LiDAR传感器检测周围物体的功能。 + +## 功能特性 + +1. **物理仿真**:基于MuJoCo的真实物理仿真,提供精确的物理规律模拟 +2. **小车模型**:包含底盘、车厢和四个圆柱形轮子的更真实小车模型 +3. **键盘控制**:支持通过键盘方向键控制小车移动方向 +4. **传感器模拟**:LiDAR传感器点云数据生成,模拟真实激光雷达工作原理 +5. **物体检测**:检测环境中的障碍物并进行标注 +6. **数据保存**:保存点云数据和检测结果,便于后续分析 +7. **温度监控**:模拟车内温度变化并可视化,包括热源影响分析 +8. **智能空调系统**:根据温度自动开启/关闭空调调节温度,维持舒适环境 +9. **温度调节可视化**:生成多种温度调节相关图表,直观展示温控效果 +10. **故障自检系统**:实时监测传感器和执行器状态,预防系统故障 +11. **故障记录与可视化**:自动生成故障报告和趋势图,便于诊断维护 + +## 环境要求 + +- Python 3.7+ +- mujoco +- numpy +- pygame +- windows 10+ + +``` +pip install -r requirements.txt +``` + +## 项目结构 + +``` +minicarsim/ +├── main.py # 主程序 +├── README.md # 说明文档 +├── models/ + └── simple_car.xml # 小车和环境模型 +``` + +## 快速开始 +**1.运行仿真:** +```bash +cd src/minicarsim +python main.py +``` + +2. 观察可视化窗口中的仿真过程 + +3. 如需手动控制小车,请使用方向键: + - 上键:前进 + - 下键:后退 + - 左键:左转 + - 右键:右转 + + 控制界面会显示按键说明和当前控制状态(手动控制或自动避障) + +## 代码说明 + +### 主要类和方法 + +- `MojocoDataSim`: 主要的仿真类 + - `generate_realistic_lidar_data()`: 生成真实的LiDAR点云数据 + - `detect_objects()`: 检测环境中的物体 + - `simulate_temperature_data()`: 模拟车内温度变化 + - `check_and_control_ac()`: 检查并控制空调开关 + - `handle_keyboard_input()`: 处理键盘输入控制 + - `run_simulation()`: 运行仿真主循环 + - `visualize_ac_control()`: 生成空调控制状态图 + - `generate_temperature_trend()`: 生成温度变化趋势图 + - `generate_temperature_summary_chart()`: 生成温度调节汇总图 + - `generate_fault_report()`: 生成故障报告 + - `visualize_fault_status()`: 生成故障状态图 + - `generate_health_trend()`: 生成健康趋势图 + +- `FaultMonitor`: 故障监测类 + - `check_system_health()`: 检查系统整体健康状态 + - `_check_sensor_health()`: 检查传感器健康状态 + - `_check_actuator_health()`: 检查执行器健康状态 + +### 配置参数 + +在`main.py`中可以调整的主要参数: + +- `LIDAR_PARAMS`: LiDAR传感器参数 +- `TEMPERATURE_PARAMS`: 温度监控参数 +- `FAULT_MONITORING_PARAMS`: 故障监测参数 +- `SIMULATION_FRAMES`: 仿真总帧数 + +## 模型说明 + +### simple_car.xml + +该文件定义了: +- 地面平面 +- 小车模型(底盘、车厢和四个圆柱形轮子) +- 5个彩色障碍物 +- 传感器安装位置(LiDAR和摄像头) + +## 数据输出 + +仿真运行后会产生四类数据: + +1. **LiDAR点云数据**:保存为`.npy`格式的NumPy数组 +2. **物体检测标注**:保存为`.json`格式的标注文件 +3. **温度调节可视化图表**: + - 温度变化趋势图 (`temperature_trend.png`) + - 温度调节汇总图 (`temperature_summary.png`) + - 空调控制状态图 (`ac_control_XXXX.png`) + - 环境温度分布图 (`thermal_map_XXXX.png`) +4. **故障监测报告**: + - 故障详细报告 (`frame_XXXX.json`) + - 故障状态图 (`fault_status_XXXX.png`) + - 系统健康趋势图 (`health_trend.png`) + +## 扩展建议 + +1. 添加更多类型的传感器(如摄像头) +2. 实现更复杂的物体检测算法 +3. 添加不同的环境地图 +4. 实现自主导航功能 +5. 添加更多的车辆控制方式 +6. 增强空调控制算法(PID控制等) +7. 增加更多类型的故障检测(如通信故障、电源故障等) + +## 故障排除 + +### 常见问题 + +1. **找不到模型文件**:检查`XML_PATH`是否正确 +2. **无法显示可视化窗口**:确保已正确安装MuJoCo +3. **没有检测到物体**:检查小车与物体之间的距离 +4. **温度调节效果不明显**:检查空调功率系数和舒适温度范围设置 +5. **没有生成故障报告**:检查故障检测阈值设置 + +### 支持 + +如有问题,请提交issue或联系项目维护者。 \ No newline at end of file diff --git a/src/Vehicle_Object_Detection_Simulation/requirements.txt b/src/Vehicle_Object_Detection_Simulation/requirements.txt new file mode 100644 index 0000000000..71d723a71b --- /dev/null +++ b/src/Vehicle_Object_Detection_Simulation/requirements.txt @@ -0,0 +1,3 @@ +mujoco +numpy +pygame \ No newline at end of file