Fix insidesite sensor for massless flex parent bodies.
mjSENS_INSIDESITE uses xipos to test containment, but for massless flex parent bodies xipos equals the static body frame origin and does not track the actual flex position. Fix: in the INSIDESITE sensor case, when the object is a massless body with positive subtree mass (i.e., a flex parent), use subtree_com instead of xipos. This correctly reflects the mass-weighted centroid of the flex child bodies without changing the global semantics of xipos. PiperOrigin-RevId: 908745144 Change-Id: I527f0efb7b419345188411c9da883505156ebeea
This commit is contained in:
committed by
Copybara-Service
parent
f7d31e06f0
commit
8287d9d152
@@ -795,6 +795,15 @@ static void mj_computeSensorPos(const mjModel* m, mjData* d, int i, mjtNum* sens
|
||||
|
||||
case mjSENS_INSIDESITE: // 1 if object is inside site
|
||||
get_xpos_xmat(d, objtype, objid, i, &xpos, &xmat);
|
||||
|
||||
// for massless bodies with positive subtree mass (e.g., flex parents),
|
||||
// xipos is the static body frame origin; use subtree_com instead
|
||||
if (objtype == mjOBJ_BODY && objid > 0 &&
|
||||
m->body_mass[objid] < mjMINVAL &&
|
||||
m->body_subtreemass[objid] >= mjMINVAL) {
|
||||
xpos = d->subtree_com + 3*objid;
|
||||
}
|
||||
|
||||
sensordata[0] = mju_insideGeom(d->site_xpos + 3*refid,
|
||||
d->site_xmat + 9*refid,
|
||||
m->site_size + 3*refid,
|
||||
|
||||
Reference in New Issue
Block a user