diff --git a/src/user/user_api.h b/src/user/user_api.h index e23a5cb2..e69c7602 100644 --- a/src/user/user_api.h +++ b/src/user/user_api.h @@ -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; diff --git a/src/user/user_init.c b/src/user/user_init.c index 02f8b8fa..b45c2dde 100644 --- a/src/user/user_init.c +++ b/src/user/user_init.c @@ -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; } diff --git a/src/user/user_objects.cc b/src/user/user_objects.cc index 18c5c61d..db747ab3 100644 --- a/src/user/user_objects.cc +++ b/src/user/user_objects.cc @@ -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: diff --git a/src/xml/xml_urdf.cc b/src/xml/xml_urdf.cc index e7d281ce..8001d93a 100644 --- a/src/xml/xml_urdf.cc +++ b/src/xml/xml_urdf.cc @@ -13,6 +13,7 @@ // limitations under the License. #include +#include #include #include #include @@ -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; + } } }