Add mjModel.tendon_armature (in preparation, not yet implemented)
PiperOrigin-RevId: 743649968 Change-Id: I1d893e3e06afc48b652575bc7837750ab3573670
This commit is contained in:
committed by
Copybara-Service
parent
f96f3e1c22
commit
e1f5ceb65a
@@ -3390,6 +3390,7 @@ void mjCModel::CopyObjects(mjModel* m) {
|
||||
m->tendon_margin[i] = (mjtNum)pte->margin;
|
||||
m->tendon_stiffness[i] = (mjtNum)pte->stiffness;
|
||||
m->tendon_damping[i] = (mjtNum)pte->damping;
|
||||
m->tendon_armature[i] = (mjtNum)pte->armature;
|
||||
m->tendon_frictionloss[i] = (mjtNum)pte->frictionloss;
|
||||
m->tendon_lengthspring[2*i] = (mjtNum)pte->springlength[0];
|
||||
m->tendon_lengthspring[2*i+1] = (mjtNum)pte->springlength[1];
|
||||
@@ -4931,6 +4932,7 @@ bool mjCModel::CopyBack(const mjModel* m) {
|
||||
tendons_[i]->margin = (double)m->tendon_margin[i];
|
||||
tendons_[i]->stiffness = (double)m->tendon_stiffness[i];
|
||||
tendons_[i]->damping = (double)m->tendon_damping[i];
|
||||
tendons_[i]->armature = (double)m->tendon_armature[i];
|
||||
tendons_[i]->frictionloss = (double)m->tendon_frictionloss[i];
|
||||
|
||||
if (nuser_tendon) {
|
||||
|
||||
@@ -5616,6 +5616,12 @@ void mjCTendon::Compile(void) {
|
||||
|
||||
// spatial path
|
||||
else {
|
||||
if (armature < 0) {
|
||||
throw mjCError(this,
|
||||
"tendon '%s' (id = %d): tendon armature cannot be negative",
|
||||
name.c_str(), id);
|
||||
}
|
||||
|
||||
switch (path[i]->type) {
|
||||
case mjWRAP_PULLEY:
|
||||
// pulley should not follow other pulley
|
||||
@@ -5657,6 +5663,12 @@ void mjCTendon::Compile(void) {
|
||||
name.c_str(), id, i);
|
||||
}
|
||||
|
||||
if (armature > 0) {
|
||||
throw mjCError(this,
|
||||
"tendon '%s' (id = %d): geom wrapping not supported by tendon armature",
|
||||
name.c_str(), id);
|
||||
}
|
||||
|
||||
// mark geoms as non visual
|
||||
model->Geoms()[path[i]->obj->id]->SetNotVisual();
|
||||
break;
|
||||
|
||||
@@ -363,18 +363,18 @@ const char* MJCF[nMJCF][mjXATTRNUM] = {
|
||||
|
||||
{"tendon", "*", "0"},
|
||||
{"<"},
|
||||
{"spatial", "*", "18", "name", "class", "group", "limited", "range",
|
||||
{"spatial", "*", "19", "name", "class", "group", "limited", "range",
|
||||
"solreflimit", "solimplimit", "solreffriction", "solimpfriction",
|
||||
"frictionloss", "springlength", "width", "material",
|
||||
"margin", "stiffness", "damping", "rgba", "user"},
|
||||
"margin", "stiffness", "damping", "armature", "rgba", "user"},
|
||||
{"<"},
|
||||
{"site", "*", "1", "site"},
|
||||
{"geom", "*", "2", "geom", "sidesite"},
|
||||
{"pulley", "*", "1", "divisor"},
|
||||
{">"},
|
||||
{"fixed", "*", "15", "name", "class", "group", "limited", "range",
|
||||
{"fixed", "*", "16", "name", "class", "group", "limited", "range",
|
||||
"solreflimit", "solimplimit", "solreffriction", "solimpfriction",
|
||||
"frictionloss", "springlength", "margin", "stiffness", "damping", "user"},
|
||||
"frictionloss", "springlength", "margin", "stiffness", "damping", "armature", "user"},
|
||||
{"<"},
|
||||
{"joint", "*", "2", "joint", "coef"},
|
||||
{">"},
|
||||
@@ -2061,6 +2061,7 @@ void mjXReader::OneTendon(XMLElement* elem, mjsTendon* tendon) {
|
||||
ReadAttr(elem, "margin", 1, &tendon->margin, text);
|
||||
ReadAttr(elem, "stiffness", 1, &tendon->stiffness, text);
|
||||
ReadAttr(elem, "damping", 1, &tendon->damping, text);
|
||||
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
|
||||
if (ReadAttr(elem, "springlength", 2, tendon->springlength, text, false, false) == 1) {
|
||||
@@ -3800,7 +3801,7 @@ void mjXReader::Tendon(XMLElement* section) {
|
||||
def = mjs_getSpecDefault(spec);
|
||||
}
|
||||
|
||||
// create equality constraint and parse
|
||||
// create tendon and parse
|
||||
mjsTendon* tendon = mjs_addTendon(spec, def);
|
||||
OneTendon(elem, tendon);
|
||||
|
||||
|
||||
@@ -729,6 +729,7 @@ void mjXWriter::OneTendon(XMLElement* elem, const mjCTendon* tendon, mjCDef* def
|
||||
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);
|
||||
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] ||
|
||||
def->Tendon().springlength[0] != def->Tendon().springlength[1]) {
|
||||
|
||||
Reference in New Issue
Block a user