Add group support to mjcPhysics equivalents for sites, geoms, actuators, and joints.

PiperOrigin-RevId: 781945497
Change-Id: I5c409f05e6bae33c181a51c273f260daea6004fc
This commit is contained in:
Sam Haves
2025-07-11 05:36:35 -07:00
committed by Copybara-Service
parent bbb265da4a
commit 3473e4e451
14 changed files with 234 additions and 24 deletions
@@ -1463,6 +1463,9 @@ class ModelWriter {
ApplyApiSchema(data_, site_path, MjcPhysicsTokens->MjcSiteAPI);
WriteUniformAttribute(site_path, pxr::SdfValueTypeNames->Int,
MjcPhysicsTokens->mjcGroup, site->group);
int site_id = mjs_getId(site->element);
auto transform = MujocoPosQuatToTransform(&model_->site_pos[3 * site_id],
&model_->site_quat[4 * site_id]);
@@ -1508,6 +1511,9 @@ class ModelWriter {
return;
}
WriteUniformAttribute(geom_path, pxr::SdfValueTypeNames->Int,
MjcPhysicsTokens->mjcGroup, geom->group);
// Apply the physics schemas if we are writing physics and the
// geom participates in collisions.
if (write_physics_ && (model_->geom_contype[geom_id] != 0 ||
@@ -1855,6 +1861,9 @@ class ModelWriter {
// Finally write the mjcPhysicsJointAPI attributes.
ApplyApiSchema(data_, joint_path, MjcPhysicsTokens->MjcJointAPI);
WriteUniformAttribute(joint_path, pxr::SdfValueTypeNames->Int,
MjcPhysicsTokens->mjcGroup, joint->group);
WriteUniformAttribute(
joint_path, pxr::SdfValueTypeNames->DoubleArray,
MjcPhysicsTokens->mjcSpringdamper,