From f161b63a220b0919f92e918ca2cf6c02426a2052 Mon Sep 17 00:00:00 2001 From: Yuval Tassa Date: Thu, 19 Sep 2024 04:35:34 -0700 Subject: [PATCH] Set default body position to (0, 0, 0). The "undefined" body position is a remnant of the now-removed `compiler/coordinate` attribute, see [documentation in version 2.3.3](https://mujoco.readthedocs.io/en/2.3.3/modeling.html#cframe) (or older). PiperOrigin-RevId: 676361485 Change-Id: I104c8da2a988a0430eb85fff8b9b60f8c1e08582 --- src/user/user_init.c | 1 - src/user/user_objects.cc | 18 +----------------- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/src/user/user_init.c b/src/user/user_init.c index 4ae5de6c..a9e0b64c 100644 --- a/src/user/user_init.c +++ b/src/user/user_init.c @@ -78,7 +78,6 @@ void mjs_defaultBody(mjsBody* body) { memset(body, 0, sizeof(mjsBody)); // body frame - body->pos[0] = mjNAN; body->quat[0] = 1; // inertial frame diff --git a/src/user/user_objects.cc b/src/user/user_objects.cc index aa37a895..b3c17780 100644 --- a/src/user/user_objects.cc +++ b/src/user/user_objects.cc @@ -1482,11 +1482,6 @@ void mjCBody::Compile(void) { } userdata_.resize(model->nuser_body); - // pos defaults to (0,0,0) - if (!mjuu_defined(pos[0])) { - mjuu_setvec(pos, 0, 0, 0); - } - // normalize user-defined quaternions mjuu_normvec(quat, 4); mjuu_normvec(iquat, 4); @@ -1524,23 +1519,12 @@ void mjCBody::Compile(void) { InertiaFromGeom(); } - // both pos and ipos undefined: error - if (!mjuu_defined(ipos[0]) && !mjuu_defined(pos[0])) { - throw mjCError(this, "body pos and ipos are both undefined"); - } - // ipos undefined: copy body frame into inertial - else if (!mjuu_defined(ipos[0])) { + if (!mjuu_defined(ipos[0])) { mjuu_copyvec(ipos, pos, 3); mjuu_copyvec(iquat, quat, 4); } - // pos undefined: copy inertial frame into body frame - else if (!mjuu_defined(pos[0])) { - mjuu_copyvec(pos, ipos, 3); - mjuu_copyvec(quat, iquat, 4); - } - // check and correct mass and inertia if (id>0) { // fix minimum