Mujoco Spec Editingのロゴ

Mujoco Spec Editing

コミュニティ
eust-w
mujoco-spec-editing

MuJoCo procedural model authoring, editing, and tuning with MjSpec (`mujoco.MjSpec` in Python and `mjSpec` in C++): bodies, geoms, joints, sites, cameras, sub-model attachment with prefix namespaces, actuators (position servos, motors, velocity drives, trntype), baseline option/default overrides (implicitfast, elliptic cones, solref, solimp, armature, damping), collision bitmasks (contype, conaffinity), friction (condim), default classes (MjsDefault), procedural meshes, deletion, spec recompilation (spec.recompile). Use only for authoring or tuning MuJoCo MJCF/MjSpec models, adding bodies/geoms/actuators, and attaching sub-models. Don't use for designing custom non-MuJoCo XML/scene-graph APIs when MuJoCo `MjSpec` is not used, deformable flex/cloth/cable modeling (mujoco-deformables), stepping simulations (mujoco-python), or rendering (mujoco-rendering).

概要

公開者eust-w
リポジトリopen-robotics-plugin
スキル名mujoco-spec-editing
スター
245
フォーク
0
同梱ファイル
指示のみ
ライセンスApache-2.0
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 指示だけで完結

    モデルに必要なものはすべて指示に含まれているため、別途同期するファイルはありません。

  • オープンソース

    eust-wがGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキル「Mujoco Spec Editing」をTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/eust-w/open-robotics-plugin/tree/main/skills/mujoco-spec-editing
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/eust-w/open-robotics-plugin.git /tmp/open-robotics-plugin
mkdir -p .claude/skills
cp -r /tmp/open-robotics-plugin/skills/mujoco-spec-editing .claude/skills/mujoco-spec-editing
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでMujoco Spec Editingを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあるとすぐに、モデルが自動的にMujoco Spec Editingを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Mujoco Spec Editingは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、スキルを使わない間は指示の読み込みにトークンを消費しません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

MuJoCo Spec Editing: Building & Modifying Models

[!TIP]

Official MuJoCo documentation (doc/*.rst): Read short chapters like ../../programming/modeledit.rst (.. _meOverview:) and ../../overview.rst directly when in a MuJoCo checkout; for large reference files like ../../modeling.rst (.. _ProceduralModeling:, .. _Mechanisms:, .. _CTuning:), ../../XMLreference.rst, ../../python.rst (.. _PyModelEdit:), and ../../APIreference/functions.rst, grep the literal .. _Label: anchor. Outside a checkout, the same doc/*.rst tree ships offline in pip install mujoco at pathlib.Path(mujoco.__file__).parent / 'doc'; otherwise fetch https://mujoco.readthedocs.io/en/latest/<path>.html (or /en/stable/ for released pages; functions.rst renders inside APIreference/APIfunctions.html, and Sphinx anchors lowercase the label, e.g. .. _meOverview: → #meoverview) and browse repo paths (../../../) under https://github.com/google-deepmind/mujoco/tree/main/.

Related skills:

  • mujoco-deformables — Deformable <flexcomp>, <flex>, and <skin> modeling (1D rods, 2D cloth/shells, 3D FEM soft bodies, and attachments).
  • mujoco-python — Simulation lifecycle, stepping, and diagnostics.
  • mujoco-rendering — Offscreen image rendering and camera setup.
  • mujoco-studio — Interactive viewers and Studio plugins.

1. Procedural Modeling with MjSpec

MjSpec is a mutable C++ and Python data structure that mirrors the MJCF XML schema, allowing models to be constructed and modified programmatically.

python
import mujoco

spec = mujoco.MjSpec()

# Add a body with a freejoint and sphere geom
body = spec.worldbody.add_body(name='ball', pos=[0, 0, 1.0])
body.add_freejoint()
body.add_geom(type=mujoco.mjtGeom.mjGEOM_SPHERE, size=[0.1], rgba=[1, 0, 0, 1])

# Compile to MjModel
model = spec.compile()

In C++:

cpp
#include <mujoco/mujoco.h>

mjSpec* spec = mj_makeSpec();
mjsBody* body = mjs_addBody(mjs_findBody(spec, "world"), nullptr);
body->pos[2] = 1.0;
mjs_addFreeJoint(body);
mjsGeom* geom = mjs_addGeom(body, nullptr);
geom->type = mjGEOM_SPHERE;
geom->size[0] = 0.1;

mjModel* model = mj_compile(spec, nullptr);
if (!model) printf("%s\n", mjs_getError(spec));
mj_deleteSpec(spec);

2. Building Hierarchies: Bodies, Geoms, Joints & Sites

Adding Elements

python
body = spec.worldbody.add_body(name='arm', pos=[0, 0, 0.5])

# Geom with capsule shape
geom = body.add_geom(
    name='arm_geom',
    type=mujoco.mjtGeom.mjGEOM_CAPSULE,
    size=[0.05, 0.25],
    rgba=[0.2, 0.6, 1.0, 1.0],
)

# Hinge joint
joint = body.add_joint(
    name='shoulder',
    type=mujoco.mjtJoint.mjJNT_HINGE,
    axis=[0, 1, 0],
    range=[-1.57, 1.57],
)

# Sensor site and camera
site = body.add_site(name='grip_site', pos=[0, 0, 0.25])
cam = body.add_camera(name='tool_cam', pos=[0, -0.5, 0.25], xyaxes=[1, 0, 0, 0, 0, 1])

Geom Dimensions Reference

Geom Typesize Parameter Semantics
mjGEOM_SPHERE[radius]
mjGEOM_CAPSULE[radius, half_length] (or [radius] if using fromto)
mjGEOM_CYLINDER[radius, half_length] (or [radius] if using fromto)
mjGEOM_BOX[half_x, half_y, half_z]
mjGEOM_ELLIPSOID[radius_x, radius_y, radius_z]
mjGEOM_PLANE[half_x, half_y, grid_spacing]

[!WARNING]

When fromto=[x1, y1, z1, x2, y2, z2] is specified for capsules or cylinders, size takes only one value ([radius]); length is calculated from endpoints.

Orientation Keywords

Only one orientation specification can be used at a time:

  • quat=[w, x, y, z] (native representation)
  • euler=[a1, a2, a3] (sequence set by spec.compiler.eulerseq, default 'xyz')
  • axisangle=[x, y, z, angle]
  • xyaxes=[x_x, x_y, x_z, y_x, y_y, y_z]
  • zaxis=[x, y, z]

Angles in euler and axisangle are in degrees unless spec.compiler.degree = False (see modeling.rst, .. _COrientation:, and XMLreference.rst, .. _body-geom:).

3. Sub-model Composition & Attachments

Compose models modularly by attaching sub-specs with prefix namespaces (see programming/modeledit.rst, .. _meAttachment: and .. _meAttributeMerging:):

python
parent = mujoco.MjSpec()
child = mujoco.MjSpec()

child_body = child.worldbody.add_body(name='gripper')
child_body.add_geom(size=[0.05], type=mujoco.mjtGeom.mjGEOM_SPHERE)

# Attach child spec to a mount site on the parent
mount_site = parent.worldbody.add_site(name='mount', pos=[0, 0, 1.0])
parent.attach(child, site=mount_site, prefix='gripper_')
# Child body is renamed to 'gripper_gripper' in parent

Cross-Spec Equality Constraints

When linking bodies from two different child specs (e.g. dual-arm setups), attach both children to the common parent first, then declare constraints on the parent spec:

python
left_mount = parent.worldbody.add_frame(pos=[0, 0.3, 0])
right_mount = parent.worldbody.add_frame(pos=[0, -0.3, 0])
parent.attach(arm1_spec, frame=left_mount, prefix='left_')
parent.attach(arm2_spec, frame=right_mount, prefix='right_')

eq = parent.add_equality(
    type=mujoco.mjtEq.mjEQ_CONNECT,
    objtype=mujoco.mjtObj.mjOBJ_BODY,
    name1='left_hand',
    name2='right_hand',
)
eq.data[0:3] = [0, 0, 0]  # connect anchor, in name1's body frame

[!NOTE]

attach() requires exactly one of frame= or site=; omitting both raises ValueError.

4. Deleting & Dynamically Modifying Elements

Deleting Elements

Pass the element object to spec.delete(); deleting a body removes its subtree:

python
spec.delete(spec.body('unwanted_body'))
spec.delete(spec.geom('old_geom'))
spec.delete(spec.joint('redundant_joint'))
spec.delete(spec.actuator('motor'))

State-Preserving Recompilation

When changing model architecture at runtime, use spec.recompile to keep existing physics state:

python
# Add new tool to robot
spec.worldbody.add_geom(name='tool_tip', size=[0.02], type=mujoco.mjtGeom.mjGEOM_SPHERE)

# Recompile keeping positions/velocities intact
model, data = spec.recompile(model, data)

5. Actuators & Servos

Always explicitly set the transmission type (trntype):

python
# 1. Torque Motor
motor = spec.add_actuator(
    name='torque_actuator',
    target='shoulder',
    trntype=mujoco.mjtTrn.mjTRN_JOINT,
)
motor.set_to_motor()

# 2. Stiff Position Servo (Recommended for position control)
servo = spec.add_actuator(
    name='pos_servo',
    target='shoulder',
    trntype=mujoco.mjtTrn.mjTRN_JOINT,
)
servo.set_to_position(kp=200.0, dampratio=1.0)  # Pair with implicitfast (kv defaults to 0)
servo.forcelimited = True
servo.forcerange = [-50.0, 50.0]     # Peak torque in Nm
servo.ctrllimited = True
servo.ctrlrange = [-1.57, 1.57]      # Target angle in radians

# 3. Velocity Actuator
vel = spec.add_actuator(
    name='vel_driver',
    target='wheel_joint',
    trntype=mujoco.mjtTrn.mjTRN_JOINT,
)
vel.set_to_velocity(kv=10.0)

[!CAUTION]

The helper functions set_to_position() and set_to_motor() configure gains but do not set the transmission. You must always specify trntype=mujoco.mjtTrn.mjTRN_JOINT (or another valid transmission type). See modeling.rst (.. _CActuators:, .. _CActShortcuts:) and XMLreference.rst (.. _actuator:).

6. Default Classes (Inheritance & Styling)

Default classes (MjsDefault) provide cascaded styling and properties (see modeling.rst, .. _CDefault:, and programming/modeledit.rst, .. _meDefault:):

python
# Create child class under root 'main' class
main_class = spec.default
rubber = spec.add_default('rubber', main_class)
rubber.geom.friction = [1.5, 0.01, 0.001]
rubber.geom.density = 1200.0

# Assign class at creation
body.add_geom(rubber, name='tire', type=mujoco.mjtGeom.mjGEOM_CYLINDER, size=[0.1, 0.05])

# Assign class post-creation (must pass MjsDefault object, NOT a string)
other_geom.classname = rubber

Baseline Tuning Overrides (<option> & Root <default>)

Several internal defaults (Euler, pyramidal cones with impratio=1, soft solref="0.02 1", zero joint armature/damping) are kept for backwards compatibility rather than new robotics models. Override them at the top of a project (full rationale and priority-ordered parameter guide in modeling.rst, .. _CTuning:, .. _CTuningDefaults:, .. _CTuningGlobal:, .. _CTuningModel:):

python
spec.option.integrator = mujoco.mjtIntegrator.mjINT_IMPLICITFAST  # DISCRETE for flex elasticity
spec.option.cone = mujoco.mjtCone.mjCONE_ELLIPTIC
spec.option.impratio = 10.0

spec.default.geom.solref = [0.005, 1.0]                 # Keep solref[0] >= 2 * timestep
spec.default.joint.armature = 0.01                      # Reflected rotor inertia (I_rotor * N^2)
spec.default.joint.damping = 0.1                        # Implicit in M + h*D at zero solver cost

Keep the default solimp: raising solimp[0] (e.g. to 0.95) halves rest penetration and creep but costs solver iterations, so reach for it only after solref and elliptic cones.

7. Collisions & Friction Tuning

Collision Filtering Bitmasks

Two geoms collide if and only if: (g1.contype & g2.conaffinity) || (g2.contype & g1.conaffinity)

python
# Visual-only geom: never collides; set mass=0 if omitting <inertial> so it
# does not add water-density (1000 kg/m^3) mass (inertiagrouprange defaults to "0 5")
body.add_geom(size=[0.1], contype=0, conaffinity=0, group=1, mass=0)

# Team A collides only with Team B
geom_a = body.add_geom(size=[0.1], contype=1, conaffinity=2)
geom_b = body.add_geom(size=[0.1], contype=2, conaffinity=1)

Contact Dimension (condim) & Friction

condimActive Friction ComponentsFriction Index Used
1Normal force only (frictionless)—
3Tangential sliding frictionfriction[0]
4Tangential + torsional (twisting)friction[0:2]
6Tangential + torsional + rollingfriction[0:3]
python
# High-friction contact for grasping
finger.add_geom(
    type=mujoco.mjtGeom.mjGEOM_CAPSULE,
    size=[0.01, 0.03],
    condim=4,
    friction=[1.2, 0.02, 0.0001],
)

For contact softness, solver impedance/reference tuning (solref, solimp, priority/mixing), and why parent-child geoms omit collisions by default, read modeling.rst (.. _CTuning:, .. _CTuningModel:, .. _CSolver:, .. _CContact:) and overview.rst (.. _SurprisingCollisions:, .. _Soft:, .. _Units:).

8. Procedural Meshes, Materials & Sensors

Procedural Meshes

python
vertices = np.array([[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]], dtype=np.float32)
faces = np.array([[0, 2, 1], [0, 1, 3], [0, 3, 2], [1, 2, 3]], dtype=np.int32)
mesh = spec.add_mesh(name='tetra', uservert=vertices.flatten(), userface=faces.flatten())
body.add_geom(type=mujoco.mjtGeom.mjGEOM_MESH, meshname='tetra')

Concave collision meshes are replaced by their convex hulls (unless using SDF plugins); prefer primitives (sphere, capsule, box, cylinder) for both speed and cleaner normals, or pre-decompose non-convex assets offline with CoACD or mjfit (see computation/index.rst, .. _coChecking: and .. _coDecomposition:).

Procedural Sensors

python
# IMU Accelerometer and Gyroscope
spec.add_sensor(name='torso_acc', type=mujoco.mjtSensor.mjSENS_ACCELEROMETER,
                objtype=mujoco.mjtObj.mjOBJ_SITE, objname='imu_site')
spec.add_sensor(name='torso_gyro', type=mujoco.mjtSensor.mjSENS_GYRO,
                objtype=mujoco.mjtObj.mjOBJ_SITE, objname='imu_site')

9. Common Gotchas & Best Practices

  1. Non-zero geom sizes: Geoms with radius or half-extents of zero cause immediate compilation errors.
  2. classname takes an object: geom.classname = 'rubber' raises a TypeError. Pass the MjsDefault instance: geom.classname = rubber.
  3. Always assign recompile(): spec.recompile(m, d) produces newly allocated model and data instances. Reassign them: m, d = spec.recompile(m, d) (see programming/modeledit.rst, .. _meRecompilation:).
  4. Declare high-contact "hub" bodies first (reverse-Cholesky fill-in): When a moving body with DOFs (e.g., an actuated tray, sieve, container, or robot base) contacts many independent clutter bodies, declare the hub body before the independent bodies so mju_cholFactorSparse factors the mass/Hessian arrowhead in $O(N)$ with zero fill-in rather than $O(N^3)$. Static geoms on worldbody have 0 DOFs and are unaffected — see the full derivation in modeling.rst (.. _CBodyOrdering:).
  5. Never add joints (including <freejoint/>) to the parent body of an unpinned <flexcomp> (except dof="2d" or "radial"). See mujoco-deformables for all <flexcomp>, <pin>, and <elasticity> rules.

10. Reference Models & Key References

Reference MJCF Models & Fixtures

Before authoring complex mechanisms or specialized elements from scratch, check existing models:

  • Built-in showcase models (../../../model/, or online at https://github.com/google-deepmind/mujoco/tree/main/model): model/humanoid/, model/tendon_arm/arm26.xml, model/car/car.xml, model/slider_crank/slider_crank.xml, model/flex/ (cables, cloth, soft bodies — see mujoco-deformables), model/replicate/ (newton_cradle.xml, particle.xml, bunnies.xml), model/plugin/ (actuator, sensor, SDF), model/tactile/, model/adhesion/, model/sleep/, model/speculative/, and model/plastic/.
  • MuJoCo Menagerie (models.rst, .. _Menagerie:): Production robot descriptions (Franka Panda/FR3, UR5e/UR10e, Unitree G1/H1/Go2, Spot, Barkour, Shadow Hand, Robotiq 2F-85, ALOHA 2, Skydio X2, Flybody) at https://github.com/google-deepmind/mujoco_menagerie.
  • Minimal test fixtures (../../../test/**/testdata/, or online under https://github.com/google-deepmind/mujoco/tree/main/test): Focused single-feature XMLs in test/user/testdata/ (MjSpec & compiler), test/xml/testdata/ (parent.xml / child.xml attachment fixtures, OpenUSD), and test/engine/testdata/ (collisions.xml, connect.xml, equality_site.xml, catenary.xml).

Documentation

Source Code & Notebook Examples

よくある質問

AIスキル「Mujoco Spec Editing」では何ができますか?

MuJoCo procedural model authoring, editing, and tuning with MjSpec (`mujoco.MjSpec` in Python and `mjSpec` in C++): bodies, geoms, joints, sites, cameras, sub-model attachment with prefix namespaces, actuators (position servos, motors, velocity drives, trntype), baseline option/default overrides (implicitfast, elliptic cones, solref, solimp, armature, damping), collision bitmasks (contype, conaffinity), friction (condim), default classes (MjsDefault), procedural meshes, deletion, spec recompilation (spec.recompile). Use only for authoring or tuning MuJoCo MJCF/MjSpec models, adding bodies/g...

TypingMindでMujoco Spec Editingを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Mujoco Spec Editingはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにMujoco Spec Editingをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/eust-w/open-robotics-plugin/tree/main/skills/mujoco-spec-editingを貼り付けてください。TypingMindがSKILL.mdを読み込み、チャットごとに有効にできるスキルとしてインストールします。

Mujoco Spec Editingを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストの内容がこのスキルの用途に合ったときに、このスキルを読み込めます。

Mujoco Spec Editingで使えるAIモデルの数に制限はありますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもMujoco Spec Editingを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Mujoco Spec Editing」は無料ですか?

はい。eust-wがApache-2.0ライセンスのもとでGitHubに公開しています。ご利用のAIプロバイダーに支払うのは、使用したトークンの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇