Put sparsity structures in mjModel, don't use them yet.

PiperOrigin-RevId: 795032051
Change-Id: I75c69e881980ff9c308acf00bb3a65f4b2ef12f5
This commit is contained in:
Yuval Tassa
2025-08-14 07:36:59 -07:00
committed by Copybara-Service
parent f077fd00a9
commit 7eb13777f8
9 changed files with 404 additions and 178 deletions
+19 -4
View File
@@ -654,6 +654,10 @@ struct mjModel_ {
int nbvhdynamic; // number of dynamic bounding volumes (aabb stored in mjData)
int noct; // number of total octree cells in all meshes
int njnt; // number of joints
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
int nD; // number of non-zeros in sparse dof-dof matrix
int ngeom; // number of geoms
int nsite; // number of sites
int ncam; // number of cameras
@@ -717,10 +721,6 @@ struct mjModel_ {
// 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
int nD; // number of non-zeros in sparse dof-dof matrix
int nJmom; // number of non-zeros in sparse actuator_moment matrix
int ntree; // number of kinematic trees under world body
int ngravcomp; // number of bodies with nonzero gravcomp
@@ -1222,6 +1222,21 @@ struct mjModel_ {
// paths
char* paths; // paths to assets, 0-terminated (npaths x 1)
// sparse structures
int* B_rownnz; // body-dof: non-zeros in each row (nbody x 1)
int* B_rowadr; // body-dof: row addresses (nbody x 1)
int* B_colind; // body-dof: column indices (nB x 1)
int* M_rownnz; // reduced inertia: non-zeros in each row (nv x 1)
int* M_rowadr; // reduced inertia: row addresses (nv x 1)
int* M_colind; // reduced inertia: column indices (nC x 1)
int* mapM2M; // index mapping from qM to M (nC x 1)
int* D_rownnz; // full inertia: non-zeros in each row (nv x 1)
int* D_rowadr; // full inertia: row addresses (nv x 1)
int* D_diag; // full inertia: index of diagonal element (nv x 1)
int* D_colind; // full inertia: column indices (nD x 1)
int* mapM2D; // index mapping from qM to D (nD x 1)
int* mapD2M; // index mapping from D to qM (nM x 1)
// compilation signature
uint64_t signature; // also held by the mjSpec that compiled this model
};
+18 -5
View File
@@ -77,6 +77,10 @@
X( nbvhdynamic ) \
X( noct ) \
X( njnt ) \
X( nM ) \
X( nB ) \
X( nC ) \
X( nD ) \
X( ngeom ) \
X( nsite ) \
X( ncam ) \
@@ -138,10 +142,6 @@
X( nnames ) \
X( npaths ) \
X( nnames_map ) \
X( nM ) \
X( nB ) \
X( nC ) \
X( nD ) \
X( nJmom ) \
X( ntree ) \
X( ngravcomp ) \
@@ -597,6 +597,19 @@
X ( char, names, nnames, 1 ) \
X ( int, names_map, nnames_map, 1 ) \
X ( char, paths, npaths, 1 ) \
X ( int, B_rownnz, nbody, 1 ) \
X ( int, B_rowadr, nbody, 1 ) \
X ( int, B_colind, nB, 1 ) \
X ( int, M_rownnz, nv, 1 ) \
X ( int, M_rowadr, nv, 1 ) \
X ( int, M_colind, nC, 1 ) \
X ( int, mapM2M, nC, 1 ) \
X ( int, D_rownnz, nv, 1 ) \
X ( int, D_rowadr, nv, 1 ) \
X ( int, D_diag, nv, 1 ) \
X ( int, D_colind, nD, 1 ) \
X ( int, mapM2D, nD, 1 ) \
X ( int, mapD2M, nM, 1 )
//-------------------------------- mjData ----------------------------------------------------------
@@ -722,7 +735,7 @@
X( mjContact, contact, MJ_D(ncon), 1 )
// array fields of mjData that are used in the primal problem
#define MJDATA_ARENA_POINTERS_SOLVER \
#define MJDATA_ARENA_POINTERS_SOLVER \
X ( int, efc_type, MJ_D(nefc), 1 ) \
X ( int, efc_id, MJ_D(nefc), 1 ) \
XNV( int, efc_J_rownnz, MJ_D(nefc), 1 ) \