首页 > 解决方案 > 如何在 MultibodyPlant 中设置特定实体的摩擦属性(或任何 GeometryProperties)?

问题描述

我想知道如何设置物体的摩擦属性MultibodyPlant

更具体地说,我有一个从 SDF 读取的模型实例,我想在该模型实例中添加或更改特定物体的摩擦属性。

标签: drake

解决方案


有几种方法可以设置摩擦属性。除了您非常具体的问题之外,我还将概述多个工作流程。(作为旁注,虽然其中一些已记录在案,但不一定可以在 doxygen 中发现 - 甚至渲染 - 这是一个需要解决的突出问题,存在问题)。

  • 在 urdf/sdf 中定义。
    • Drake 为标签提供了与接触属性(包括摩擦等)相关的自定义<geometry>标签。URDF/SDF 中的标签相同,但使用方式略有不同(基于 SDF 与 URDF 的风格)。可以在此处找到 sdf 的详细信息, 在此处找到 urdf 的详细信息。
  • 通过 API 添加新几何并在定义中包含摩擦。
    #include "drake/geometry/proximity_properties.h"
    #include "drake/multibody/plant/multibody_plant.h"
    
    // Omitting drake:: namespaces for clarity.
    MultibodyPlant<double> plant;
    // Populate plant with bodies.   
    ProximityProperties contact_props;
    AddContactMaterial({}, {}, CoulombFriction<double>(mu_s, mu_d), &contact_props);
    // Assume we've defined body, X_BG, shape, and name elsewhere.
    plant.RegisterCollisionGeometry(body, X_BG, shape, name, contact_props);
    
  • 添加/更新到 urdf/sdf 中定义的几何图形
    • 在这种情况下,我们需要SceneGraph根据它与实体的关联来更改几何定义。这意味着,从 开始Body,我们需要得到GeometryId. 我们将假设已经完成并且您拥有GeometryId此工作流程。
    SceneGraph<double> sg;
    const GeometryId g_id = ...;
    CoulombFriction<double> friction(mu_s, mu_d);
    ProximityProperties new_props;
    const ProximityProperties* curr_props = 
        sg.model_inspector().GetProximityProperties(g_id);
    if (curr_props != nullptr) {
      new_props = *curr_props;
    }
    // Replaces old friction definition, or adds it if previously absent.
    new_props.UpdateProperty("material", "coulomb_friction", friction);
    sg.AssignRole(g_id, new_props, RoleAssign::kReplace);
    

推荐阅读