Remove urdfeffort attribute, parse URDF "effort" into mjsJoint.actforcerange.
PiperOrigin-RevId: 630796429 Change-Id: I45363aca8afcce68bf48b2e8bdb556b39852f073
This commit is contained in:
committed by
Copybara-Service
parent
61a651c63a
commit
ac1af8e461
@@ -244,7 +244,6 @@ typedef struct _mjsJoint { // joint specification
|
||||
// other
|
||||
int group; // group
|
||||
mjtByte actgravcomp; // is gravcomp force applied via actuators
|
||||
double urdfeffort; // effort (urdf)
|
||||
mjDoubleVec userdata; // user data
|
||||
mjString info; // message appended to compiler errors
|
||||
} mjsJoint;
|
||||
|
||||
@@ -105,7 +105,6 @@ void mjs_defaultJoint(mjsJoint* joint) {
|
||||
joint->actfrclimited = mjLIMITED_AUTO;
|
||||
mj_defaultSolRefImp(joint->solref_limit, joint->solimp_limit);
|
||||
mj_defaultSolRefImp(joint->solref_friction, joint->solimp_friction);
|
||||
joint->urdfeffort = -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2411,8 +2411,7 @@ void mjCGeom::Compile(void) {
|
||||
if (type==mjGEOM_HFIELD) {
|
||||
size[0] = hfield->size[0];
|
||||
size[1] = hfield->size[1];
|
||||
size[2] = 0.5*(0.5*hfield->size[2] +
|
||||
hfield->size[3]);
|
||||
size[2] = 0.25 * hfield->size[2] + 0.5 * hfield->size[3];
|
||||
} else if (type==mjGEOM_MESH || type==mjGEOM_SDF) {
|
||||
const double* aamm = mesh->aamm();
|
||||
size[0] = mju_max(fabs(aamm[0]), fabs(aamm[3]));
|
||||
@@ -5021,7 +5020,6 @@ void mjCActuator::CopyFromSpec() {
|
||||
|
||||
|
||||
void mjCActuator::ResolveReferences(const mjCModel* m) {
|
||||
mjCJoint* pjnt;
|
||||
switch (trntype) {
|
||||
case mjTRN_JOINT:
|
||||
case mjTRN_JOINTINPARENT:
|
||||
@@ -5031,14 +5029,6 @@ void mjCActuator::ResolveReferences(const mjCModel* m) {
|
||||
throw mjCError(this,
|
||||
"unknown transmission target '%s' for actuator id = %d", target_.c_str(), id);
|
||||
}
|
||||
pjnt = (mjCJoint*) ptarget;
|
||||
|
||||
// apply urdfeffort
|
||||
if (pjnt->spec.urdfeffort>0) {
|
||||
forcerange[0] = -pjnt->spec.urdfeffort;
|
||||
forcerange[1] = pjnt->spec.urdfeffort;
|
||||
forcelimited = mjLIMITED_TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
case mjTRN_SLIDERCRANK:
|
||||
|
||||
+16
-9
@@ -13,6 +13,7 @@
|
||||
// limitations under the License.
|
||||
|
||||
#include <array>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
@@ -488,17 +489,23 @@ void mjXURDF::Joint(XMLElement* joint_elem) {
|
||||
|
||||
// limit element
|
||||
if ((elem = FindSubElem(joint_elem, "limit"))) {
|
||||
ReadAttr(elem, "lower", 1, pjoint->range, text);
|
||||
ReadAttr(elem, "upper", 1, pjoint->range+1, text);
|
||||
bool is_limited = mjuu_defined(pjoint->range[0]) &&
|
||||
mjuu_defined(pjoint->range[1]) &&
|
||||
pjoint->range[0] < pjoint->range[1];
|
||||
pjoint->limited = is_limited ? mjLIMITED_TRUE : mjLIMITED_FALSE;
|
||||
bool haslower = ReadAttr(elem, "lower", 1, pjoint->range, text);
|
||||
bool hasupper = ReadAttr(elem, "upper", 1, pjoint->range+1, text);
|
||||
|
||||
// handle range mis-specification, otherwise the default mjLIMITED_AUTO will do the right thing
|
||||
bool bad_range = (haslower != hasupper) || pjoint->range[0] > pjoint->range[1];
|
||||
if (bad_range) {
|
||||
pjoint->limited = mjLIMITED_FALSE;
|
||||
}
|
||||
|
||||
// ReadAttr(elem, "velocity", 1, &pjoint->maxvel, text); // no maxvel in MuJoCo
|
||||
ReadAttr(elem, "effort", 1, &pjoint->urdfeffort, text);
|
||||
} else {
|
||||
pjoint->limited = mjLIMITED_FALSE;
|
||||
double effort = 0;
|
||||
ReadAttr(elem, "effort", 1, &effort, text);
|
||||
effort = std::abs(effort);
|
||||
if (effort > 0) {
|
||||
pjoint->actfrcrange[0] = -effort;
|
||||
pjoint->actfrcrange[1] = effort;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user