Polynomial stiffness and damping https://youtu.be/aKa3ZlEF9_Y
PiperOrigin-RevId: 884607673 Change-Id: If8088dbf37fed1055304778a7eb84dec52cba920
This commit is contained in:
committed by
Copybara-Service
parent
aec1b45dce
commit
efae9157a7
@@ -1815,14 +1815,18 @@ void mjXReader::OneJoint(XMLElement* elem, mjsJoint* joint) {
|
||||
ReadAttr(elem, "pos", 3, joint->pos, text);
|
||||
ReadAttr(elem, "axis", 3, joint->axis, text);
|
||||
ReadAttr(elem, "springdamper", 2, joint->springdamper, text);
|
||||
ReadAttr(elem, "stiffness", 1, &joint->stiffness, text);
|
||||
|
||||
ReadAttr(elem, "stiffness", 1+mjNPOLY, joint->stiffness, text, false, false);
|
||||
|
||||
ReadAttr(elem, "range", 2, joint->range, text);
|
||||
ReadAttr(elem, "actuatorfrcrange", 2, joint->actfrcrange, text);
|
||||
ReadAttr(elem, "margin", 1, &joint->margin, text);
|
||||
ReadAttr(elem, "ref", 1, &joint->ref, text);
|
||||
ReadAttr(elem, "springref", 1, &joint->springref, text);
|
||||
ReadAttr(elem, "armature", 1, &joint->armature, text);
|
||||
ReadAttr(elem, "damping", 1, &joint->damping, text);
|
||||
|
||||
ReadAttr(elem, "damping", 1+mjNPOLY, joint->damping, text, false, false);
|
||||
|
||||
ReadAttr(elem, "frictionloss", 1, &joint->frictionloss, text);
|
||||
if (MapValue(elem, "actuatorgravcomp", &n, bool_map, 2)) {
|
||||
joint->actgravcomp = (n == 1);
|
||||
@@ -2267,8 +2271,11 @@ void mjXReader::OneTendon(XMLElement* elem, mjsTendon* tendon) {
|
||||
ReadAttr(elem, "range", 2, tendon->range, text);
|
||||
ReadAttr(elem, "actuatorfrcrange", 2, tendon->actfrcrange, text);
|
||||
ReadAttr(elem, "margin", 1, &tendon->margin, text);
|
||||
ReadAttr(elem, "stiffness", 1, &tendon->stiffness, text);
|
||||
ReadAttr(elem, "damping", 1, &tendon->damping, text);
|
||||
|
||||
ReadAttr(elem, "stiffness", 1+mjNPOLY, tendon->stiffness, text, false, false);
|
||||
|
||||
ReadAttr(elem, "damping", 1+mjNPOLY, tendon->damping, text, false, false);
|
||||
|
||||
ReadAttr(elem, "armature", 1, &tendon->armature, text);
|
||||
ReadAttr(elem, "frictionloss", 1, &tendon->frictionloss, text);
|
||||
// read springlength, either one or two values; if one, copy to second value
|
||||
@@ -2679,11 +2686,11 @@ void mjXReader::OneComposite(XMLElement* elem, mjsBody* body, mjsFrame* frame, c
|
||||
"solreffriction", mjNREF, djoint.solref_friction, text, false, false);
|
||||
ReadAttr(ejnt,
|
||||
"solimpfriction", mjNIMP, djoint.solimp_friction, text, false, false);
|
||||
ReadAttr(ejnt, "stiffness", 1, &djoint.stiffness, text);
|
||||
ReadAttr(ejnt, "stiffness", 1, djoint.stiffness, text);
|
||||
ReadAttr(ejnt, "range", 2, djoint.range, text);
|
||||
ReadAttr(ejnt, "margin", 1, &djoint.margin, text);
|
||||
ReadAttr(ejnt, "armature", 1, &djoint.armature, text);
|
||||
ReadAttr(ejnt, "damping", 1, &djoint.damping, text);
|
||||
ReadAttr(ejnt, "damping", 1, djoint.damping, text);
|
||||
ReadAttr(ejnt, "frictionloss", 1, &djoint.frictionloss, text);
|
||||
|
||||
// advance
|
||||
|
||||
@@ -395,7 +395,12 @@ void mjXWriter::OneJoint(XMLElement* elem, const mjCJoint* joint, mjCDef* def,
|
||||
true);
|
||||
WriteAttr(elem, "solimpfriction", mjNIMP, joint->solimp_friction, def->Joint().solimp_friction,
|
||||
true);
|
||||
WriteAttr(elem, "stiffness", 1, &joint->stiffness, &def->Joint().stiffness);
|
||||
{
|
||||
int nstiff = 1+mjNPOLY;
|
||||
while (nstiff > 1 && joint->stiffness[nstiff-1] == 0
|
||||
&& def->Joint().stiffness[nstiff-1] == 0) nstiff--;
|
||||
WriteAttr(elem, "stiffness", nstiff, joint->stiffness, def->Joint().stiffness);
|
||||
}
|
||||
if (joint->type != mjJNT_FREE) {
|
||||
WriteAttrKey(elem, "limited", TFAuto_map, 3, joint->limited, def->Joint().limited);
|
||||
}
|
||||
@@ -408,7 +413,12 @@ void mjXWriter::OneJoint(XMLElement* elem, const mjCJoint* joint, mjCDef* def,
|
||||
WriteAttr(elem, "actuatorfrcrange", 2, joint->actfrcrange, def->Joint().actfrcrange);
|
||||
WriteAttr(elem, "margin", 1, &joint->margin, &def->Joint().margin);
|
||||
WriteAttr(elem, "armature", 1, &joint->armature, &def->Joint().armature);
|
||||
WriteAttr(elem, "damping", 1, &joint->damping, &def->Joint().damping);
|
||||
{
|
||||
int ndamp = 1+mjNPOLY;
|
||||
while (ndamp > 1 && joint->damping[ndamp-1] == 0
|
||||
&& def->Joint().damping[ndamp-1] == 0) ndamp--;
|
||||
WriteAttr(elem, "damping", ndamp, joint->damping, def->Joint().damping);
|
||||
}
|
||||
WriteAttr(elem, "frictionloss", 1, &joint->frictionloss, &def->Joint().frictionloss);
|
||||
|
||||
// userdata
|
||||
@@ -753,8 +763,18 @@ void mjXWriter::OneTendon(XMLElement* elem, const mjCTendon* tendon, mjCDef* def
|
||||
WriteAttr(elem, "range", 2, tendon->range, def->Tendon().range);
|
||||
WriteAttr(elem, "actuatorfrcrange", 2, tendon->actfrcrange, def->Tendon().actfrcrange);
|
||||
WriteAttr(elem, "margin", 1, &tendon->margin, &def->Tendon().margin);
|
||||
WriteAttr(elem, "stiffness", 1, &tendon->stiffness, &def->Tendon().stiffness);
|
||||
WriteAttr(elem, "damping", 1, &tendon->damping, &def->Tendon().damping);
|
||||
{
|
||||
int nstiff = 1+mjNPOLY;
|
||||
while (nstiff > 1 && tendon->stiffness[nstiff-1] == 0
|
||||
&& def->Tendon().stiffness[nstiff-1] == 0) nstiff--;
|
||||
WriteAttr(elem, "stiffness", nstiff, tendon->stiffness, def->Tendon().stiffness);
|
||||
}
|
||||
{
|
||||
int ndamp = 1+mjNPOLY;
|
||||
while (ndamp > 1 && tendon->damping[ndamp-1] == 0
|
||||
&& def->Tendon().damping[ndamp-1] == 0) ndamp--;
|
||||
WriteAttr(elem, "damping", ndamp, tendon->damping, def->Tendon().damping);
|
||||
}
|
||||
WriteAttr(elem, "armature", 1, &tendon->armature, &def->Tendon().armature);
|
||||
WriteAttr(elem, "frictionloss", 1, &tendon->frictionloss, &def->Tendon().frictionloss);
|
||||
if (tendon->springlength[0] != tendon->springlength[1] ||
|
||||
|
||||
+3
-2
@@ -486,12 +486,13 @@ void mjXURDF::Joint(XMLElement* joint_elem) {
|
||||
|
||||
// dynamics element
|
||||
if ((elem = FindSubElem(joint_elem, "dynamics"))) {
|
||||
ReadAttr(elem, "damping", 1, &pjoint->damping, text);
|
||||
ReadAttr(elem, "damping", 1, pjoint->damping, text);
|
||||
ReadAttr(elem, "friction", 1, &pjoint->frictionloss, text);
|
||||
|
||||
// copy parameters to all elements of planar joint
|
||||
if (pjoint1) {
|
||||
pjoint1->damping = pjoint2->damping = pjoint->damping;
|
||||
mjuu_copyvec(pjoint1->damping, pjoint->damping, 1+mjNPOLY);
|
||||
mjuu_copyvec(pjoint2->damping, pjoint->damping, 1+mjNPOLY);
|
||||
pjoint1->frictionloss = pjoint2->frictionloss = pjoint->frictionloss;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user