Sparse ten_J and ten_J_colind memory

PiperOrigin-RevId: 868800229
Change-Id: Id83f9fd40dd9bece06fd99753e4202eea17ca884
This commit is contained in:
Taylor Howell
2026-02-11 12:44:56 -08:00
committed by Copybara-Service
parent 94e834bf4f
commit d011285380
21 changed files with 118 additions and 43 deletions
+12
View File
@@ -3226,7 +3226,16 @@ int mjCModel::CountNJmom(const mjModel* m) {
return count;
}
// compute non-zeros in ten_J matrix
int mjCModel::CountNJten(const mjModel* m) {
int nv = m->nv;
int ntendon = m->ntendon;
// conservative upper bound: each tendon can have at most nv non-zeros
// TODO(taylorhowell): compute tighter bound
int count = ntendon * nv;
return count;
}
// copy objects outside kinematic tree
void mjCModel::CopyObjects(mjModel* m) {
@@ -5037,6 +5046,9 @@ void mjCModel::TryCompile(mjModel*& m, mjData*& d, const mjVFS* vfs) {
// compute non-zeros in actuator_moment
m->nJmom = nJmom = CountNJmom(m);
// compute non-zeros in ten_J
m->nJten = nJten = CountNJten(m);
// scale mass
if (compiler.settotalmass > 0) {
mj_setTotalmass(m, compiler.settotalmass);
+2
View File
@@ -130,6 +130,7 @@ class mjCModel_ : public mjsElement {
mjtSize nC; // number of non-zeros in reduced sparse dof-dof matrix
mjtSize nD; // number of non-zeros in sparse dof-dof matrix
mjtSize nJmom; // number of non-zeros in sparse actuator_moment matrix
mjtSize nJten; // number of non-zeros in sparse ten_J matrix
// statistics, as computed by mj_setConst
double meaninertia_auto; // mean diagonal inertia, as computed by mj_setConst
@@ -368,6 +369,7 @@ class mjCModel : public mjCModel_, private mjSpec {
void FinalizeSimple(mjModel* m); // finalize simple bodies/dofs including tendon information
void CopyPlugins(mjModel*); // copy plugin data
int CountNJmom(const mjModel* m); // compute number of non-zeros in actuator_moment matrix
int CountNJten(const mjModel* m); // compute number of non-zeros in ten_J matrix
// remove plugins that are not referenced by any object
void RemovePlugins();