robot — GiordanoRobot kinematics / dynamics (Pinocchio)
Purpose
One Pinocchio-backed model object that turns a state
(q, v)into the whole coordinated-control
tower: frames + CoM (self.motion) and the dynamics matricesΓ, Γ⁻¹, Γ̇, M̂, Ĉ, M̆, C̆, J⊕,
the dampedJ⊕inverse, and the 7-DOF nullspace basis (self.dyn). The equations live here, not
in the controllers — the controllers only readself.dyn.*/self.motion.*.
Role in the system
- Owned by the control root com_controller (
CC_Controller) and consumed by breve_controller
asself.dyn.*(Γ,M̆,C̆,s_min_G, dampedJ⊕) andself.motion.*(frames,Gblocks). - The guidance tower (ee_guidance → base_guidance → com_guidance) and
analytic_feedforward read the sameself.motioncache through the controller. - Calls sampling (the module-level
sigma_min_and_cond,Sampling.best_sample, the γ ramp) and geometry
(as_col3,cross,as_flat); loads the model from the single UR3 MJCF via parameter_loader.
Inputs / Outputs
- In: state
(q, v); config (robot,config_sampling.j_plus,controller.arm.null_space). - Out:
self.motion(frames, CoM,G_ωb,G_vc, breve blocks) andself.dyn
(M, M̂, M̆, C, Ĉ, C̆, C_c, Γ, Γ⁻¹, Γ̇, J⊕, J_inv, s_min_G, s_min_J, κ_G, κ_J, plusk_hat, z_a).
Key methods
all_dynamics_terms— single pass FK → Γ → Γ⁻¹ → Ĉ → Ĵ → nullspace; cachesself.dyn—utils/robot.py:270all_motion_terms— single FK pass building every kinematic /G-block term; cachesself.motion—:128damped_inverse— 3-tierJ⊕inverse (exact/MP → Tikhonov → hold-last) —:217;regularized_svd— the Tikhonov tier —:249Gamma/J_plus— standaloneΓ(q)/J⊕(q)at zero velocity (used by the σ_min sampler) —:260/:264twist— frame twist[v; ω]in local / world / lwa —:114;update— drive Pinocchio FK + CoM —:104choose_q_init_by_sigma— random-search a well-conditioned initial arm config —:408K_ELBOW_LAW = 0.107— bare-arm singular-law slopeσ_min ≈ K·|sin θ₃|(class const,:69).
Footguns
The 7-DOF nullspace basis must FREEZE near a singularity
n_hat = ker(J⊕)needs the full SVD (the economy SVD drops the null vector). Below
null_space.freeze_floorthe kernel direction swings up to 69°/step atσ₆ ~ 1e-3, so the code
reuseslast_n_hat / k_hat / z_ainstead — trading exactM-orthogonality for directional
stability (same philosophy aslast_J_plus_inv).n_hatis a direction, not an orientation:
a sign-continuity flip keeps it from jumping. (utils/INSIGHTS.md[singularity], R1 review.)
damped_inverseis three tiers, each baseline-protectedAbove
soft_floor: exactinvfor squareJ(the byte-exact 6-DOF path) or Moore-Penrose for wide
J. Betweensoft_floorandhard_floor: Tikhonov withλ = max(damping, soft_floor − σ_min).
At/belowhard_floor(or any non-finite / over-norm result): returnlast_J_plus_invunchanged.
The four knobs arej_plus.{hard_floor, soft_floor, damping, inv_norm_max}. (utils/INSIGHTS.md[singularity]/[config].)
q0_epsperturbation is a PLANT initial condition only
_apply_q0_perturbationoffsets the arm joints by magnitudeq0_eps[rad] along a frozen-seed
direction (_Q0_DIR_SEED = 20260617); the free-flyer quaternion slots stay 0 andq0_eps = 0.0is a
byte-identical no-op. It seeds the plantq0— it cannot bias the reference trajectory.
(utils/INSIGHTS.md[history].)
_deterministic_q_initmoves BOTH vanishing det factors off zeroThe opt-in RNG-free seed sets elbow
θ₃and wristθ₅from the bare-arm law
σ_min ≈ K_ELBOW_LAW·|sin θ₃|(K_ELBOW_LAW = 0.107, cpin-verified).det.target_sigmais the
bare-arm target; the full Γ lands ~0.8× that, still above the floor. Default OFF → the shipped
random search (byte-identical). (utils/INSIGHTS.md[math].)
Pseudocode (one all_dynamics_terms call)
m = all_motion_terms(q, v) # FK + frames + CoM + G blocks (one Pinocchio pass)
M, Jv_bar = crba; COM Jacobian # base-frame mass matrix + CoM Jacobian
J⊕ = J_nu_e - R_eb0·Jv_bar # CoM-referenced EE Jacobian
return early if return_J / return_G # the σ_min sampler reuses this same FK pass
J_inv = damped_inverse(J⊕) # 3-tier (exact / Tikhonov / hold-last)
Γ, Γ⁻¹, Γ̇ from m + J⊕ + J_inv # the coordinated map and its rate
M̂ = Γ⁻¹ᵀ M Γ⁻¹ ; Ĉ = Γ⁻¹ᵀ(C − P·Γ̇)Γ⁻¹ # reduced inertia + Coriolis; M̆/C̆ = lower-right blocks
if n > 6: nullspace (n_hat, k_hat, z_a), FROZEN below freeze_floor
cache self.dyn ; return
Equations & references
Key equations mirrored from current_sota — the math source of truth; see there for derivations.
The coordinated map — current_sota §2.4, eq (2.4):
Reduced (circumcentroidal) equations of motion — §3, eq (3.4):
Damped inverse (three-tier) — §6.4, eq (6.5):
References:
- Coordinated map
Γ+ circumcentroidal velocities (§2) and reduced EoMM̂/Ĉ(§3):
current_sota > 2 · current_sota > 3. - Singularity handling — damped
J⊕, conditioning ramp, nullspace freeze (§6): current_sota > 6. - eq↔code cross-check:
generated_reports/GNC/cross_check.md; bare-arm singular law derivation:
generated_reports/math/singularity_geometry.md.
Related
breve_controller · com_controller · sampling · geometry · parameter_loader · analytic_feedforward · terminology · tikhonov_regularization · com_vs_base · coupled_dynamics