Remove "global" option from [compiler/coordinate](https://mujoco.readthedocs.io/en/latest/XMLreference.html#compiler-coordinate) attribute.

Keeping this rarely-used setting complicates the compiler logic and is blocking future improvements. In order to convert older models which used this option, load and save them in MuJoCo 2.3.3 or older.

PiperOrigin-RevId: 521739137
Change-Id: If0cb40d5db4879a4db9318cc2be258a7923e6e85
This commit is contained in:
Yuval Tassa
2023-04-04 05:58:53 -07:00
committed by Copybara-Service
parent b327058641
commit 7cc42ecf2a
14 changed files with 705 additions and 806 deletions
-5
View File
@@ -213,11 +213,6 @@ void mjCComposite::SetDefault(void) {
// make composite object
bool mjCComposite::Make(mjCModel* model, mjCBody* body, char* error, int error_sz) {
// require local coordinates
if (model->global) {
return comperr(error, "Composite requires local coordinates", error_sz);
}
// check geom type
if ((def[0].geom.type!=mjGEOM_SPHERE &&
def[0].geom.type!=mjGEOM_CAPSULE &&
-1
View File
@@ -89,7 +89,6 @@ mjCModel::mjCModel() {
balanceinertia = false;
strippath = false;
fitaabb = false;
global = false;
degree = true;
euler[0] = 'x';
euler[1] = 'y';
-1
View File
@@ -123,7 +123,6 @@ class mjCModel {
bool balanceinertia; // automatically impose A + B >= C rule
bool strippath; // automatically strip paths from mesh files
bool fitaabb; // meshfit to aabb instead of inertia box
bool global; // local or global coordinates
bool degree; // angles in radians or degrees
char euler[3]; // sequence for euler rotations
std::string meshdir; // mesh and hfield directory
+9 -28
View File
@@ -649,17 +649,8 @@ void mjCBody::GeomFrame(void) {
// setup child local frame: pos
void mjCBody::MakeLocal(double* _locpos, double* _locquat,
const double* _pos, const double* _quat) {
// global: transform to local
if (model->global) {
mjuu_localpos(_locpos, _pos, pos, quat);
mjuu_localquat(_locquat, _quat, quat);
}
// local: copy
else {
mjuu_copyvec(_locpos, _pos, 3);
mjuu_copyvec(_locquat, _quat, 4);
}
mjuu_copyvec(_locpos, _pos, 3);
mjuu_copyvec(_locquat, _quat, 4);
}
// set explicitinertial to true
@@ -825,9 +816,9 @@ void mjCBody::Compile(void) {
}
userdata.resize(model->nuser_body);
// pos defaults to (0,0,0) in local coordinates
if (!mjuu_defined(pos[0]) && !model->global) {
mjuu_setvec(pos, 0, 0, 0);
// pos defaults to (0,0,0)
if (!mjuu_defined(pos[0])) {
mjuu_setvec(pos, 0, 0, 0);
}
// normalize user-defined quaternions
@@ -1112,12 +1103,8 @@ int mjCJoint::Compile(void) {
mjuu_zerovec(locpos, 3);
}
// compute local axis relative to specified body
if (model->global) {
mjuu_localaxis(locaxis, axis, body->quat);
} else {
mjuu_copyvec(locaxis, axis, 3);
}
// copy axis to local
mjuu_copyvec(locaxis, axis, 3);
// convert reference angles to radians for hinge joints
if (type==mjJNT_HINGE && model->degree) {
@@ -1930,14 +1917,8 @@ void mjCLight::Compile(void) {
// ask parent body to compute our local pos and quat relative to itself
body->MakeLocal(locpos, locquat, pos, quat);
// copy/convert dir to local frame
if (model->global) {
double mat[9], q[4] = {locquat[0], -locquat[1], -locquat[2], -locquat[3]};
mjuu_quat2mat(mat, q);
mjuu_mulvecmat(locdir, dir, mat);
} else {
mjuu_copyvec(locdir, dir, 3);
}
// copy dir to local frame
mjuu_copyvec(locdir, dir, 3);
// get targetbodyid
if (!targetbody.empty()) {
+4 -1
View File
@@ -863,7 +863,10 @@ void mjXReader::Compiler(XMLElement* section, mjCModel* mod) {
mod->fitaabb = (n==1);
}
if (MapValue(section, "coordinate", &n, coordinate_map, 2)) {
mod->global = (n==1);
if (n==1) {
throw mjXError(section, "global coordinates no longer supported. To convert existing models, "
"load and save them in MuJoCo 2.3.3 or older");
}
}
if (MapValue(section, "angle", &n, angle_map, 2)) {
mod->degree = (n==1);
-1
View File
@@ -99,7 +99,6 @@ void mjXURDF::Parse(XMLElement* root) {
}
// enforce required compiler defaults for URDF
model->global = false;
model->degree = false;
// get model name