我正在尝试模拟雄鸭中的弹性弹跳球。但是,我还没有弄清楚如何为我加载的urdf模型设置恢复系数。德雷克是否支持点接触模型的弹性碰撞?如果是,如何设置各个参数?
编辑:我已经尝试使用plant.set_penetration_allowance(0.0001)
设置渗透率,但是出现以下错误:AttributeError: 'MultibodyPlant_[float]' object has no attribute 'set_penetration_allowance'
。但是,由于它是对临界阻尼系统进行建模的,所以我认为它无论如何也无济于事。
我当前的代码如下:
plane_friction_coef = CoulombFriction(static_friction=1.0, dynamic_friction=1.0)
# generate the diagram of the system
builder = DiagramBuilder()
plant, scene_graph = AddMultibodyPlantSceneGraph(builder, time_step=0.0)
parser = Parser(plant=plant)
# connect to Drake Visualizer
lcm = DrakeLcm()
ConnectDrakeVisualizer(builder, scene_graph, lcm=lcm)
# add plane to plant
X_WP = xyz_rpy_deg(xyz=[0, 0, 0], rpy_deg=[0,0,0]) # offset and orientation of plane wrt.
world frame
plant.RegisterVisualGeometry(plant.world_body(), X_BG=X_WP, shape=HalfSpace(),
name='InclinedPlaneVisualGeometry',
diffuse_color=np.array([1, 1, 1, 0.999]))
plant.RegisterCollisionGeometry(plant.world_body(), X_BG=X_WP, shape=HalfSpace(),
name='InclinedPlaneCollisionGeometry',
coulomb_friction=plane_friction_coef)
# set gravity in world
plant.mutable_gravity_field().set_gravity_vector(gravity_vec)
# add object from sdf or urdf file
my_object = parser.AddModelFromFile(obj_file_path, model_name='my_object')
plant.Finalize()
# add a logger
logger = LogOutput(plant.get_state_output_port(), builder)
logger.set_name('logger')
logger.set_publish_period(1 / recording_rate)
# build diagram and set its context
diagram = builder.Build()
diagram_context = diagram.CreateDefaultContext()
plant_context = diagram.GetMutableSubsystemContext(plant, diagram_context)
plant.SetPositionsAndVelocities(plant_context, gen_pos)
# start simulation
simulator = Simulator(diagram, diagram_context)
simulator.Initialize()
simulator.set_target_realtime_rate(1)
simulator.AdvanceTo(sim_time)
time_log = logger.sample_times()
state_log = logger.data()
我加载的urdf文件如下:
<?xml version="1.0"?>
<robot name="my_ball">
<material name="Black">
<color rgba="0.0 0.0 0.0 1.0"/>
</material>
<link name="base_link">
<inertial>
<origin rpy="0 0 0" xyz="0.0 0.0 0.0"/>
<mass value="5"/>
<inertia ixx="0.05" ixy="0" ixz="0" iyy="0.05" iyz="0" izz="0.05"/>
</inertial>
<visual>
<geometry>
<sphere radius="0.2"/>
</geometry>
<material name="Black"/>
</visual>
<collision name='collision'>
<geometry>
<sphere radius="0.2"/>
</geometry>
<drake:proximity_properties>
<drake:mu_dynamic value="1.0" />
<drake:mu_static value="1.0" />
</drake:proximity_properties>
</collision>
</link>
</robot>
答案 0 :(得分:0)
尼古拉斯,
不,目前我们不支持弹性碰撞,因为我们将精力集中在缓慢接近接触表面上,就像在操纵应用中一样。随着我们的联系求解器的成熟,我们一定会对此提供支持。
话虽如此,目前尚无支持为模型指定恢复系数。
最佳解决方案将取决于您的特定问题。这是一个垂直跳动的球吗?摩擦重要吗? (即球也可以水平移动吗?)是2D还是3D的盒子?
从简单到复杂,我建议:
MBP::get_applied_spatial_force_input_port()
连接所施加的力。希望这对您有所帮助。