drake - 在 Pydrake 中找到与给定模型的关节相关的框架的雅可比行列式

标签 drake

有什么方法可以找到与给定模型(而不是整个工厂)的关节相关的框架的雅可比行列式,或者确定完整工厂雅可比列的哪些列对应于给定模型的关节?我找到了 MultibodyPlant.CalcJacobian* ,但我不确定这些是否是正确的方法。
我也尝试映射 JointIndex将模型中的每个关节添加到 MultibodyPlant.CalcJacobian* 的列中,但结果没有意义——联合索引是连续的(所有一个模型后跟所有其他模型),但雅可比列看起来交错(一列对应一个模型,然后一个对应另一个模型) .

最佳答案

假设您正在计算速度,您将需要使用 Joint.velocity_start()Joint.num_velocities()创建一个掩码或一组索引。如果您使用的是 Python,那么您可以使用 NumPy 的数组切片来选择您想要的雅可比列。
(如果您计算 w.r.t. 位置,请确保使用 Joint.position_start()Joint.num_positions() 。)
示例笔记本:
https://nbviewer.jupyter.org/github/EricCousineau-TRI/repro/blob/eb7f11d/drake_stuff/notebooks/multibody_plant_jacobian_subset.ipynb
(TODO:指向更官方的来源。)
主要需要注意的代码:

def get_velocity_mask(plant, joints):
    """
    Generates a mask according to supplied set of ``joints``.

    The binary mask is unable to preserve ordering for joint indices, thus
    `joints` required to be a ``set`` (for simplicity).
    """
    assert isinstance(joints, set)
    mask = np.zeros(plant.num_velocities(), dtype=np.bool)
    for joint in joints:
        start = joint.velocity_start()
        end = start + joint.num_velocities()
        mask[start:end] = True
    return mask

def get_velocity_indices(plant, joints):
    """
    Generates a list of indices according to supplies list of ``joints``.

    The indices are generated according to the order of ``joints``, thus
    ``joints`` is required to be a list (for simplicity).
    """
    indices = []
    for joint in joints:
        start = joint.velocity_start()
        end = start + joint.num_velocities()
        for i in range(start, end):
            indices.append(i)
    return indices

...

# print(Jv1_WG1)  # Prints 7 dof from a 14 dof plant
[[0.000 -0.707 0.354 0.707 0.612 -0.750 0.256]
 [0.000 0.707 0.354 -0.707 0.612 0.250 0.963]
 [1.000 -0.000 0.866 -0.000 0.500 0.612 -0.079]
 [-0.471 0.394 -0.211 -0.137 -0.043 -0.049 0.000]
 [0.414 0.394 0.162 -0.137 0.014 0.008 0.000]
 [0.000 -0.626 0.020 0.416 0.035 -0.064 0.000]]

关于drake - 在 Pydrake 中找到与给定模型的关节相关的框架的雅可比行列式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68578567/

相关文章:

drake - 针对各个关节角度的雅可比导数的自动微分

drake - 由自由体基座组成的机器人的广义速度结构是什么?

drake - 示例 Acrobot plant A 矩阵与标准形式之间的差异

python - 如何将标签图像从 pydrake/Drake 直接保存到磁盘?

drake - 如何运行自定义 slider

simulation - Drake中如何使钟摆因重力而摆动

python-3.x - 如何将联合索引映射到广义位置的对应索引?

ros - 无法将 underlay ros2 安装与 drake-ros 一起用作 Bazel 工作区中的外部

drake gurobi 无法处理二次约束

ubuntu - 德雷克几何_inspector.py : error: File does not exist: