From a9e936bc43fb6c7741f08d3a32f66da8d9e34a34 Mon Sep 17 00:00:00 2001 From: sladro Date: Wed, 10 Sep 2025 11:45:20 +0800 Subject: [PATCH] Initial project structure for robotic arm feasibility test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Added project configuration (config.json) with robot model path, environment parameters - Created 9-DOF robotic arm URDF model (models/manual_robot.urdf) - Established modular code architecture with empty source files ready for implementation - Configured Python dependencies (pybullet, PyKDL, urdf_parser_py) - Added comprehensive project documentation (CLAUDE.md) - Created .gitignore for Python project 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .claude/settings.local.json | 9 + .gitignore | 63 ++++ CLAUDE.md | 114 ++++++++ Readme.md | 9 + config.json | 61 ++++ models/manual_robot.urdf | 507 +++++++++++++++++++++++++++++++++ requirements.txt | 6 + src/__init__.py | 0 src/config_loader.py | 0 src/main.py | 0 src/planning/__init__.py | 0 src/planning/path_optimizer.py | 0 src/planning/rrt_star.py | 0 src/robot/__init__.py | 0 src/robot/arm_controller.py | 0 src/robot/kinematics.py | 0 src/simulation/__init__.py | 0 src/simulation/environment.py | 0 src/simulation/simulator.py | 0 src/utils/__init__.py | 0 src/utils/constants.py | 0 src/utils/validators.py | 0 22 files changed, 769 insertions(+) create mode 100644 .claude/settings.local.json create mode 100644 .gitignore create mode 100644 CLAUDE.md create mode 100644 Readme.md create mode 100644 config.json create mode 100644 models/manual_robot.urdf create mode 100644 requirements.txt create mode 100644 src/__init__.py create mode 100644 src/config_loader.py create mode 100644 src/main.py create mode 100644 src/planning/__init__.py create mode 100644 src/planning/path_optimizer.py create mode 100644 src/planning/rrt_star.py create mode 100644 src/robot/__init__.py create mode 100644 src/robot/arm_controller.py create mode 100644 src/robot/kinematics.py create mode 100644 src/simulation/__init__.py create mode 100644 src/simulation/environment.py create mode 100644 src/simulation/simulator.py create mode 100644 src/utils/__init__.py create mode 100644 src/utils/constants.py create mode 100644 src/utils/validators.py diff --git a/.claude/settings.local.json b/.claude/settings.local.json new file mode 100644 index 0000000..b2bc9f8 --- /dev/null +++ b/.claude/settings.local.json @@ -0,0 +1,9 @@ +{ + "permissions": { + "allow": [ + "Bash(git init:*)" + ], + "deny": [], + "ask": [] + } +} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..45c882a --- /dev/null +++ b/.gitignore @@ -0,0 +1,63 @@ +# Python +__pycache__/ +*.py[cod] +*$py.class +*.so +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# Virtual environments +venv/ +env/ +ENV/ +.venv/ +.env/ + +# IDEs +.vscode/ +.idea/ +*.swp +*.swo +*~ + +# Jupyter Notebook +.ipynb_checkpoints + +# PyCharm +.idea/ + +# OS generated files +.DS_Store +.DS_Store? +._* +.Spotlight-V100 +.Trashes +ehthumbs.db +Thumbs.db + +# PyBullet logs +*.log + +# Simulation outputs +simulation_output/ +results/ +logs/ + +# Temporary files +*.tmp +*.temp \ No newline at end of file diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..1262f37 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,114 @@ +# CLAUDE.md + +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. + +## 项目概述 + +这是一个机械臂运作可行性测试项目,用于测试机械臂从指定基座位置到达指定位置A点,运送物体穿越障碍(一般是墙体上的洞口或其他障碍)到达指定点位B的可行性。 + +## 技术栈 + +- **pybullet**: 物理仿真引擎 +- **kdl**: 运动学/动力学库 +- **AI RRT***: 路径规划算法 + +## 配置管理原则 + +**所有配置参数必须从 `config.json` 文件读取,严禁硬编码:** +- 机械臂模型路径必须从 `config.robot.model_path` 读取 +- 墙体参数从 `config.wall` 读取 +- 洞口参数从 `config.hole` 读取 +- 任务点A、B从 `config.task_points` 读取 +- 运送物体参数从 `config.transport_object` 读取 +- 仿真参数从 `config.simulation` 读取 +- 修改任何参数只需修改配置文件,无需改动代码 + +## 项目架构 + +### 目录结构 +- `config.json`: **核心配置文件**,包含所有运行参数 +- `models/`: 机械臂模型文件目录 + - `manual_robot.urdf`: 9自由度机械臂URDF配置文件 +- `CLAUDE.md`: 项目开发指南 + +### 机械臂模型规范 +- 使用URDF格式定义机械臂模型 +- 遵循右手坐标系统:X轴(红色)、Y轴(绿色)、Z轴(蓝色) +- 关节轴向定义: + - `xyz="1 0 0"`: 绕X轴旋转 + - `xyz="0 1 0"`: 绕Y轴旋转 + - `xyz="0 0 1"`: 绕Z轴旋转 + +### 坐标系统 +- 位置定义:`` +- xyz: 位置偏移(米) +- rpy: 旋转角度(弧度) - roll绕X轴,pitch绕Y轴,yaw绕Z轴 + +## 开发指导 + +### 核心功能模块 +1. **机械臂控制模块**: 基于pybullet的仿真控制 +2. **路径规划模块**: 使用RRT*算法进行避障路径规划 +3. **运动学计算模块**: 使用kdl进行正逆运动学计算 +4. **障碍物检测模块**: 碰撞检测和环境感知 + +## 业务流程(严格按此顺序执行) + +### 1. 系统初始化 +1. **读取配置文件**: 从 `config.json` 加载所有配置参数 +2. **验证配置**: 检查所有必要参数是否存在且有效 +3. **初始化pybullet仿真环境**: 使用 `config.simulation` 参数 + +### 2. 环境构建 +1. **加载机械臂**: 使用 `config.robot.model_path` 指定的URDF文件 +2. **设置机械臂基座**: 使用 `config.robot.base_position` 和 `base_orientation` +3. **创建墙体障碍**: 根据 `config.wall` 参数创建墙体 +4. **创建洞口**: 在墙体中根据 `config.hole` 参数创建洞口 +5. **放置运送物体**: 在 `config.transport_object.initial_position` 放置物体 + +### 3. 任务执行 +1. **路径规划阶段1**: 机械臂基座 → A点(取物点) +2. **抓取物体**: 在A点抓取运送物体 +3. **路径规划阶段2**: A点 → 穿越洞口 → B点(避障路径规划) +4. **运送物体**: 携带物体穿越障碍到达B点 +5. **释放物体**: 在B点释放物体 + +### 4. 关键约束 +- **配置驱动**: 所有参数必须从config.json读取 +- **避障要求**: 机械臂和物体不能与墙体碰撞,只能通过洞口 +- **路径平滑**: 使用RRT*算法确保路径可行且平滑 +- **运动学约束**: 遵循机械臂的运动学限制 + +## 开发规范 + +### 配置文件使用规范 +```python +# 正确的配置读取方式 +import json + +# 1. 必须首先读取配置文件 +with open('config.json', 'r') as f: + config = json.load(f) + +# 2. 从配置读取机械臂模型路径 +robot_model_path = config['robot']['model_path'] + +# 3. 从配置读取所有其他参数 +wall_params = config['wall'] +hole_params = config['hole'] +task_points = config['task_points'] +transport_object = config['transport_object'] +``` + +### 严禁的做法 +```python +# ❌ 严禁硬编码路径和参数 +robot_model = "models/manual_robot.urdf" # 错误! +wall_position = [2.0, 0.0, 1.0] # 错误! +``` + +### 测试验证 +- 配置文件修改后,程序行为应相应改变 +- 不同的机械臂模型应能正确加载 +- 墙体和洞口参数变化应反映在仿真中 +- A、B点位置调整应影响路径规划结果 \ No newline at end of file diff --git a/Readme.md b/Readme.md new file mode 100644 index 0000000..99778d6 --- /dev/null +++ b/Readme.md @@ -0,0 +1,9 @@ +## 机械臂运作可行性测试 + +本项目是测试机械臂进行工作的可行性,应用于现实中的工程测试。测试内容是机械臂从指定基座位置到达指定位置A点,运送物体穿越障碍(一般是墙体上的洞口或者其它障碍)到达指定点位B的可行性 + +### 技术选择 + +- pybullet +- kdl +- AI RRT* \ No newline at end of file diff --git a/config.json b/config.json new file mode 100644 index 0000000..dfa526f --- /dev/null +++ b/config.json @@ -0,0 +1,61 @@ +{ + "robot": { + "model_path": "models/manual_robot.urdf", + "base_position": [0.0, 0.0, 0.0], + "base_orientation": [0.0, 0.0, 0.0] + }, + + "wall": { + "position": [2.0, 0.0, 1.0], + "dimensions": { + "width": 3.0, + "height": 2.5, + "thickness": 0.2 + }, + "material": { + "color": [0.8, 0.8, 0.8, 1.0], + "type": "concrete" + } + }, + + "hole": { + "position_relative_to_wall": [0.0, 0.0, 0.0], + "dimensions": { + "width": 0.6, + "height": 0.6 + }, + "shape": "rectangle" + }, + + "task_points": { + "point_A": { + "position": [1.0, 0.5, 0.8], + "description": "取物点,与机械臂同侧" + }, + "point_B": { + "position": [3.0, 0.5, 0.8], + "description": "目标点,墙体另一侧" + } + }, + + "transport_object": { + "initial_position": [1.0, 0.5, 0.5], + "dimensions": { + "width": 0.1, + "height": 0.1, + "depth": 0.1 + }, + "mass": 0.5, + "shape": "cube", + "material": { + "color": [1.0, 0.0, 0.0, 1.0], + "friction": 0.7 + } + }, + + "simulation": { + "timestep": 0.01, + "gravity": [0.0, 0.0, -9.81], + "real_time": false + } +} \ No newline at end of file diff --git a/models/manual_robot.urdf b/models/manual_robot.urdf new file mode 100644 index 0000000..5e7126a --- /dev/null +++ b/models/manual_robot.urdf @@ -0,0 +1,507 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..1ea9b00 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,6 @@ +pybullet>=3.2.5 +PyKDL>=1.5.1 +urdf_parser_py>=0.0.4 +numpy>=1.21.0 +scipy>=1.7.0 +matplotlib>=3.5.0 \ No newline at end of file diff --git a/src/__init__.py b/src/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/config_loader.py b/src/config_loader.py new file mode 100644 index 0000000..e69de29 diff --git a/src/main.py b/src/main.py new file mode 100644 index 0000000..e69de29 diff --git a/src/planning/__init__.py b/src/planning/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/planning/path_optimizer.py b/src/planning/path_optimizer.py new file mode 100644 index 0000000..e69de29 diff --git a/src/planning/rrt_star.py b/src/planning/rrt_star.py new file mode 100644 index 0000000..e69de29 diff --git a/src/robot/__init__.py b/src/robot/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/robot/arm_controller.py b/src/robot/arm_controller.py new file mode 100644 index 0000000..e69de29 diff --git a/src/robot/kinematics.py b/src/robot/kinematics.py new file mode 100644 index 0000000..e69de29 diff --git a/src/simulation/__init__.py b/src/simulation/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/simulation/environment.py b/src/simulation/environment.py new file mode 100644 index 0000000..e69de29 diff --git a/src/simulation/simulator.py b/src/simulation/simulator.py new file mode 100644 index 0000000..e69de29 diff --git a/src/utils/__init__.py b/src/utils/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/utils/constants.py b/src/utils/constants.py new file mode 100644 index 0000000..e69de29 diff --git a/src/utils/validators.py b/src/utils/validators.py new file mode 100644 index 0000000..e69de29