Command Palette

Search for a command to run...

Back to skills
skill № 15186

grasp-planning

机械臂抓取规划技能 - 6-DOF抓取、点云感知、MoveIt GraspGenerator、深度学习抓取检测

FreeNo executable scripts
MIUAVby MIUAV★ 30 GitHub stars

Install grasp-planning in Claude Code & Claude Desktop

Sign up to install this skill

Create a free account to reveal the install command and save the skill to your library.

  • Reveal the one-line install command
  • Save skills to your synced library
  • Get notified when skills update
Sign up freeI already have an account

About this skill

机械臂抓取规划技能

用于开发机械臂的抓取规划系统,涵盖 6-DOF 抓取姿态估计、点云处理、MoveIt 集成和深度学习抓取检测


何时使用

当需要以下帮助时使用此技能:

  • 实现目标物体的 6-DOF 抓取姿态规划
  • 集成点云传感器进行抓取检测
  • 配置 MoveIt GraspGenerator
  • 开发深度学习抓取检测网络
  • 评估抓取质量并选择最优抓取
  • 多指灵巧手的抓取规划

快速参考

抓取类型

抓取类型:
├── 平行夹抓 (Parallel Jaw): 两指平行,适合扁平物体
├── 捏取 (Pinch): 拇指+食指,适合小物体
├── 包络抓取 (Enveloping): 全手包裹,适合球形物体
└── _power grasp (强力抓取): 配合手腕力,适合重型物体

ROS2 接口

# 核心包
sudo apt install -y ros-humble-moveit-resources
sudo apt install -y ros-humble-moveit-ros-visualization

# 抓取检测(需要 Xavier NX / Orin)
sudo apt install -y ros-humble-depthimage-to-laserscan

核心话题

话题 类型 说明
/obj_detection/object_pose geometry_msgs/PoseStamped 物体位姿
/grasp_poses geometry_msgs/PoseArray 候选抓取姿态
/gripper/cmd std_msgs/Float64 夹爪开合

6-DOF 抓取姿态表示

抓取表示法

import numpy as np
from dataclasses import dataclass
from typing import List, Tuple, Optional

@dataclass
class GripperConfig:
    """夹爪配置"""
    finger_width: float = 0.01      # 指宽 (m)
    max_span: float = 0.1           # 最大开距 (m)
    palm_size: Tuple[float, float, float] = (0.05, 0.03, 0.02)  # 掌心尺寸

@dataclass
class GraspPose:
    """6-DOF 抓取姿态"""
    # 位置 (x, y, z) - 夹爪掌心中心
    position: np.ndarray  # shape (3,)

    # 姿态 - 夹爪坐标系相对于物体坐标系
    # approach: 接近方向 (approach direction)
    # grasp_direction: 抓取闭合方向
    # binormal: 垂直于前两者的方向
    approach: np.ndarray   # (3,) 从物体指向夹爪
    grasp_direction: np.ndarray  # (3,) 闭合方向
    binormal: np.ndarray   # (3,)

    # 夹爪开度
    open_width: float = 0.0

    # 抓取质量评分
    quality: float = 0.0

    def to_matrix(self) -> np.ndarray:
        """转换为 4x4 齐次变换矩阵"""
        R = np.column_stack([self.grasp_direction, self.binormal, self.approach])
        T = np.eye(4)
        T[:3, :3] = R
        T[:3, 3] = self.position
        return T

逆运动学验证

import numpy as np
from typing import List, Optional

class GraspIKValidator:
    """验证抓取姿态的可达性和碰撞"""

    def __init__(self, robot_model, scene):
        self.robot_model = robot_model
        self.scene = scene  # MoveIt PlanningScene

    def validate(
        self,
        grasp_pose: GraspPose,
        arm_group: str = "manipulator"
    ) -> bool:
        """
        验证抓取姿态是否可达且无碰撞
        """
        # 1. 末端执行器姿态(夹爪闭合时的姿态)
        ee_pose = grasp_pose.to_matrix()

        # 2. 逆运动学求解
        joint_limits = self.robot_model.get_joint_limits(arm_group)
        ik_solution = self.robot_model.solve_ik(
            ee_pose,
            arm_group=arm_group,
            joint_limits=joint_limits
        )

        if ik_solution is None:
            return False  # 不可达

        # 3. 碰撞检测
        self.scene.set_joint_state(arm_group, ik_solution)
        if self.scene.check_collisions(arm_group):
            return False  # 有碰撞

        return True

    def find_valid_grasp(
        self,
        grasp_poses: List[GraspPose],
        arm_group: str = "manipulator"
    ) -> Optional[GraspPose]:
        """从候选抓取中找到第一个有效的"""
        for grasp in grasp_poses:
            if self.validate(grasp, arm_group):
                return grasp
        return None

点云预处理

import numpy as np
import open3d as o3d
from typing import Tuple

class PointCloudPreprocessor:
    """点云预处理用于抓取检测"""

    @staticmethod
    def preprocess(
        cloud: o3d.geometry.PointCloud,
        voxel_size: float = 0.003,
        outlier_nb_neighbors: int = 20,
        outlier_std_ratio: float = 0.8
    ) -> o3d.geometry.PointCloud:
        """
        点云预处理流程
        """
        # 1. 下采样(体素滤波)
        cloud_down = cloud.voxel_down_sample(voxel_size)

        # 2. 去除离群点
        cl, ind = cloud_down.remove_statistical_outlier(
            nb_neighbors=outlier_nb_neighbors,
            std_ratio=outlier_std_ratio
        )
        cloud_filtered = cloud_down.select_by_index(ind)

        # 3. 估计法向量
        cloud_filtered.estimate_normals(
            search_param=o3d.geometry.KDTreeSearchParamHybrid(radius=0.02, max_nn=30)
        )

        return cloud_filtered

    @staticmethod
    def extract_object_clusters(
        cloud: o3d.geometry.PointCloud,
        eps: float = 0.02,
        min_points: int = 100
    ) -> list:
        """
        欧几里得聚类分割物体
        """
        with o3d.utility.VerbosityContextManager(o3d.utility.VerbosityLevel.Error):
            labels = np.array(
                cloud.cluster_dbscan(eps=eps, min_points=min_points, print_progress=False)
            )

        clusters = []
        max_label = labels.max()
        for i in range(max_label + 1):
            indices = np.where(labels == i)[0]
            cluster = cloud.select_by_index(indices)
            clusters.append(cluster)

        return clusters

    @staticmethod
    def compute_grasps_from_cluster(cluster: o3d.geometry.PointCloud) -> List[GraspPose]:
        """
        从点云簇生成候选抓取
        """
        center = cluster.get_center()

        # 计算物体主轴方向
        cov = cluster.compute_mean_a
Full SKILL.md on GitHub

Allowed tools

Tools this skill is permitted to call.

No restriction — this skill can use any tool.

FAQ

What does the grasp-planning skill do?

机械臂抓取规划技能 - 6-DOF抓取、点云感知、MoveIt GraspGenerator、深度学习抓取检测

How do I install the grasp-planning skill?

Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.

Does the grasp-planning skill run scripts?

No, this skill is instructions only (SKILL.md) with no executable scripts.

Related skills

Compare grasp-planning with