From 9f51ba50db503b98b978d132b229ba5ec03d0a01 Mon Sep 17 00:00:00 2001 From: Yuval Tassa Date: Thu, 14 Nov 2024 03:44:42 -0800 Subject: [PATCH] Fix field ordering in `mjModel`. `nnames_map` is not required for `mjModel` construction, it is set during construction. PiperOrigin-RevId: 696462793 Change-Id: Ie722e2a04d7fd7ed96634d3304cc94e895ed713b --- doc/includes/references.h | 8 ++++---- include/mujoco/mjmodel.h | 8 ++++---- introspect/structs.py | 14 +++++++------- unity/Runtime/Bindings/MjBindings.cs | 2 +- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/doc/includes/references.h b/doc/includes/references.h index 0f8d869a..4d4c6b98 100644 --- a/doc/includes/references.h +++ b/doc/includes/references.h @@ -948,10 +948,10 @@ struct mjModel_ { int nuser_actuator; // number of mjtNums in actuator_user int nuser_sensor; // number of mjtNums in sensor_user int nnames; // number of chars in all names - int nnames_map; // number of slots in the names hash map int npaths; // number of chars in all paths - // sizes set after mjModel construction (only affect mjData) + // sizes set after mjModel construction + int nnames_map; // number of slots in the names hash map int nM; // number of non-zeros in sparse inertia matrix int nB; // number of non-zeros in sparse body-dof matrix int nC; // number of non-zeros in sparse reduced dof-dof matrix @@ -959,8 +959,8 @@ struct mjModel_ { int ntree; // number of kinematic trees under world body int ngravcomp; // number of bodies with nonzero gravcomp int nemax; // number of potential equality-constraint rows - int njmax; // number of available rows in constraint Jacobian - int nconmax; // number of potential contacts in contact list + int njmax; // number of available rows in constraint Jacobian (legacy) + int nconmax; // number of potential contacts in contact list (legacy) int nuserdata; // number of mjtNums reserved for the user int nsensordata; // number of mjtNums in sensor data vector int npluginstate; // number of mjtNums in plugin state vector diff --git a/include/mujoco/mjmodel.h b/include/mujoco/mjmodel.h index 9bea5917..3cc59311 100644 --- a/include/mujoco/mjmodel.h +++ b/include/mujoco/mjmodel.h @@ -655,10 +655,10 @@ struct mjModel_ { int nuser_actuator; // number of mjtNums in actuator_user int nuser_sensor; // number of mjtNums in sensor_user int nnames; // number of chars in all names - int nnames_map; // number of slots in the names hash map int npaths; // number of chars in all paths - // sizes set after mjModel construction (only affect mjData) + // sizes set after mjModel construction + int nnames_map; // number of slots in the names hash map int nM; // number of non-zeros in sparse inertia matrix int nB; // number of non-zeros in sparse body-dof matrix int nC; // number of non-zeros in sparse reduced dof-dof matrix @@ -666,8 +666,8 @@ struct mjModel_ { int ntree; // number of kinematic trees under world body int ngravcomp; // number of bodies with nonzero gravcomp int nemax; // number of potential equality-constraint rows - int njmax; // number of available rows in constraint Jacobian - int nconmax; // number of potential contacts in contact list + int njmax; // number of available rows in constraint Jacobian (legacy) + int nconmax; // number of potential contacts in contact list (legacy) int nuserdata; // number of mjtNums reserved for the user int nsensordata; // number of mjtNums in sensor data vector int npluginstate; // number of mjtNums in plugin state vector diff --git a/introspect/structs.py b/introspect/structs.py index 0d5107fd..bed95997 100644 --- a/introspect/structs.py +++ b/introspect/structs.py @@ -1148,16 +1148,16 @@ STRUCTS: Mapping[str, StructDecl] = dict([ type=ValueType(name='int'), doc='number of chars in all names', ), - StructFieldDecl( - name='nnames_map', - type=ValueType(name='int'), - doc='number of slots in the names hash map', - ), StructFieldDecl( name='npaths', type=ValueType(name='int'), doc='number of chars in all paths', ), + StructFieldDecl( + name='nnames_map', + type=ValueType(name='int'), + doc='number of slots in the names hash map', + ), StructFieldDecl( name='nM', type=ValueType(name='int'), @@ -1196,12 +1196,12 @@ STRUCTS: Mapping[str, StructDecl] = dict([ StructFieldDecl( name='njmax', type=ValueType(name='int'), - doc='number of available rows in constraint Jacobian', + doc='number of available rows in constraint Jacobian (legacy)', ), StructFieldDecl( name='nconmax', type=ValueType(name='int'), - doc='number of potential contacts in contact list', + doc='number of potential contacts in contact list (legacy)', ), StructFieldDecl( name='nuserdata', diff --git a/unity/Runtime/Bindings/MjBindings.cs b/unity/Runtime/Bindings/MjBindings.cs index 32e58267..358787c1 100644 --- a/unity/Runtime/Bindings/MjBindings.cs +++ b/unity/Runtime/Bindings/MjBindings.cs @@ -5238,8 +5238,8 @@ public unsafe struct mjModel_ { public int nuser_actuator; public int nuser_sensor; public int nnames; - public int nnames_map; public int npaths; + public int nnames_map; public int nM; public int nB; public int nC;