Newton API Prototype · Mimic Joint Design

Newton Mimic Joints

A design note on whether mimic relationships should be modeled as Newton joints, constraints, or compact coordinate relations. The emphasis is Model parameterization, benchmark evidence, and practical implementation tradeoffs.

Executive summary

Best semantic model

Mimic followers are kinematic joints in the body tree: they have parent/child bodies, fixed parent/child frames, labels, world membership, and enabled state. Reusing those existing joint attributes is a real win.

State-reducing option

If mimics are represented as joints, zero-DOF followers are the only variant that removes redundant generalized coordinates. Same-DOF followers are effectively normal joints plus a mimic constraint.

Practical verdict

Support scalar DOF-to-DOF mimic first. Treat vector/multi-DOF mimic as multiple scalar relations unless a real asset requires a matrix-valued map. Existing MJCF, PhysX USD, and Menagerie evidence all point that way.

Numerically, the benefit comes from eliminating follower state: zero-DOF joint-based import reduces Robotiq generalized coordinates from 6 to 1 in the synthetic URDF and 14/12 to 6/6 in imported Robotiq models, improving FK by 30–40% on those assets. A same-DOF mimic keeps those follower coordinates, so it mostly becomes the separate-constraint prototype. Multi-DOF mimic should not be a special vector joint initially: MuJoCo, PhysX USD, and scanned assets use scalar per-axis couplings.

Prototype branch: eric-heiden/newton · mimic-constraint at aa76da85.

How a mimic joint should be parameterized in Model

A mimic relation is the scalar affine equation q_follower = offset + multiplier * q_leader. To make it a Newton joint without inflating generalized state, the follower should be a zero-DOF joint that derives its effective coordinate during FK/IK/state transfer.

Why zero DOF instead of matching the leader DOF count?

A same-DOF mimic is a valid design, but it changes what we are optimizing for. If the follower has the same coordinate and velocity slots as the leader, Newton can reuse all per-DOF arrays normally: joint_axis, limits, target gains, armature, friction, effort limits, and control slots all exist. That makes parameterization easy and avoids the zero-DOF metadata problem.

The cost is that the follower is no longer derived state. It has its own joint_q, joint_qd, controls, forces, limits, and solver unknowns. The affine mimic relation then has to be enforced as an equality/constraint or by overwriting the follower state before every consumer. If enforced as a constraint, the follower can drift unless the solver stabilizes it. If overwritten, the extra DOF rows are dead storage and any user-written controls/forces on those rows become ambiguous.

The eric/mimic-constraint prototype at aa76da85 is the same-DOF/separate-constraint model: URDF import creates the follower as a normal joint, then adds constraint_mimic_joint0/joint1/coef0/coef1. The branch does not add JointType.MIMIC, and no solver/FK kernels consume constraint_mimic_* yet. Metadata creation is covered by targeted tests (Ran 4 tests in 0.202s: OK); full mimic test discovery was blocked by dependency issues, documented in prototype_investigation.json.

Reuse existing joint attributes

No-extra-array encoding using existing fields

The most aggressive encoding is type-dependent overloading for JointType.MIMIC:

This is genuinely attractive if we only care about the affine dependency: it needs no new arrays and the lookup is direct. However it changes two important Model invariants. First, joint_parent is currently a body index used by topology, FK, articulation construction, body filtering, and import/export; using it as a joint index means any code that needs the follower's parent body must recover it elsewhere. Second, joint_target_ke and joint_target_kd are per-DOF arrays today, while a zero-DOF mimic has no DOF slot. Making joint_target_ke[j] work would require either changing those arrays to joint frequency, adding a fake metadata DOF, or defining an exception where mimic joints index target arrays by joint id. Those are API changes even though they avoid new array names.

Can joint_axis store offset and multiplier?

It can only work as another documented overload, and it is weaker than using joint_target_ke/kd. The tempting layout is joint_parent[j] as the leader joint index and joint_axis[j].x/y as offset/multiplier. That uses the two useful floats in the existing wp.vec3 and leaves z unused or available for a future scalar flag.

The blocker is the current Newton invariant: joint_axis is not joint-frequency metadata. It is a per-DOF array indexed from joint_qd_start; the docs explicitly say it has length joint_dof_count. A zero-DOF mimic joint therefore has no legal axis slot. Storing coefficients at joint_axis[j] would be unsafe because joint index and DOF index are different spaces: fixed joints have zero slots, free/D6 joints have multiple slots, and j can either collide with another joint's real axis or exceed joint_dof_count.

Adding a fake axis row would also not be free. If the fake row increments joint_dof_count, the mimic is no longer a true zero-DOF joint and it perturbs every per-DOF array. If the row does not increment joint_dof_count, Newton needs a second indexing rule or a separate metadata count, which is effectively a new schema rule hidden behind an old name.

Practical recommendation

If Newton is comfortable with explicit type-dependent semantics, the target-gain overload is the better no-new-array encoding for scalar mimic joints: document that for JointType.MIMIC, joint_parent means leader joint and target stiffness/damping mean offset/multiplier. I would not use joint_axis for coefficients unless Newton is already willing to split axis metadata away from DOF storage. If we want to preserve global invariants that joint_parent is always a body index and per-DOF arrays are always per DOF, then the dependency has to live somewhere else. In that case the compact generic relation table remains preferable to dense mimic-specific arrays.

Design alternatives compared

This is the decision center of the report. Green options preserve the most useful Model invariants or measured wins; yellow options are workable but require clear tradeoffs; red options add hidden complexity or redundant state.

RecommendedViable with caveatsAvoid

ApproachModel shapeProsConsWhen to choose
Caveat Separate mimic constraintsKeep constraint_mimic_joint0/joint1/coef0/coef1; follower is still a normal DOF joint.Compact storage; matches constraint semantics; no new joint type; solver lowering already natural.Duplicates kinematic topology; import/export/FK must special-case an out-of-tree relation; generalized state includes follower DOFs unless separately suppressed.Choose if Newton wants zero Model API churn and solver constraint semantics are the priority.
Caveat Same-DOF mimic joint / prototype constraintFollower remains a normal joint with its own DOF rows; constraint_mimic_joint0/joint1/coef0/coef1 enforce q0 = coef0 + coef1*q1.All existing per-DOF arrays are valid; joint_axis and target arrays can be reused without fake slots; multi-DOF extension is straightforward if coefficients are scalar-per-DOF or vectorized.No generalized-state reduction; needs solver/FK enforcement; follower controls/forces are ambiguous; current prototype stores metadata but does not enforce it in kernels.Choose if the goal is minimal importer/API disruption and constraint semantics, not if the goal is state reduction or treating mimics as derived kinematic joints.
Caveat No-extra-array overloadJointType.MIMIC; joint_parent stores leader joint; joint_target_ke/kd store offset/multiplier for mimics.No new Model arrays; direct leader lookup; comparable traversal speed to dense mimic arrays; simple importer surface.Overloads joint_parent from body index to joint index; target arrays are per DOF today, but zero-DOF mimics have no DOF slot; follower axis/type inference may be insufficient for all formats.Choose only if Newton accepts documented type-dependent field semantics for JointType.MIMIC.
Avoid Joint-axis coefficient overloadJointType.MIMIC; joint_parent stores leader joint; joint_axis.x/y store offset/multiplier.No new named arrays; two coefficients fit in an existing vec3; traversal cost is similar to other dense overloads.joint_axis is currently per DOF, not per joint; zero-DOF mimics have no axis slot; fake slots would perturb joint_dof_count or require hidden indexing rules; coefficients are semantically not axes.Mostly avoid. Only consider if Newton intentionally redefines joint_axis as joint metadata for mimic rows.
Prototype Current branch: dense mimic joint attrsJointType.MIMIC plus joint_mimic_* arrays of length joint_count.Simple kernels; no separate lookup table; passes mimic tests; clean FK topology.Adds four permanent mimic-only arrays to every Model; sparse assets pay storage/cache cost; hard to justify if no other joint type uses these fields.Good prototype; questionable production API.
Recommended Joint + generic relation tableJointType.MIMIC owns one or more compact scalar AFFINE_COORD relation rows, optionally grouped by key for multi-DOF mechanisms.Preserves existing field invariants; compact; names are not mimic-specific; matches MJCF/PhysX scalar coupling patterns; supports future coupled/derived joints.Requires one new generic table and one indirection from joint to relation rows.Best invariant-preserving design, especially if Newton wants scalar-per-axis multi-DOF mimic support.
Avoid Virtual axis slot in existing arraysPermit zero-DOF joints to have an axis metadata row outside joint_dof_count.Reuses joint_axis conceptually for follower axis.Breaks the current invariant that joint_axis is per DOF; touches many kernels; still needs leader and affine coefficients.Not recommended unless Newton is already splitting axis metadata from generalized DOFs.

Multi-DOF mimic joints and schema evidence

Practical assets and interchange schemas do not justify a first-class vector-valued mimic relation yet: there are many coupled mechanisms, but the practical representation is almost always a set of scalar DOF-to-DOF relations. Raw notes: schema research JSON and MuJoCo Menagerie scan JSON.

MuJoCo MJCF

equality/joint constrains one hinge/slide coordinate to a quartic polynomial of another hinge/slide coordinate. It explicitly excludes ball/free joints. equality/tendon can couple scalar tendon lengths, and fixed tendons can be linear combinations of scalar hinge/slide joints.

USD / PhysX

Core UsdPhysics has joints, per-axis limits, per-axis drives, and collision filtering, but no mimic schema. NVIDIA PhysX USD adds PhysxMimicJointAPI, applied per target axis with a reference joint, reference axis, gearing, and offset.

Asset evidence

A scan of MuJoCo Menagerie at b846dd12 found 209 equality/joint constraints in 22 assets: 187 hinge-hinge, 10 slide-hinge, and 12 slide-slide. No ball/free/vector mimic constraints were found.

What counts as multi-DOF in practice?

Assets such as ms_human_700, iit_softfoot, toddlerbot_2xc/2xm, and hello_robot_stretch have mechanisms that feel multi-DOF at the component level: knees with translations and rotations, shoulder/scapula couplings, multi-link phalanx chains, geared humanoid joints, and telescoping arm segments. But they are authored as multiple scalar equations, not as one relation q_follower_vector = A q_leader_vector + b.

Recommended Newton representation

Use a scalar relation row as the primitive: target_joint, target_dof, source_joint, source_dof, offset, multiplier, plus optional polynomial coefficients if Newton wants to preserve MuJoCo's quartic equality exactly. A multi-DOF mimic is then just a group of scalar rows sharing a group id/key. This matches PhysX USD's multiple-apply mimic API and MuJoCo's scalar equality model, and it avoids inventing matrix-valued metadata before an asset needs it.

For zero-DOF derived joints, each scalar row derives one follower coordinate from one leader coordinate. For same-DOF constraints, each row contributes one scalar residual. For true vector maps, Newton could later add a relation-table extension with compressed row blocks or a dense/sparse matrix, but that should be a second step rather than the default mimic API.

Do we currently handle it?

The current eric/mimic-constraint prototype only stores one scalar coef0/coef1 pair per mimic constraint between two joint indices. Its docstring says multi-DOF joints are supported by applying the same scalar coefficients to all DOFs, but the stored Model data has no target DOF index, source DOF index, per-axis coefficient vector, or matrix. Also, no FK/solver kernels consume constraint_mimic_* yet. So the prototype handles scalar metadata creation, but it does not yet robustly implement multi-DOF mimic semantics.

Real Newton asset benchmarks

Branch-vs-main benchmark data: branch JSON and main JSON. The important signal is where mimic representation changes state size: Robotiq-style assets get smaller and faster; unrelated assets mostly show noise.

FK and state-size results

AssetJointsBranch coords / DOFsMain coords / DOFsBranch mimic joints / constraintsMain mimic joints / constraintsBranch FKMain FKBranch vs main
LEAP hand MJCF1716 / 1616 / 160 / 00 / 0370.3 us324.6 us+14.1%
Robotiq 2F85 MJCF116 / 614 / 120 / 00 / 1342.1 us490.1 us-30.2%
Robotiq 2F85 USD116 / 614 / 120 / 00 / 1316.4 us460.5 us-31.3%
Shadow hand MJCF2524 / 2424 / 240 / 00 / 0332.9 us339.7 us-2.0%
Synthetic Robotiq URDF71 / 16 / 65 / 00 / 5305.0 us509.9 us-40.2%
Unitree G1 with hands URDF5343 / 4343 / 430 / 00 / 0384.4 us308.0 us+24.8%

Interpretation: the performance win appears exactly where mimic followers remove generalized coordinates. Robotiq assets improve 30–40% in FK. Assets without mimics are neutral or noisy; the branch does not provide a general speedup independent of mimic state reduction.

Solver step results

AssetSemi-ImplicitXPBDFeatherstoneVBDMuJoCo
LEAP hand MJCF184.6 us (+8.6%)609.3 us (+17.1%)4365.0 us (+0.7%)4437.0 us (+12.2%)4325.4 us (+9.4%)
Robotiq 2F85 MJCF189.6 us (+17.9%)702.3 us (+39.7%)829.1 us (+0.8%)3947.4 us (-25.2%)ValueError: Error: mass and inertia of mov
Robotiq 2F85 USD159.4 us (+6.1%)503.6 us (+9.2%)815.3 us (+1.4%)4383.3 us (-10.2%)15423.0 us (-48.5%)
Shadow hand MJCF176.6 us (+5.6%)496.8 us (-9.1%)13429.4 us (+0.5%)4107.8 us (+2.5%)ValueError: Error: mass and inertia of mov
Synthetic Robotiq URDF169.1 us (-6.0%)513.4 us (+1.0%)530.0 us (+1.2%)NotImplementedError: SolverVBD rigid jointValueError: Error: mass and inertia of mov
Unitree G1 with hands URDF174.9 us (+43.5%)498.6 us (+28.5%)107075.3 us (+0.5%)3947.8 us (+5.5%)ValueError: Error: mass and inertia of mov

Solver interpretation: semi-implicit, XPBD, Featherstone, and VBD timings are mostly dominated by solver implementation and asset size rather than mimic representation. MuJoCo's Robotiq USD row improves from 29.9 ms to 15.4 ms after lowering the zero-DOF mimic representation to MuJoCo's equality format. VBD still rejects the synthetic rigid JointType.MIMIC case, so full solver parity is not yet achieved.

Parameterization microbenchmark

This microbenchmark isolates Model metadata traversal and storage overhead across the parameterization choices: script and raw JSON. It is not a solver benchmark; it answers which representation adds hidden bookkeeping cost before physics even runs.

Best invariant-preserving choiceCompact relation table

Scales with mimic count and keeps joint/body/DOF indexing rules clean.

Fastest no-new-array ideaTarget ke/kd overload

Cheap storage, but only if Newton accepts type-dependent field semantics.

Prototype-compatible pathSame-DOF + constraint

Easy to parameterize, but keeps redundant follower state.

Weakest encodingJoint-axis overload

Confuses per-DOF axis storage with joint-level mimic metadata.

CaseBaseline FK loopDense mimic arraysTarget ke/kd overloadJoint-axis coefficientsSame-DOF + constraintCompact relation tableSeparate constraint passMetadata/state bytes dense / target / axis / same-DOF / compact / separate
synthetic robotiq like12994.5 us18369.2 us (+41.4%)16794.7 us (+29.2%)17218.8 us (+32.5%)28180.0 us (+116.9%)19805.9 us (+52.4%)21733.8 us (+67.3%)196 / 0 / 0 / 500 / 140 / 120
robotiq imported like12106.4 us15990.7 us (+32.1%)15848.5 us (+30.9%)16278.1 us (+34.5%)27116.0 us (+124.0%)17530.7 us (+44.8%)18885.5 us (+56.0%)420 / 0 / 0 / 800 / 224 / 192
hand 24dof sparse mimic18422.1 us22323.1 us (+21.2%)22364.9 us (+21.4%)22400.6 us (+21.6%)23647.2 us (+28.4%)20372.9 us (+10.6%)22274.6 us (+20.9%)896 / 0 / 0 / 400 / 112 / 96
humanoid 43dof sparse mimic27661.7 us40900.0 us (+47.9%)34198.1 us (+23.6%)34320.2 us (+24.1%)32260.3 us (+16.6%)29317.2 us (+6.0%)31146.4 us (+12.6%)1792 / 0 / 0 / 600 / 168 / 144
large batched 10pct mimic43409.2 us53155.7 us (+22.5%)53167.9 us (+22.5%)53411.1 us (+23.0%)51956.3 us (+19.7%)46880.7 us (+8.0%)48894.9 us (+12.6%)28672 / 0 / 0 / 10200 / 2856 / 2448

Takeaway: the compact relation table is the cleanest general-purpose design because it scales with the number of mimic relations and preserves Model invariants. The target-gain overload is the best no-new-array option, but its zero-storage win comes from accepting type-dependent semantics. Same-DOF + constraint is implementation-friendly but gives up the state-size win. The joint-axis overload should be avoided because it mixes DOF-axis storage with joint-level relation metadata.

Asset behavior videos

These videos show the imported hands and grippers used in the benchmark set, including the Robotiq mimic cases where follower coordinates are removed.

Robotiq 2F85 USD
Robotiq 2F85 MJCF
LEAP hand MJCF
Shadow hand MJCF
Unitree G1 with hands URDF

Validation

Passed: the earlier mimic-joint prototype passed 23 mimic-related tests in 17.395 s.

Passed: eric/mimic-constraint at aa76da85 passed 4 targeted metadata tests in 0.202 s. Full mimic discovery was blocked by environment/dependency issues, not by assertion failures; see prototype_investigation.json.

Conclusion

Same-DOF mimics answer the parameterization problem but not the original modeling problem: they are normal joints with an added relation, so they keep redundant state and require enforcement. That matches the current constraint_mimic_* prototype. Multi-DOF evidence argues for scalar rows, not a matrix-valued mimic joint: MJCF equality/joint is hinge/slide only, PhysX USD mimic is per-axis, and Menagerie's 209 equality joint constraints are all scalar. If Newton wants mimic followers to be derived kinematic joints and keep the Robotiq state-size/FK wins, they should be zero-DOF with scalar per-axis relation rows. For zero-DOF mimics, the no-extra-array target-gain overload is viable only as a documented JointType.MIMIC exception; I still prefer a compact generic relation table if preserving Model invariants matters. If Newton prefers constraint semantics and minimal API disruption, keep the same-DOF/separate-constraint prototype but add explicit source/target DOF indices and enforcement.

Last updated: 2026-05-30 16:11:45 UTC