Don't write limited and actuatorfrclimited attributes when "true" is not a valid value.
Saved XMLs are filled with ``` <joint type="free" limited="false" actuatorforcelimited="false"/> ``` but since these are hardcoded to "false" at compile time, there is no point in saving them to XML. PiperOrigin-RevId: 776606516 Change-Id: Iac61c5126231f776077a8c265be732f9215fbfbb
This commit is contained in:
committed by
Copybara-Service
parent
e80a62c6d5
commit
c945247e7c
@@ -2392,6 +2392,7 @@ int mjCJoint::Compile(void) {
|
|||||||
if (type == mjJNT_FREE) {
|
if (type == mjJNT_FREE) {
|
||||||
limited = mjLIMITED_FALSE;
|
limited = mjLIMITED_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// otherwise if limited is auto, check consistency wrt auto-limits
|
// otherwise if limited is auto, check consistency wrt auto-limits
|
||||||
else if (limited == mjLIMITED_AUTO) {
|
else if (limited == mjLIMITED_AUTO) {
|
||||||
bool hasrange = !(range[0] == 0 && range[1] == 0);
|
bool hasrange = !(range[0] == 0 && range[1] == 0);
|
||||||
@@ -2423,6 +2424,7 @@ int mjCJoint::Compile(void) {
|
|||||||
if (type == mjJNT_FREE || type == mjJNT_BALL) {
|
if (type == mjJNT_FREE || type == mjJNT_BALL) {
|
||||||
actfrclimited = mjLIMITED_FALSE;
|
actfrclimited = mjLIMITED_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// otherwise if actfrclimited is auto, check consistency wrt auto-limits
|
// otherwise if actfrclimited is auto, check consistency wrt auto-limits
|
||||||
else if (actfrclimited == mjLIMITED_AUTO) {
|
else if (actfrclimited == mjLIMITED_AUTO) {
|
||||||
bool hasrange = !(actfrcrange[0] == 0 && actfrcrange[1] == 0);
|
bool hasrange = !(actfrcrange[0] == 0 && actfrcrange[1] == 0);
|
||||||
|
|||||||
@@ -395,10 +395,14 @@ void mjXWriter::OneJoint(XMLElement* elem, const mjCJoint* joint, mjCDef* def,
|
|||||||
WriteAttr(elem, "solimpfriction", mjNIMP, joint->solimp_friction, def->Joint().solimp_friction,
|
WriteAttr(elem, "solimpfriction", mjNIMP, joint->solimp_friction, def->Joint().solimp_friction,
|
||||||
true);
|
true);
|
||||||
WriteAttr(elem, "stiffness", 1, &joint->stiffness, &def->Joint().stiffness);
|
WriteAttr(elem, "stiffness", 1, &joint->stiffness, &def->Joint().stiffness);
|
||||||
WriteAttrKey(elem, "limited", TFAuto_map, 3, joint->limited, def->Joint().limited);
|
if (joint->type != mjJNT_FREE) {
|
||||||
|
WriteAttrKey(elem, "limited", TFAuto_map, 3, joint->limited, def->Joint().limited);
|
||||||
|
}
|
||||||
WriteAttr(elem, "range", 2, joint->range, def->Joint().range);
|
WriteAttr(elem, "range", 2, joint->range, def->Joint().range);
|
||||||
WriteAttrKey(elem, "actuatorfrclimited", TFAuto_map, 3, joint->actfrclimited,
|
if (joint->type != mjJNT_FREE && joint->type != mjJNT_BALL) {
|
||||||
def->Joint().actfrclimited);
|
WriteAttrKey(elem, "actuatorfrclimited", TFAuto_map, 3, joint->actfrclimited,
|
||||||
|
def->Joint().actfrclimited);
|
||||||
|
}
|
||||||
WriteAttrKey(elem, "actuatorgravcomp", bool_map, 2, joint->actgravcomp, def->Joint().actgravcomp);
|
WriteAttrKey(elem, "actuatorgravcomp", bool_map, 2, joint->actgravcomp, def->Joint().actgravcomp);
|
||||||
WriteAttr(elem, "actuatorfrcrange", 2, joint->actfrcrange, def->Joint().actfrcrange);
|
WriteAttr(elem, "actuatorfrcrange", 2, joint->actfrcrange, def->Joint().actfrcrange);
|
||||||
WriteAttr(elem, "margin", 1, &joint->margin, &def->Joint().margin);
|
WriteAttr(elem, "margin", 1, &joint->margin, &def->Joint().margin);
|
||||||
|
|||||||
Reference in New Issue
Block a user