RoboticArmTest/CLAUDE.md
sladro a9e936bc43 Initial project structure for robotic arm feasibility test
- 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 <noreply@anthropic.com>
2025-09-10 11:45:20 +08:00

114 lines
4.0 KiB
Markdown
Raw 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.

# 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轴旋转
### 坐标系统
- 位置定义:`<origin xyz="x y z" rpy="roll pitch yaw"/>`
- 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点位置调整应影响路径规划结果