﻿# MuJoCo Jacobians: quaternion positions do not define velocity-vector columns

Map MuJoCo Jacobian columns to tangent-space degrees of freedom instead of raw qpos offsets when a model contains ball or free joints.

Author: Retrivium team
Updated: 2026-11-06
Canonical URL: https://retrivium.ai/journal/simulation-mujoco-jacobian-quaternion-nq-nv-tangent/
Language: en

## A position offset is not always a velocity offset

A twin controller multiplies an end-effector Jacobian by a velocity vector assembled using qpos indices. The adapter works for a hinge-only model, then fails after adding a floating base. The new model has quaternion configuration coordinates whose storage is not the velocity coordinate system. Diagnose the representation boundary before changing controller gains. A matrix can have plausible numeric entries while its columns are associated with the wrong motion coordinates.

## Distinguish configuration from its tangent space

The [MuJoCo Jacobian guide](https://mujoco.readthedocs.io/en/3.3.7/programming/simulation.html) distinguishes configuration size nq from tangent-space size nv. Quaternion joints make those dimensions differ. A kinematic Jacobian maps generalized velocities to spatial motion, so its columns follow velocity degrees of freedom. They are not independent derivatives with respect to every stored quaternion component treated as an unconstrained scalar. Preserve joint-specific position and velocity addressing rather than assuming a single shared offset table for both arrays.

## Use position operations that respect quaternions

The [function reference](https://mujoco.readthedocs.io/en/3.3.7/APIreference/APIfunctions.html) provides mj_integratePos for applying a qvel-format displacement to qpos and mj_differentiatePos for recovering a qvel-format difference between configurations. These functions respect quaternion representation. Renormalizing an arbitrary component-wise perturbation is not the same as deliberately choosing a unit tangent direction for a particular degree of freedom. Establish the intended generalized-velocity basis first; then perturb position through the supported operation when checking a Jacobian column.

## Build a basis-direction diagnostic

A proposed fixture should include both an ordinary scalar joint and a quaternion joint. At a declared configuration, select a velocity basis direction, create nearby configurations with manifold-aware integration and recompute the relevant spatial point. Compare the finite-difference displacement with the matching Jacobian column under a stated perturbation convention. Keep spatial frame and rotation-difference convention explicit. This is a numerical verification procedure, not evidence that a controller has been tested on a real robot.

## Check semantics as well as matrix shape

Acceptance records should retain model revision, joint names, qpos and velocity addressing, Jacobian shape and the selected point and body. A shape assertion catches some errors but cannot detect swapped velocity columns of equal size. Inspect signed responses for named basis directions. Refresh the required derived state before comparing quantities at the same configuration. Do not compare a Jacobian from before integration with a point sampled afterward and then diagnose the difference as quaternion arithmetic failure.

## Keep local linearization within its scope

A valid Jacobian describes a local relationship under the chosen model and frame. It does not establish a collision-free finite motion or guarantee behavior near singularities. The [Quest geometry article](/journal/quest-passthrough-camera-local-detection-world-rays/) provides related pose-context reasoning; [software reproducibility](/journal/software-stack-reproducibility/) supports preserving the model and adapter. The concrete acceptance result is correct mapping between tangent coordinates and Jacobian columns, followed by separately justified trajectory and controller checks.
