unity2moveit2/scripts/verify-refactoring.ps1
ayuan9957 fe15edcbd5 Initial commit: Unity-MoveIt2 integrated robotic arm simulation system
- Unity frontend with ROS-TCP-Connector for ROS2 communication
- Docker-based ROS2 Jazzy backend with MoveIt2 integration
- Support for 1-9 DOF manipulators
- UR5 robot configuration and URDF files
- Assembly task feasibility analysis tools
- Comprehensive documentation and deployment guides

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-13 12:08:34 +08:00

147 lines
5.7 KiB
PowerShell
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Unity 代码重构验证脚本
# Verify Unity Code Refactoring
param(
[string]$UnityPath = "C:\Program Files\Unity\Hub\Editor\2022.3.57f1c2\Editor\Unity.exe",
[string]$ProjectPath = "$PSScriptRoot\..\unity-project",
[switch]$OpenEditor = $false
)
Write-Host "=====================================" -ForegroundColor Cyan
Write-Host "Unity 代码重构验证脚本" -ForegroundColor Cyan
Write-Host "Unity Code Refactoring Verification" -ForegroundColor Cyan
Write-Host "=====================================" -ForegroundColor Cyan
Write-Host ""
# 检查 Unity 是否存在
if (-not (Test-Path $UnityPath)) {
Write-Host "❌ 未找到 Unity Editor: $UnityPath" -ForegroundColor Red
Write-Host "请在 Unity Hub 中安装 Unity 2022.3.57f1c2 或修改脚本中的路径" -ForegroundColor Yellow
exit 1
}
# 检查项目路径
if (-not (Test-Path $ProjectPath)) {
Write-Host "❌ 未找到 Unity 项目: $ProjectPath" -ForegroundColor Red
exit 1
}
Write-Host "✓ Unity Editor: $UnityPath" -ForegroundColor Green
Write-Host "✓ 项目路径: $ProjectPath" -ForegroundColor Green
Write-Host ""
# 显示重构摘要
Write-Host "=== 重构内容摘要 ===" -ForegroundColor Yellow
Write-Host ""
Write-Host "已修复的文件:" -ForegroundColor White
Write-Host " 1. MessageConverter.cs - 类型转换和坐标系统" -ForegroundColor Gray
Write-Host " 2. ROSTCPBridge.cs - ROS 消息注册和订阅" -ForegroundColor Gray
Write-Host " 3. RobotControlInterface.cs - 坐标转换调用" -ForegroundColor Gray
Write-Host " 4. ROSMessageTypes.cs - ROSClock 条件编译" -ForegroundColor Gray
Write-Host ""
Write-Host "新增的文件:" -ForegroundColor White
Write-Host " 1. TypeConversionHelper.cs - 类型转换工具类" -ForegroundColor Gray
Write-Host " 2. AI_NAVIGATION_FIX.md - AI Navigation 修复指南" -ForegroundColor Gray
Write-Host " 3. REFACTORING_SUMMARY.md - 完整重构文档" -ForegroundColor Gray
Write-Host ""
# 检查修复的关键文件是否存在
$criticalFiles = @(
"$ProjectPath\Assets\Scripts\Communication\MessageConverter.cs",
"$ProjectPath\Assets\Scripts\Communication\ROSTCPBridge.cs",
"$ProjectPath\Assets\Scripts\Communication\RobotControlInterface.cs",
"$ProjectPath\Assets\Scripts\Communication\ROSMessageTypes.cs",
"$ProjectPath\Assets\Scripts\Communication\TypeConversionHelper.cs"
)
Write-Host "=== 检查关键文件 ===" -ForegroundColor Yellow
Write-Host ""
$allFilesExist = $true
foreach ($file in $criticalFiles) {
if (Test-Path $file) {
$fileName = Split-Path $file -Leaf
Write-Host "$fileName" -ForegroundColor Green
} else {
$fileName = Split-Path $file -Leaf
Write-Host "$fileName (缺失)" -ForegroundColor Red
$allFilesExist = $false
}
}
Write-Host ""
if (-not $allFilesExist) {
Write-Host "❌ 部分关键文件缺失,请检查重构是否完整" -ForegroundColor Red
exit 1
}
# 检查 bug.txt 中的错误
Write-Host "=== 检查已知错误列表 ===" -ForegroundColor Yellow
Write-Host ""
$bugFile = "$ProjectPath\Assets\Scripts\bug.txt"
if (Test-Path $bugFile) {
$bugContent = Get-Content $bugFile -Raw
$errorCount = ([regex]::Matches($bugContent, "error CS")).Count
Write-Host "bug.txt 中记录了 $errorCount 个错误" -ForegroundColor Yellow
Write-Host ""
Write-Host "注意: 这是旧的错误记录,大部分已修复" -ForegroundColor Cyan
Write-Host "剩余的主要是 AI Navigation 包问题4个错误" -ForegroundColor Cyan
Write-Host ""
}
# 提供下一步操作指导
Write-Host "=== 下一步操作 ===" -ForegroundColor Yellow
Write-Host ""
Write-Host "1. 修复 AI Navigation 包问题:" -ForegroundColor White
Write-Host " - 打开 Unity Editor" -ForegroundColor Gray
Write-Host " - Window → Package Manager" -ForegroundColor Gray
Write-Host " - 找到 'AI Navigation' 并升级到 2.0.0+" -ForegroundColor Gray
Write-Host " - 或者直接移除该包(不影响机器人功能)" -ForegroundColor Gray
Write-Host ""
Write-Host "2. 验证编译:" -ForegroundColor White
Write-Host " - 等待 Unity 自动编译完成" -ForegroundColor Gray
Write-Host " - 检查 Console 面板无错误" -ForegroundColor Gray
Write-Host ""
Write-Host "3. 测试 ROS 连接:" -ForegroundColor White
Write-Host " - cd docker" -ForegroundColor Gray
Write-Host " - docker-compose up -d" -ForegroundColor Gray
Write-Host " - 在 Unity 中运行场景" -ForegroundColor Gray
Write-Host ""
# 询问是否打开 Unity Editor
if ($OpenEditor) {
Write-Host "正在打开 Unity Editor..." -ForegroundColor Cyan
Write-Host ""
$projectPathAbsolute = Resolve-Path $ProjectPath
# 启动 Unity Editor
Start-Process -FilePath $UnityPath -ArgumentList "-projectPath `"$projectPathAbsolute`""
Write-Host "✓ Unity Editor 已启动" -ForegroundColor Green
Write-Host ""
Write-Host "请在 Unity Console 中查看编译结果" -ForegroundColor Yellow
} else {
Write-Host "提示: 使用 -OpenEditor 参数可自动打开 Unity" -ForegroundColor Cyan
Write-Host "示例: .\verify-refactoring.ps1 -OpenEditor" -ForegroundColor Gray
Write-Host ""
}
Write-Host "=== 重要文档 ===" -ForegroundColor Yellow
Write-Host ""
Write-Host "查看完整重构详情:" -ForegroundColor White
Write-Host " - REFACTORING_SUMMARY.md - 详细的重构总结" -ForegroundColor Gray
Write-Host " - AI_NAVIGATION_FIX.md - AI Navigation 修复方案" -ForegroundColor Gray
Write-Host ""
Write-Host "=====================================" -ForegroundColor Cyan
Write-Host "验证脚本执行完成" -ForegroundColor Cyan
Write-Host "=====================================" -ForegroundColor Cyan
Write-Host ""
# 返回成功
exit 0