diff --git a/CLAUDE.md b/CLAUDE.md index 8cdd885..e7671d4 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -176,4 +176,25 @@ wall_position = [2.0, 0.0, 1.0] # 错误! - 修复 `cleanup()` 函数调用 `_clear_wall()` - 使用 `_wall_part_ids` 列表记录所有墙体部件ID -**修复文件**:`src/simulation/environment.py` \ No newline at end of file +**修复文件**:`src/simulation/environment.py` + +### 代码重复和一致性问题(2025-09-12)✅ 已解决 +**现象**: +1. `path_executor.py` 中存在未使用的重复方法 `_move_to_configuration_reset()` +2. 空文件 `rrt_star.py` 增加项目混乱度 +3. 需要验证KDL和PyBullet关节顺序转换的一致性 + +**根本原因**: +1. **代码重复**:两个功能相同的路径执行方法,违反DRY原则 +2. **遗留文件**:空的 `rrt_star.py` 文件未清理 +3. **架构复杂性**:需要确保关节顺序映射在所有地方正确使用 + +**解决方案**: +- 删除未使用的 `_move_to_configuration_reset()` 方法 +- 删除空的 `rrt_star.py` 文件 +- 验证确认关节顺序转换机制在全项目中使用一致 + +**修复文件**: +- `src/planning/path_executor.py` - 删除重复方法 +- `src/planning/rrt_star.py` - 删除空文件 +- 全项目关节顺序转换验证通过 \ No newline at end of file diff --git a/src/planning/path_executor.py b/src/planning/path_executor.py index 9ef550d..fabd797 100644 --- a/src/planning/path_executor.py +++ b/src/planning/path_executor.py @@ -157,35 +157,3 @@ class PathExecutor: return True - def _move_to_configuration_reset(self, target_config: List[float]) -> bool: - - current_config = self.arm_controller.get_current_joint_positions() - - distance = np.linalg.norm(np.array(target_config) - np.array(current_config)) - if distance < self.position_tolerance: - return True - - move_time = distance / self.velocity_scaling - num_steps = int(move_time / self.timestep) + 1 - num_steps = max(2, num_steps) - - robot_id = self.arm_controller.robot_loader.get_robot_id() - joint_indices = self.arm_controller.robot_loader.joint_indices - cid = self.arm_controller.physics_client - - for step in range(1, num_steps + 1): - ratio = step / num_steps - interpolated = ( - np.array(current_config) * (1 - ratio) + np.array(target_config) * ratio - ).tolist() - # 将KDL顺序转换为PyBullet顺序 - q_pb = self.arm_controller._to_pb_order(interpolated) - for j, jid in enumerate(joint_indices): - p.resetJointState(robot_id, jid, float(q_pb[j]), physicsClientId=cid) - time.sleep(self.timestep) - - final_config = self.arm_controller.get_current_joint_positions() - final_distance = np.linalg.norm(np.array(target_config) - np.array(final_config)) - if final_distance > self.position_tolerance: - raise RuntimeError(f"Failed to reach target, error: {final_distance}") - return True diff --git a/src/planning/rrt_star.py b/src/planning/rrt_star.py deleted file mode 100644 index e69de29..0000000