Don't save actdim="{0,1}" for state{less,ful} actuators, respectively.
actdim has a default value of -1 (==unset), which means it currently gets saved for all actuators. After this change, it will only be saved if the value is > 1, errors are thrown for stateful actuators with actdim=0 and stateless actuators with actdim>0. PiperOrigin-RevId: 520627313 Change-Id: Ia498dae5c7314cfaa0995f8077d297c2339a5c35
This commit is contained in:
committed by
Copybara-Service
parent
0becf8fd98
commit
c65e046043
@@ -640,7 +640,13 @@ void mjXWriter::OneActuator(XMLElement* elem, mjCActuator* pact, mjCDef* def) {
|
||||
|
||||
// non-plugins: write actuator parameters
|
||||
else {
|
||||
WriteAttrInt(elem, "actdim", pact->actdim, def->actuator.actdim);
|
||||
// special handling of actdim which has default value of -1
|
||||
if (writingdefaults) {
|
||||
WriteAttrInt(elem, "actdim", pact->actdim, def->actuator.actdim);
|
||||
} else {
|
||||
int default_actdim = pact->dyntype == mjDYN_NONE ? 0 : 1;
|
||||
WriteAttrInt(elem, "actdim", pact->actdim, default_actdim);
|
||||
}
|
||||
WriteAttrKey(elem, "dyntype", dyn_map, dyn_sz, pact->dyntype, def->actuator.dyntype);
|
||||
WriteAttrKey(elem, "gaintype", gain_map, gain_sz, pact->gaintype, def->actuator.gaintype);
|
||||
WriteAttrKey(elem, "biastype", bias_map, bias_sz, pact->biastype, def->actuator.biastype);
|
||||
|
||||
@@ -844,6 +844,8 @@ TEST_F(XMLWriterTest, Actdim) {
|
||||
</worldbody>
|
||||
<actuator>
|
||||
<general joint="hinge" dyntype="user" actdim="2"/>
|
||||
<general joint="hinge" dyntype="filter" dynprm="1"/>
|
||||
<motor joint="hinge"/>
|
||||
</actuator>
|
||||
</mujoco>
|
||||
)";
|
||||
@@ -851,6 +853,8 @@ TEST_F(XMLWriterTest, Actdim) {
|
||||
ASSERT_THAT(model, NotNull());
|
||||
std::string saved_xml = SaveAndReadXml(model);
|
||||
EXPECT_THAT(saved_xml, HasSubstr("actdim=\"2\""));
|
||||
EXPECT_THAT(saved_xml, Not(HasSubstr("actdim=\"1\"")));
|
||||
EXPECT_THAT(saved_xml, Not(HasSubstr("actdim=\"0\"")));
|
||||
mj_deleteModel(model);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user