## 01 · From measured assembly to MJCF

Let's look at from measured assembly to mjcf using a real-to-sim experiment. We are now translating a real robot into a runnable MuJoCo model. The goal is not merely a file that compiles, but a body tree whose frames, geometry and physical parameters correspond to measured hardware.

MJCF is a declarative model description. The worldbody contains bodies and geoms, joints introduce degrees of freedom, and defaults can make repeated attributes easier to maintain without copying values everywhere.

Here is how I would turn this into a reproducible experiment. Start with a two-link manipulator and tabletop. Display the real reference dimensions beside the corresponding body positions and local frame axes. Compile and inspect the resolved model rather than trusting source XML alone.

Models often appear to work with implicit defaults even when those defaults encode assumptions the experiment never established.

Open the compiled model in a diagnostic viewer and compare transformed marker locations with source CAD measurements. Keep a small table: physical point in meters, compiled world point and signed difference. The table is more objective than a camera angle.

For every moving part, trace the frame from its physical mounting reference to the compiled joint and collision geometry.

The quickest way to uncover an implementation mistake is to reduce the model to one body, one joint or one contact and compare it with a calculation we can do by hand. Preserve this small reference so later asset edits cannot break it silently.

The package should run without a visible editor or manual clicks. If there is an unexpected result, a single script ought to print the physical quantity, units, model version and input conditions that would let somebody else reproduce it.

Keep the original trial and the counterexample in the record; both teach us something.

## 02 · Bodies, transforms, and joints

Our next diagnostic is bodies, transforms, and joints. In MuJoCo, a body transform defines a frame for its child elements, while joints specify permitted relative motion. Keeping those roles separate prevents many seemingly random kinematic errors.

Hinge axes and joint positions are expressed in specified local frames; joint ranges and reference positions change what commanded coordinates mean. The chain of transforms must match the physical mechanism.

Before fitting anything, verify the definitions of the quantities on screen. Animate one hinge at a time while freezing all others. Overlay commanded axis, observed endpoint path and an independent CAD marker. A wrong axis often draws the correct arc in the wrong plane.

It is tempting to fix the visible end-effector pose by compensating in the final link. That can conceal an incorrect upstream joint frame and break dynamics elsewhere.

When testing joint origins, command equal positive and negative excursions around zero. A sign mismatch is easier to see as an asymmetric reversal. For complex chains, validate each joint in isolation before composing motions.

Check joint sign, zero pose, limits, parent-child relationships and round-trip forward kinematics before actuating the full robot.

The package should run without a visible editor or manual clicks. If there is an unexpected result, a single script ought to print the physical quantity, units, model version and input conditions that would let somebody else reproduce it.

As the model animates, distinguish authored MJCF values from compiled engine state and from derived quantities in MjData. Those categories correspond to different debugging questions; one is the model specification, one is the current experiment, and one is an inferred consequence.

If those checks disagree, stop and fix the assumption before continuing.

## 03 · Geoms and inertial properties

In this scene, geoms and inertial properties is our focus. A pretty mesh is not enough. Collision geoms and inertial properties must be explicitly justified, or the simulator can have correct kinematics with incorrect acceleration and contact behavior.

Use the distinction between visual and colliding geoms. Assign mass and inertia from measurements, CAD or a documented approximation and check positive definiteness of inertia.

We're going to test this rather than treat it as a cosmetic adjustment. Place two equal-total-mass links with different mass distributions under an identical torque profile. Display the resulting angular acceleration and shift in reaction forces.

Assigning mass by visual volume alone can create unrealistic COM placement, especially for hollow shells, motors and gearboxes.

An inertia matrix should satisfy symmetry and positivity under physically valid mass distributions. Check principal values, trace and center-of-mass placement rather than copying the bounding-box volume into an automatic mass formula.

Compare masses, centers of mass, principal inertias and collider bounds against independently derived reference values.

As the model animates, distinguish authored MJCF values from compiled engine state and from derived quantities in MjData. Those categories correspond to different debugging questions; one is the model specification, one is the current experiment, and one is an inferred consequence.

The quickest way to uncover an implementation mistake is to reduce the model to one body, one joint or one contact and compare it with a calculation we can do by hand. Preserve this small reference so later asset edits cannot break it silently.

That is how a visually convincing demonstration becomes an experimentally defensible claim.

## 04 · Actuators and transmission

Let's look at actuators and transmission using a real-to-sim experiment. MuJoCo actuators apply forces through defined transmissions. A requested control value is not automatically a joint angle and not always a joint torque.

Motor, position and velocity actuators encode different mappings; gear ratios, force limits and activation dynamics matter. Joint damping and friction are distinct from controller action.

Watch the animation carefully as we change only one part of the setup. Drive a single hinge with a known control waveform while plotting control, actuator force, joint acceleration and resulting motion. Show the difference between open-loop torque and high-gain position control.

An actuator set to an enormous gain can make an incorrect model appear well controlled until contact exposes the error as huge impulses.

Choose whether a controller is represented inside MuJoCo or outside it and make that choice explicit. Two active feedback controllers can oppose each other or appear to add unexplained damping during contact.

Document units, transmission, saturation, gain and control clock before comparing tracking performance to real hardware.

The quickest way to uncover an implementation mistake is to reduce the model to one body, one joint or one contact and compare it with a calculation we can do by hand. Preserve this small reference so later asset edits cannot break it silently.

The package should run without a visible editor or manual clicks. If there is an unexpected result, a single script ought to print the physical quantity, units, model version and input conditions that would let somebody else reproduce it.

The goal is an engineering test that can fail for an understandable reason.

## 05 · Contact parameters in MJCF

Our next diagnostic is contact parameters in mjcf. MuJoCo models can contain friction, solref and solimp parameters that influence contact behavior. These values should be calibrated against actual observables, not tweaked until a screenshot feels convincing.

Collision masks and exclusions define which pairs can touch. Contact compliance settings affect the effective normal response; geom sizes and transforms set when contact begins.

The important thing here is to separate an observation from an explanation. Bring a block into a gripper under controlled normal load. Plot penetration, tangential slip and force while changing exactly one contact parameter.

If contact starts too soon, inspect geometry first. If static onset agrees but dynamic sliding does not, diagnose the friction model and measurement conditions.

Observe the first-contact frame in the engine and compare against the physical probe measurement. Friction tuning should begin only after normal geometry and loading have been independently checked.

Keep a log of physical trial IDs, controller state and simulated contact settings for each calibration run.

The package should run without a visible editor or manual clicks. If there is an unexpected result, a single script ought to print the physical quantity, units, model version and input conditions that would let somebody else reproduce it.

As the model animates, distinguish authored MJCF values from compiled engine state and from derived quantities in MjData. Those categories correspond to different debugging questions; one is the model specification, one is the current experiment, and one is an inferred consequence.

Notice that the image is evidence of a hypothesis, not a substitute for measurement.

## 06 · Sensor model and frames

In this scene, sensor model and frames is our focus. Sensors are observations, not ground truth. In the compiled MuJoCo model they have specified attachment frames, outputs and sampling interpretation.

Joint position and velocity readings, force or torque signals, accelerometer and site-based measurements must be compared to the actual instrument mounting, sign convention and rate.

Here is how I would turn this into a reproducible experiment. Place an accelerometer at a local site and rotate the body. Show how a fixed local sensor basis moves in world coordinates, then compare simulated measurement under gravity to expectations.

A perfect simulated sensor can make an estimator look stronger than it will be on hardware with bias, drift, quantization or latency.

For an IMU-like observation, isolate gravitational acceleration, rotational acceleration and translation. A sensor attached away from the center of rotation experiences an additional acceleration that a world-frame marker does not.

Measure hardware noise and timestamp properties separately; add only uncertainty components that experiments support.

As the model animates, distinguish authored MJCF values from compiled engine state and from derived quantities in MjData. Those categories correspond to different debugging questions; one is the model specification, one is the current experiment, and one is an inferred consequence.

The quickest way to uncover an implementation mistake is to reduce the model to one body, one joint or one contact and compare it with a calculation we can do by hand. Preserve this small reference so later asset edits cannot break it silently.

Keep the original trial and the counterexample in the record; both teach us something.

## 07 · MjModel, MjData and stepping

Let's look at mjmodel, mjdata and stepping using a real-to-sim experiment. The Python API distinguishes the compiled, mostly structural MjModel from the mutable runtime MjData holding state. A correct simulation loop respects that distinction.

Set state, call forward dynamics when appropriate to derive dependent quantities, then step the model and read time, joint state and contacts. Use the exact installed version’s API and avoid modifying model constants casually midexperiment.

Before fitting anything, verify the definitions of the quantities on screen. Run a ten-second deterministic motor test in Python and print a CSV of time, qpos, qvel, control, body pose and contact count. Replay the same initial conditions and check output consistency.

Reading stale derived quantities immediately after directly editing qpos is a common source of misleading diagnostics.

A short simulation loop can record one row for every physics step, then resample for a plotting or control loop. Keep the raw step-level data so aliasing and event timing can be reconstructed later.

Define initialization, stepping, logging and reset explicitly; keep the test small enough to audit line by line.

The quickest way to uncover an implementation mistake is to reduce the model to one body, one joint or one contact and compare it with a calculation we can do by hand. Preserve this small reference so later asset edits cannot break it silently.

The package should run without a visible editor or manual clicks. If there is an unexpected result, a single script ought to print the physical quantity, units, model version and input conditions that would let somebody else reproduce it.

If those checks disagree, stop and fix the assumption before continuing.

## 08 · Debug visualization and logging

Our next diagnostic is debug visualization and logging. A simulation that looks correct but lacks recorded state is hard to validate or reproduce. Logging should preserve enough evidence to diagnose frame, physics and control errors.

Record numerical units and clock semantics with every field. Use reproducible scene seeds and log actual engine parameters, not just requested high-level configuration.

We're going to test this rather than treat it as a cosmetic adjustment. Overlay tool-center trajectory, contact normals and measured reference positions in an offline plot while replaying the visual simulation. Make discrepancies visible, not smoothed away.

Video can omit hidden instability, intermittent constraint violations or motor saturation. At least one metric should expose each failure class we claim to test.

Use site names for important fiducials and tool-center frames. Naming a probe once in the model keeps every regression plot and collision diagnostic tied to the same physical location.

A clean log schema and stable naming conventions become part of the delivered robot asset.

The package should run without a visible editor or manual clicks. If there is an unexpected result, a single script ought to print the physical quantity, units, model version and input conditions that would let somebody else reproduce it.

As the model animates, distinguish authored MJCF values from compiled engine state and from derived quantities in MjData. Those categories correspond to different debugging questions; one is the model specification, one is the current experiment, and one is an inferred consequence.

That is how a visually convincing demonstration becomes an experimentally defensible claim.

## 09 · Calibration and regression tests

In this scene, calibration and regression tests is our focus. Once the robot model runs, freeze a baseline that independent tests can challenge. Kinematic accuracy alone does not validate inertia, friction or impact response.

Group tests by physical mechanism: free motion, gravity sag, controlled torque, first contact, sticking, sliding and grasp. Vary one well-observed parameter group at a time.

Watch the animation carefully as we change only one part of the setup. Execute a reference set and a held-out set from separate physical trials. For every case, report trajectory error, latency and task outcome using the same alignment procedure.

Never grade only on the experiments used to select parameters. A model can overfit beautifully and transfer badly.

Regression tolerances should be expressed in physical units such as millimeters, radians and newton-seconds. A change in a solver default may cause a tiny pixel difference but a meaningful contact-force difference.

Turn the highest-value failure cases into automated nightly checks that run against the packaged MJCF.

As the model animates, distinguish authored MJCF values from compiled engine state and from derived quantities in MjData. Those categories correspond to different debugging questions; one is the model specification, one is the current experiment, and one is an inferred consequence.

The quickest way to uncover an implementation mistake is to reduce the model to one body, one joint or one contact and compare it with a calculation we can do by hand. Preserve this small reference so later asset edits cannot break it silently.

The goal is an engineering test that can fail for an understandable reason.

## 10 · Shipping a defensible MJCF asset

Let's look at shipping a defensible mjcf asset using a real-to-sim experiment. The deliverable is more than robot.xml. It is an auditable package with meshes, configuration, test fixtures, environment assumptions and a clear map to physical evidence.

Capture the MuJoCo version, mesh provenance, body hierarchy, actuator semantics, sensing configuration, units, collision masks and all custom defaults. Keep model files and test data together but avoid embedding secrets or unnecessary recordings.

The important thing here is to separate an observation from an explanation. Create one command that loads and simulates the robot in a neutral pose, and a second command that checks the trajectory and contact regressions.

A dependency that only exists in one developer’s home directory is a deployment defect, even if the original demo succeeded.

Asset releases should have a manifest and hash list so that the simulator, mesh files, configuration and regression inputs cannot silently drift between machines. Version the experiment rather than only the robot mesh.

Ship versioned source assets, reproducible scripts, complete metrics and documented limitations so another researcher can challenge the model.

The quickest way to uncover an implementation mistake is to reduce the model to one body, one joint or one contact and compare it with a calculation we can do by hand. Preserve this small reference so later asset edits cannot break it silently.

The package should run without a visible editor or manual clicks. If there is an unexpected result, a single script ought to print the physical quantity, units, model version and input conditions that would let somebody else reproduce it.

Notice that the image is evidence of a hypothesis, not a substitute for measurement.