notes
Tools

MuJoCo 物理の設定階層

MuJoCo の物理シミュレーションを構成する 5 階層 (option / compiler / solver / joint-geom / actuator) と各要素の主要パラメータ・単位・実用値

要点#

MuJoCo の物理設定は 5 階層。上から順に (1) <option> 積分器/ソルバ、(2) <compiler> 前処理、(3) 接触 impedance (solref/solimp)、(4) joint/geom プロパティ、(5) actuator。

各階層と主要パラメータ#

1. <option> — 全体積分器・ソルバ#

<option timestep="0.001" integrator="implicitfast" cone="elliptic"
        iterations="100" noslip_iterations="15">
  <flag sleep="enable"/>
</option>
属性意味実用値
timestep [s]積分ステップ0.001-0.005
integrator積分方式implicitfast (推奨) / RK4 / Euler / implicit
cone摩擦錐pyramidal (高速) / elliptic (正確、車輪向き)
iterationsソルバ反復数100 (default)
noslip_iterations追加 no-slip 反復車輪では 10-20
impratio摩擦/法線 impedance 比1 (default)
<flag sleep="enable"/>静止 body の休止大量 body のパフォーマンス改善

2. <compiler> — 前処理#

<compiler angle="radian" autolimits="true" discardvisual="true"/>
  • angle="radian"|"degree": joint 角度単位
  • autolimits="true": range で自動で limited=true に
  • discardvisual="true": contype=0 の geom を physics から除外 (メモリ節約)
  • inertiafromgeom="true|false|auto": body の inertial を geom から自動計算

3. 接触 impedance (per-contact)#

接触の剛性・減衰は 2 属性で決まる。

  • solref="timeconst dampratio": 接触制約の time constant [s] と damping ratio
    • default "0.02 1" — 20ms で settle, critical damping
    • 硬く: "0.005 1" (5ms)
    • 柔らかく: "0.05 1.5" (50ms + overdamped)
  • solimp="dmin dmax width mid power": 貫入距離依存の impedance プロファイル
    • default "0.9 0.95 0.001 0.5 2"
    • dmin: 深い貫入時の impedance
    • dmax: 表面接触時の impedance
    • width: 遷移幅 [m]

4. Joint / Geom プロパティ#

属性単位意味
<joint damping="x">N·m·s/rad (hinge) / N·s/m (slide)粘性
<joint armature="x">kg·m²反射慣性 (ギア減速機のロータ慣性)
<joint frictionloss="x">N·m or NCoulomb 摩擦 (静止摩擦)
<joint stiffness="x">N·m/radばね
<geom friction="slide roll spin">無次元 3 成分摩擦係数 (デフォルト "1 0.005 0.0001")
<geom mass="x"> / <geom density="x">kg / kg/m³質量指定
`<geom condim="134
<geom margin="x">m接触検出マージン

5. Actuator (実機との対応)#

種類用途主要属性
<motor>生トルク/力gear, ctrlrange, forcerange
<velocity kv="x">速度サーボ hackforce = kv * (ctrl*gear - joint_vel)
<position kp="" kv="">位置サーボ (PD)force = kp*err - kv*vel
<dcmotor>DC モータの電気モデルresistance, motorconst (Kt Ke), inductance, saturation (電流上限 [A]), controller (内部 PID), input (voltage/velocity/position)
<general>プログラマブルdyntype, gaintype, biastype

<dcmotor> の例 (RoboMaster M2006 P36 相当):

<dcmotor name="wheel0" joint="wheel0_joint"
         resistance="0.038" motorconst="0.056 0.056"
         inductance="1.6e-5 0" saturation="2.25 0 0"
         input="velocity" controller="0.136 0.036 0 0 0 24"/>
  • controller="kp ki kd int_min int_max u_max" の 6 要素。内部の PID + 電圧飽和
  • input="velocity": ctrl は速度目標 (rad/s) として解釈

チューニング手順#

  1. 骨格作成: URDF → MJCF (Menagerie の変換スクリプト or 手書き)
  2. <option>: timestep / integrator / cone を用途に合わせる (車輪あるなら elliptic + noslip_iterations)
  3. <default> class: 繰り返し要素をまとめて記述
  4. actuator: 実機モータ種別に合わせる。BLDC なら <dcmotor> + preset class (fibril_sim_models が公開)
  5. damping / friction / solref: 実機と挙動が合わない箇所を上下. 車輪の跳ね上がりは damping 増 or solref 柔らかく

デバッグの視点#

  • 貫入が深い / すり抜け: solimp の dmax を上げる or timestep を下げる
  • 接触が硬すぎて跳ねる: solref の time constant を大きく (0.02 → 0.05)
  • 車輪が滑る: friction 上げる or noslip_iterations 増
  • PID が振動: kd 増 or kp 減
  • 重すぎて動かない: forcerange の上限 or gear ratio 確認

参考#

最終更新:

On this page