Add nJmom, the number of non-zeros in sparse actuator_moment matrix, to mjModel.

PiperOrigin-RevId: 698343986
Change-Id: I3d4a4dea1ec095d4e7b231c2fffc0e6241cee39f
This commit is contained in:
Taylor Howell
2024-11-20 04:29:55 -08:00
committed by Copybara-Service
parent cd84011d7b
commit aae5fd6906
13 changed files with 78 additions and 33 deletions
+10 -2
View File
@@ -777,6 +777,7 @@ void mjCModel::Clear() {
nM = 0;
nD = 0;
nB = 0;
nJmom = 0;
njmax = -1;
nconmax = -1;
nmocap = 0;
@@ -2490,7 +2491,7 @@ void mjCModel::CopyTree(mjModel* m) {
}
}
}
m->nC = nC = 2 * nOD + nv;
m->nC = nC = 2 * nOD + nv;
}
// copy plugin data
@@ -4156,6 +4157,13 @@ void mjCModel::TryCompile(mjModel*& m, mjData*& d, const mjVFS* vfs) {
// copy objects outsite kinematic tree (including keyframes)
CopyObjects(m);
// compute nJmom
for (int i = 0; i < nu; i++) {
// dense rows
nJmom += nv;
}
m->nJmom = nJmom;
// scale mass
if (compiler.settotalmass>0) {
mj_setTotalmass(m, compiler.settotalmass);
@@ -4292,7 +4300,7 @@ bool mjCModel::CopyBack(const mjModel* m) {
neq!=m->neq || ntendon!=m->ntendon || nwrap!=m->nwrap || nsensor!=m->nsensor ||
nnumeric!=m->nnumeric || nnumericdata!=m->nnumericdata || ntext!=m->ntext ||
ntextdata!=m->ntextdata || nnames!=m->nnames || nM!=m->nM || nD!=m->nD || nC!=m->nC ||
nB!=m->nB || nemax!=m->nemax || nconmax!=m->nconmax || njmax!=m->njmax ||
nB!=m->nB || nJmom!=m->nJmom ||nemax!=m->nemax || nconmax!=m->nconmax || njmax!=m->njmax ||
npaths!=m->npaths) {
errInfo = mjCError(0, "incompatible models in CopyBack");
return false;
+1
View File
@@ -118,6 +118,7 @@ class mjCModel_ : public mjsElement {
int nB; // number of non-zeros in sparse body-dof matrix
int nC; // number of non-zeros in reduced sparse 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
// statistics, as computed by mj_setConst
double meaninertia_auto; // mean diagonal inertia, as computed by mj_setConst