Is there a way to start a simulation with a link (with a low stiffness coefficient) at a certain compression?

huangapple go评论100阅读模式
英文:

Is there a way to start a simulation with a link (with a low stiffness coefficient) at a certain compression?

问题

以下是您要翻译的内容:

我正在尝试将链接建模为弹簧,因此我已将drake:point_contact_stiffness参数添加到URDF中。但是,我想要控制在模拟开始时链接的挠曲程度。是否有一种方法可以使链接以任意挠曲程度开始模拟?

我尝试通过在链接上移动质量的方式来影响这个值,所以我改变了URDF,包括了腿链接和髋部质量之间的棱柱关节。为了让链接在开始时稍微压缩,我希望通过棱柱关节将髋部质量“推”到腿链接上。在模拟中,这并没有很好地起作用,腿链接和髋部质量会相互飞离。

以下是如何将碰撞动力学添加到地面和腿链接的示例:

<!-- 地面 -->
<link name="ground">
  <visual>
    <origin xyz="0 0 -.25" rpy="0 0 0"/>
    <geometry>
      <box size="10 1 .5" />
    </geometry>
    <material name="green">
      <color rgba="0 1 0 1" />
    </material>
  </visual>
  <collision name="collision_ground">
    <origin xyz="0 0 -.25" rpy="0 0 0"/>
    <geometry>
      <box size="10 1 .5" />
    </geometry>
    <drake:proximity_properties>
      <drake:hunt_crossley_dissipation value="0.1"/>
      <drake:point_contact_stiffness value="10000"/>
    </drake:proximity_properties>
  </collision>
</link>

在这里,我正在尝试从初始条件模拟步行模型0.9秒。在这里,理想情况下,我希望腿链接以一些挤压开始。

builder = DiagramBuilder()
compass_walker, scene_graph = AddMultibodyPlantSceneGraph(builder, time_step=0.0)
Parser(compass_walker).AddModelFromFile(file_name="compass.urdf")

compass_walker.Finalize()
compass_walker.set_name("cw")

meshcat.Delete()
visualizer = MeshcatVisualizer.AddToBuilder(builder, scene_graph, meshcat)
visualizer.set_name("visualizer")
logger = LogVectorOutput(compass_walker.get_state_output_port(), builder)

# 完成构建块图
diagram = builder.Build()
simulator = Simulator(diagram)

context = simulator.get_mutable_context()
plant_context = compass_walker.GetMyMutableContextFromRoot(context)

context.SetContinuousState([0.0, 0.0, 0.156, -0.312, 0.0, 0.0, -0.3975, -0.3065]) #8 states

visualizer.StartRecording()
simulator.AdvanceTo(0.908)
visualizer.PublishRecording()

log = logger.FindLog(context)

希望这些翻译对您有帮助。

英文:

I am trying to model links as springs so I have added drake:point_contact_stiffness parameters to the URDF. However, I want to control how much the link is deflected at the start of the simulation. Is there a way to start the simulation with the link at an arbitrary deflection?

I tried to influence this value by moving a mass on the link up and down, so I changed the URDF to include a prismatic joint between the leg link and hip mass. In order to get the link to start a bit compressed, I hoped I could "push" the hip mass onto the leg link using the prismatic joint. In simulation, this did not work very well and the leg link and hip mass would fly apart from each other.

Here is an example on how the collision dynamics were added to the ground and leg links:

<!-- ground -->

<link name="ground">

&lt;visual&gt;
  &lt;origin xyz=&quot;0 0 -.25&quot; rpy=&quot;0 0 0&quot;/&gt;
  &lt;geometry&gt;
    &lt;box size=&quot;10 1 .5&quot; /&gt;
  &lt;/geometry&gt;
  &lt;material name=&quot;green&quot;&gt;
    &lt;color rgba=&quot;0 1 0 1&quot; /&gt;
  &lt;/material&gt;
&lt;/visual&gt;

&lt;collision name=&quot;collision_ground&quot;&gt;
  &lt;origin xyz=&quot;0 0 -.25&quot; rpy=&quot;0 0 0&quot;/&gt;
  &lt;geometry&gt;
    &lt;box size=&quot;10 1 .5&quot; /&gt;
  &lt;/geometry&gt;
  &lt;drake:proximity_properties&gt;
     &lt;drake:hunt_crossley_dissipation value=&quot;0.1&quot;/&gt;
     &lt;drake:point_contact_stiffness value=&quot;10000&quot;/&gt;&gt;
    &lt;/drake:proximity_properties&gt;
&lt;/collision&gt; 

</link>

And here I am trying to simulate the walker model for 0.9 second from an initial condition. Ideally, here I would like the leg link to start with some compression.

builder = DiagramBuilder()
compass_walker, scene_graph = AddMultibodyPlantSceneGraph(builder, time_step=0.0)
Parser(compass_walker).AddModelFromFile(file_name=&quot;compass.urdf&quot;)

compass_walker.Finalize()
compass_walker.set_name(&quot;cw&quot;)

meshcat.Delete()
visualizer = MeshcatVisualizer.AddToBuilder(builder, scene_graph, meshcat)
visualizer.set_name(&quot;visualizer&quot;)
logger = LogVectorOutput(compass_walker.get_state_output_port(), builder)


# finish building the block diagram
diagram = builder.Build()
simulator = Simulator(diagram)


context = simulator.get_mutable_context()
plant_context = compass_walker.GetMyMutableContextFromRoot(context)

context.SetContinuousState([0.0, 0.0, 0.156, -0.312, 0.0, 0.0, -0.3975, -0.3065]) #8 states


visualizer.StartRecording()
simulator.AdvanceTo(0.908)
visualizer.PublishRecording()

log = logger.FindLog(context)

答案1

得分: 1

如果您想要将一个链接建模成弹簧,我认为您需要有两个链接,它们通过一个棱柱关节和一个LinearSpringDamper相连接。然后,通过设置棱柱关节的初始状态,您可以设置弹簧的初始长度。

注意:如果弹簧的任一侧是运动树中的“叶子”,则您需要在弹簧的任一侧上具有非零质量--通常情况下,质量为零的脚趾部分的非常简单的腿型机器人模型通常需要手动处理,而不使用多体动力学引擎。例如,根据这个原因,在非驱动注释中的弹簧加载倒立摆模型是手动推导的;该模型的动力学仅在脚与地面接触时才定义良好,我们必须明确忽略在空中阶段的物理。

您说得对,地面中的软接触模型也实现了弹簧刚度(通常这个刚度会高于任何内部弹簧的刚度)。这将在地面的法线方向上施加力,而不是沿着您的腿的轴线,因此它最多只是腿部弹簧的粗略近似。如果您选择这种方法,那么通过解决InverseKinematics问题来设置机器人的初始位置以实现对地面的一定穿透是可行的。

英文:

If you want to "model a link as a spring", I would think that you would want to have two links that are connected to each other via a prismatic joint and a LinearSpringDamper between them. Then setting the initial state of the prismatic joint gives you a way to set the initial length of the spring.

Note: you'll need to have non-zero mass on either side of the spring if either side of the spring is a "leaf" in the kinematic tree -- the very simple legged robot models that have massless toes typically have to be done manually and don't use the multibody dynamics engine. For instance, the spring-loaded inverted pendulum model in the underactuated notes is derived by hand for this reason; the dynamics of that model are not well-defined except when the foot is in contact with the ground, and we have to explicitly ignore physics in the aerial phase.

You're right that the soft contact model in the ground also implements a spring stiffness (typically this would be higher than the stiffness of any internal springs). This will apply forces in the normal direction of the ground, not along the axis of your leg, so it would be a coarse approximation of a leg spring at best. If you do go with this approach, then setting the initial position of the robot to achieve a certain penetration into the ground could be done by solving an InverseKinematics problem.

huangapple
  • 本文由 发表于 2023年6月30日 03:05:34
  • 转载请务必保留本文链接:https://go.coder-hub.com/76583966.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定