Add missing gravity attribute authoring to Mjcf SdfFileFormat plugin.
PiperOrigin-RevId: 779239797 Change-Id: I039b1089e5b436498d14df384c1aee830fd4b48a
This commit is contained in:
committed by
Copybara-Service
parent
45d4cacc45
commit
be3c3ef8a9
@@ -554,6 +554,16 @@ class ModelWriter {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pxr::GfVec3f gravity(spec_->option.gravity[0], spec_->option.gravity[1],
|
||||||
|
spec_->option.gravity[2]);
|
||||||
|
// Normalize will normalize gravity in place and return the magnitude before normalization.
|
||||||
|
float gravity_magnitude = gravity.Normalize();
|
||||||
|
|
||||||
|
WriteUniformAttribute(physics_scene_path, pxr::SdfValueTypeNames->Float,
|
||||||
|
pxr::UsdPhysicsTokens->physicsGravityMagnitude, gravity_magnitude);
|
||||||
|
WriteUniformAttribute(physics_scene_path, pxr::SdfValueTypeNames->Vector3f,
|
||||||
|
pxr::UsdPhysicsTokens->physicsGravityDirection, gravity);
|
||||||
|
|
||||||
pxr::GfVec3d wind(spec_->option.wind[0], spec_->option.wind[1],
|
pxr::GfVec3d wind(spec_->option.wind[0], spec_->option.wind[1],
|
||||||
spec_->option.wind[2]);
|
spec_->option.wind[2]);
|
||||||
WriteUniformAttribute(physics_scene_path, pxr::SdfValueTypeNames->Double3,
|
WriteUniformAttribute(physics_scene_path, pxr::SdfValueTypeNames->Double3,
|
||||||
|
|||||||
@@ -976,6 +976,38 @@ TEST_F(MjcfSdfFileFormatPluginTest, TestPhysicsScenePrimSDFIterations) {
|
|||||||
60);
|
60);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(MjcfSdfFileFormatPluginTest, TestPhysicsScenePrimGravity) {
|
||||||
|
auto stage = pxr::UsdStage::Open(LoadLayer(R"(
|
||||||
|
<mujoco model="test">
|
||||||
|
<option gravity="-123 0 0"> </option>
|
||||||
|
</mujoco>
|
||||||
|
)"));
|
||||||
|
|
||||||
|
ExpectAttributeEqual(stage,
|
||||||
|
kPhysicsScenePrimPath.AppendProperty(
|
||||||
|
pxr::UsdPhysicsTokens->physicsGravityMagnitude),
|
||||||
|
123.0f);
|
||||||
|
ExpectAttributeEqual(stage,
|
||||||
|
kPhysicsScenePrimPath.AppendProperty(
|
||||||
|
pxr::UsdPhysicsTokens->physicsGravityDirection),
|
||||||
|
pxr::GfVec3f(-1.0f, 0.0f, 0.0f));
|
||||||
|
|
||||||
|
stage = pxr::UsdStage::Open(LoadLayer(R"(
|
||||||
|
<mujoco model="test">
|
||||||
|
<option gravity="2 3 6"> </option>
|
||||||
|
</mujoco>
|
||||||
|
)"));
|
||||||
|
|
||||||
|
ExpectAttributeEqual(stage,
|
||||||
|
kPhysicsScenePrimPath.AppendProperty(
|
||||||
|
pxr::UsdPhysicsTokens->physicsGravityMagnitude),
|
||||||
|
7.0f);
|
||||||
|
ExpectAttributeEqual(stage,
|
||||||
|
kPhysicsScenePrimPath.AppendProperty(
|
||||||
|
pxr::UsdPhysicsTokens->physicsGravityDirection),
|
||||||
|
pxr::GfVec3f(0.2857143f, 0.42857143f, 0.85714287f));
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(MjcfSdfFileFormatPluginTest, TestPhysicsScenePrimDisableFlags) {
|
TEST_F(MjcfSdfFileFormatPluginTest, TestPhysicsScenePrimDisableFlags) {
|
||||||
auto stage = pxr::UsdStage::Open(LoadLayer(R"(
|
auto stage = pxr::UsdStage::Open(LoadLayer(R"(
|
||||||
<mujoco model="test">
|
<mujoco model="test">
|
||||||
|
|||||||
Reference in New Issue
Block a user