Add boolean flags for gravity compensation and surface velocity in mjModel.
These fields (`flg_gravcomp` and `flg_surfacevel`) replace the fast-path checks originally guarded by `ngravcomp` and (recently) `nsurfacevel`. Since the engine uses these integers only as flags (zero vs non-zero), migrating them to actual booleans makes them writeable from the Python bindings at runtime without violating size/dimension constraints. The legacy integer field `ngravcomp` is marked as deprecated and will be removed in a future release. PiperOrigin-RevId: 949779204 Change-Id: Ifab1f026063a4239302e6ad689663b611b59dda8
This commit is contained in:
committed by
Copybara-Service
parent
ebd4abae03
commit
a04b0c5b97
@@ -210,16 +210,18 @@ static void setFixed(mjModel* m, mjData* d) {
|
||||
ngravcomp += (m->body_gravcomp[i] > 0);
|
||||
}
|
||||
m->ngravcomp = ngravcomp;
|
||||
m->flg_gravcomp = (ngravcomp > 0);
|
||||
|
||||
// compute nsurfacevel: number of geoms with nonzero surfacevel
|
||||
int nsurfacevel = 0;
|
||||
// compute flg_surfacevel: whether any geom has nonzero surfacevel
|
||||
mjtBool flg_surfacevel = 0;
|
||||
for (int i=0; i < m->ngeom; i++) {
|
||||
const mjtNum* sv = m->geom_surfacevel + 6*i;
|
||||
if (sv[0] || sv[1] || sv[2] || sv[3] || sv[4] || sv[5]) {
|
||||
nsurfacevel++;
|
||||
flg_surfacevel = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
m->nsurfacevel = nsurfacevel;
|
||||
m->flg_surfacevel = flg_surfacevel;
|
||||
|
||||
// set jnt_actuatorid and tendon_actuatorid
|
||||
mju_fillInt(m->jnt_actuatorid, -1, m->njnt);
|
||||
|
||||
Reference in New Issue
Block a user