Physics Simulation

PyBullet 物理仿真技能 - 刚体动力学、碰撞检测、约束配置

miuav 50f79f3 1.0 KB Updated

File contents

PyBullet Physics Simulation Skill

用于 PyBullet 物理仿真配置


何时使用

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

  • 配置物理参数
  • 设置碰撞检测
  • 使用约束

快速参考

连接

import pybullet as p
import pybullet_data

client = p.connect(p.GUI)  # GUI 模式
# client = p.connect(p.DIRECT)  # 无头模式

p.setAdditionalSearchPath(pybullet_data.getDataPath())

物理配置

重力和时间步

p.setGravity(0, 0, -9.81)
p.setTimeStep(1/240)  # 默认 240Hz

约束

关节约束

# 创建点对点约束
constraint = p.createConstraint(
    parentBodyUniqueId,
    parentLinkIndex,
    childBodyUniqueId,
    childLinkIndex,
    p.JOINT_POINT2POINT,
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0]
)

另见

miuav/vibe-coding-ros2/tree/main/agents/skills/simulator/pybullet/physics-simulation commit 50f79f37fc

Frequently asked questions

npx skillmds@latest add miuav/physics-simulation-2