unity2moveit2/unity-project
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
..
Assets Initial commit: Unity-MoveIt2 integrated robotic arm simulation system 2025-10-13 12:08:34 +08:00
Packages Initial commit: Unity-MoveIt2 integrated robotic arm simulation system 2025-10-13 12:08:34 +08:00
ProjectSettings Initial commit: Unity-MoveIt2 integrated robotic arm simulation system 2025-10-13 12:08:34 +08:00
PROJECT_STRUCTURE.txt Initial commit: Unity-MoveIt2 integrated robotic arm simulation system 2025-10-13 12:08:34 +08:00
README.md Initial commit: Unity-MoveIt2 integrated robotic arm simulation system 2025-10-13 12:08:34 +08:00

Unity-MoveIt2 通用机械臂仿真系统

Universal Manipulator Simulation System

版本 / Version: 1.0.0 Unity版本 / Unity Version: 2022.3.57f1c2 LTS


🎯 项目简介 / Project Overview

这是一个基于Unity和MoveIt2的1-9自由度通用机械臂交互式仿真系统,专为有限空间装配任务可行性分析设计。

核心特性 / Core Features:

  • 🔧 通用性: 支持1-9自由度任意机械臂配置
  • 🎮 交互性: Unity 6DOF拖拽操作,实时末端控制
  • 🧠 智能性: MoveIt2路径规划,碰撞检测与避障
  • 📊 可视化: 实时轨迹显示,碰撞热图,状态监控
  • 🏭 装配仿真: 有限空间装配可行性分析与环境影响评估

📁 项目结构 / Project Structure

unity-project/
├── Assets/
│   ├── Scripts/                    # 脚本文件
│   │   ├── Core/                   # ✅ 核心模块(已完成)
│   │   ├── Communication/          # ⏳ 通信层(待实现)
│   │   ├── Managers/               # ⏳ 管理器层(待实现)
│   │   ├── Assembly/               # ⏳ 装配仿真(待实现)
│   │   ├── Tests/                  # ⏳ 测试用例(待扩展)
│   │   └── RosMessages/            # ROS消息类型
│   ├── Scenes/                     # Unity场景
│   ├── Prefabs/                    # 预制件资源
│   ├── Materials/                  # 材质资源
│   ├── Resources/                  # 运行时资源
│   └── StreamingAssets/Config/     # 配置文件
├── Packages/                       # Unity包管理
└── ProjectSettings/                # Unity项目设置

已完成功能 / Completed Features

1. UniversalRobotAdapter (核心适配器)

  • 1-9自由度动态适配
  • 自动关节发现和配置
  • 关节位置/速度控制
  • 正运动学(FK)计算
  • 关节限制验证
  • URDF配置导入/导出

2. InteractiveEndEffectorController (交互控制)

  • 6DOF末端执行器拖拽
  • 位置拖拽(左键)
  • 旋转拖拽(右键+Ctrl)
  • 工作空间约束
  • 网格吸附功能
  • 实时视觉反馈
  • 键盘快捷键控制

3. VisualizationEngine (可视化引擎)

  • 轨迹可视化与动画
  • 路径点标记
  • 可配置更新频率
  • LOD优化支持
  • 碰撞可视化(待实现)
  • 关节状态显示(待实现)
  • 工作空间显示(待实现)

🚀 快速开始 / Quick Start

步骤1: 打开项目

  1. 安装 Unity HubUnity 2022.3 LTS
  2. Unity Hub → Add → 选择此 unity-project 目录
  3. 等待Unity导入和编译完成

步骤2: 安装ROS包

通过Unity Package Manager安装:

Window → Package Manager → + → Add package from git URL

添加以下包:

  • https://github.com/Unity-Technologies/ROS-TCP-Connector.git?path=/com.unity.robotics.ros-tcp-connector
  • https://github.com/Unity-Technologies/URDF-Importer.git?path=/com.unity.robotics.urdf-importer

步骤3: 启动ROS2后端

cd ../docker
docker-compose up -d

步骤4: 配置机器人

  1. 创建空GameObject,命名为 RobotSystem
  2. 添加组件:
    • UniversalRobotAdapter
    • InteractiveEndEffectorController
    • VisualizationEngine
  3. 使用URDF Importer导入机器人模型
  4. 在Inspector中配置Base Link和End Effector引用

📖 使用示例 / Usage Examples

示例1: 控制关节

using UnityMoveIt2.Core;

public class ControlExample : MonoBehaviour
{
    public UniversalRobotAdapter robot;

    void Update()
    {
        // 设置关节位置(弧度)
        float[] positions = new float[6] {0, -0.5f, 1.0f, 0, 0.5f, 0};
        robot.SetJointPositions(positions);

        // 获取末端位姿
        Pose ee = robot.GetEndEffectorPose();
        Debug.Log($"末端位置: {ee.position}");
    }
}

示例2: 交互式拖拽

using UnityMoveIt2.Core;

public class InteractionExample : MonoBehaviour
{
    public InteractiveEndEffectorController controller;

    void Start()
    {
        // 订阅目标位姿变更事件
        controller.OnTargetPoseChanged += (pos, rot) => {
            Debug.Log($"新目标: {pos}");
            // 请求IK解算...
        };
    }
}

示例3: 可视化轨迹

using System.Collections.Generic;
using UnityMoveIt2.Core;

public class VisualizationExample : MonoBehaviour
{
    public VisualizationEngine visualizer;

    void Start()
    {
        List<Pose> trajectory = CreateTestTrajectory();
        visualizer.VisualizeTrajectory(trajectory);
    }
}

🎮 操作说明 / Controls

鼠标操作 / Mouse Controls

  • 左键拖拽 - 移动末端执行器位置
  • 右键拖拽 - 旋转末端执行器姿态
  • Ctrl + 右键拖拽 - Roll轴旋转
  • 滚轮 - 缩放视图

键盘快捷键 / Keyboard Shortcuts

  • ↑↓←→ - 微调末端位置
  • PageUp/PageDown - 垂直微调
  • Shift + 方向键 - 高精度微调(0.1x)
  • R - 重置到当前位姿

待实现功能 / Pending Features

高优先级 / High Priority

  1. Communication Layer - ROS2通信层

    • ROSTCPBridge.cs
    • MessageConverter.cs
    • ServiceManager.cs
  2. Manager Layer - 管理器层

    • RobotManager.cs
    • SceneManager.cs
    • UIManager.cs
  3. 完整可视化 - Complete Visualization

    • 碰撞检测可视化
    • 关节状态显示
    • 工作空间边界

中等优先级 / Medium Priority

  1. Assembly Simulation - 装配仿真模块

    • FeasibilityAnalyzer.cs
    • EnvironmentEditor.cs
    • WorkspaceOptimizer.cs
  2. Unity Scenes - Unity场景

    • MainScene.unity
    • TestScene.unity
    • AssemblySimulation.unity

低优先级 / Low Priority

  1. 测试用例扩展 - Test Case Expansion
  2. 性能优化 - Performance Optimization
  3. 文档完善 - Documentation Enhancement

📊 开发进度 / Development Progress

模块 / Module 完成度 / Progress 状态 / Status
基础架构 ████████████ 100% 完成
Core模块 ████████████ 90% 基本完成
Communication ░░░░░░░░░░░░ 0% 待开发
Managers ░░░░░░░░░░░░ 0% 待开发
Assembly ░░░░░░░░░░░░ 0% 待开发
Tests ░░░░░░░░░░░░ 0% 待扩展
整体 ███░░░░░░░░░ 30% 进行中

🐛 常见问题 / Troubleshooting

Q1: Assembly Definition引用错误

A: 打开.asmdef文件,手动添加引用GUID,然后 Assets → Reimport All

Q2: 关节不响应控制命令

A: 检查ArticulationBody的xDrive配置和关节限制设置

Q3: ROS连接失败

A:

  1. 检查Docker容器状态: docker-compose ps
  2. 验证端口10000是否开放
  3. 检查防火墙设置


📞 技术支持 / Technical Support


📄 许可证 / License

MIT License


🎉 欢迎使用Unity-MoveIt2通用机械臂仿真系统

🎉 Welcome to Unity-MoveIt2 Universal Manipulator Simulation System!


最后更新 / Last Updated: 2025-01-27