Rename mjSpec.euler to eulerseq to match MJCF.
PiperOrigin-RevId: 649007737 Change-Id: Iedb53c1d8a6e6a082a6ba30a1fb2bb4516839fa1
This commit is contained in:
committed by
Copybara-Service
parent
df7ea3ed33
commit
8f16b72f44
@@ -1654,7 +1654,7 @@ typedef struct mjSpec_ { // model specification
|
|||||||
mjtByte strippath; // automatically strip paths from mesh files
|
mjtByte strippath; // automatically strip paths from mesh files
|
||||||
mjtByte fitaabb; // meshfit to aabb instead of inertia box
|
mjtByte fitaabb; // meshfit to aabb instead of inertia box
|
||||||
mjtByte degree; // angles in radians or degrees
|
mjtByte degree; // angles in radians or degrees
|
||||||
char euler[3]; // sequence for euler rotations
|
char eulerseq[3]; // sequence for euler rotations
|
||||||
mjString* meshdir; // mesh and hfield directory
|
mjString* meshdir; // mesh and hfield directory
|
||||||
mjString* texturedir; // texture directory
|
mjString* texturedir; // texture directory
|
||||||
mjtByte discardvisual; // discard visual geoms in parser
|
mjtByte discardvisual; // discard visual geoms in parser
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ typedef struct mjSpec_ { // model specification
|
|||||||
mjtByte strippath; // automatically strip paths from mesh files
|
mjtByte strippath; // automatically strip paths from mesh files
|
||||||
mjtByte fitaabb; // meshfit to aabb instead of inertia box
|
mjtByte fitaabb; // meshfit to aabb instead of inertia box
|
||||||
mjtByte degree; // angles in radians or degrees
|
mjtByte degree; // angles in radians or degrees
|
||||||
char euler[3]; // sequence for euler rotations
|
char eulerseq[3]; // sequence for euler rotations
|
||||||
mjString* meshdir; // mesh and hfield directory
|
mjString* meshdir; // mesh and hfield directory
|
||||||
mjString* texturedir; // texture directory
|
mjString* texturedir; // texture directory
|
||||||
mjtByte discardvisual; // discard visual geoms in parser
|
mjtByte discardvisual; // discard visual geoms in parser
|
||||||
|
|||||||
@@ -8266,7 +8266,7 @@ STRUCTS: Mapping[str, StructDecl] = dict([
|
|||||||
doc='angles in radians or degrees',
|
doc='angles in radians or degrees',
|
||||||
),
|
),
|
||||||
StructFieldDecl(
|
StructFieldDecl(
|
||||||
name='euler',
|
name='eulerseq',
|
||||||
type=ArrayType(
|
type=ArrayType(
|
||||||
inner_type=ValueType(name='char'),
|
inner_type=ValueType(name='char'),
|
||||||
extents=(3,),
|
extents=(3,),
|
||||||
|
|||||||
@@ -34,9 +34,9 @@ class SpecsTest(absltest.TestCase):
|
|||||||
spec = mujoco.MjSpec()
|
spec = mujoco.MjSpec()
|
||||||
|
|
||||||
# Check that euler sequence order is set correctly.
|
# Check that euler sequence order is set correctly.
|
||||||
self.assertEqual(spec.euler[0], ord('x'))
|
self.assertEqual(spec.eulerseq[0], ord('x'))
|
||||||
spec.euler = ['z', 'y', 'x']
|
spec.eulerseq = ['z', 'y', 'x']
|
||||||
self.assertEqual(spec.euler[0], ord('z'))
|
self.assertEqual(spec.eulerseq[0], ord('z'))
|
||||||
|
|
||||||
# Add a body, check that it has default orientation.
|
# Add a body, check that it has default orientation.
|
||||||
body = spec.worldbody.add_body()
|
body = spec.worldbody.add_body()
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
#include <mujoco/mjmodel.h>
|
#include <mujoco/mjmodel.h>
|
||||||
#include <mujoco/mjtnum.h>
|
#include <mujoco/mjtnum.h>
|
||||||
#include <mujoco/mjplugin.h>
|
#include <mujoco/mjplugin.h>
|
||||||
|
#include <mujoco/mujoco.h>
|
||||||
#include "cc/array_safety.h"
|
#include "cc/array_safety.h"
|
||||||
#include "engine/engine_crossplatform.h"
|
#include "engine/engine_crossplatform.h"
|
||||||
#include "engine/engine_resource.h"
|
#include "engine/engine_resource.h"
|
||||||
@@ -145,7 +146,7 @@ bool mjCFlexcomp::Make(mjSpec* spec, mjsBody* body, char* error, int error_sz) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// compute orientation
|
// compute orientation
|
||||||
const char* alterr = mjs_resolveOrientation(quat, model->spec.degree, model->spec.euler, &alt);
|
const char* alterr = mjs_resolveOrientation(quat, model->spec.degree, model->spec.eulerseq, &alt);
|
||||||
if (alterr) {
|
if (alterr) {
|
||||||
return comperr(error, alterr, error_sz);
|
return comperr(error, alterr, error_sz);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,9 +36,9 @@ void mjs_defaultSpec(mjSpec* spec) {
|
|||||||
spec->autolimits = 1;
|
spec->autolimits = 1;
|
||||||
spec->settotalmass = -1;
|
spec->settotalmass = -1;
|
||||||
spec->degree = 1;
|
spec->degree = 1;
|
||||||
spec->euler[0] = 'x';
|
spec->eulerseq[0] = 'x';
|
||||||
spec->euler[1] = 'y';
|
spec->eulerseq[1] = 'y';
|
||||||
spec->euler[2] = 'z';
|
spec->eulerseq[2] = 'z';
|
||||||
spec->convexhull = 1;
|
spec->convexhull = 1;
|
||||||
spec->usethread = 1;
|
spec->usethread = 1;
|
||||||
spec->inertiafromgeom = mjINERTIAFROMGEOM_AUTO;
|
spec->inertiafromgeom = mjINERTIAFROMGEOM_AUTO;
|
||||||
|
|||||||
@@ -1388,7 +1388,7 @@ void mjCBody::Compile(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check and process orientation alternatives for body
|
// check and process orientation alternatives for body
|
||||||
const char* err = ResolveOrientation(quat, model->degree, model->euler, alt);
|
const char* err = ResolveOrientation(quat, model->degree, model->eulerseq, alt);
|
||||||
if (err) {
|
if (err) {
|
||||||
throw mjCError(this, "error '%s' in frame alternative", err);
|
throw mjCError(this, "error '%s' in frame alternative", err);
|
||||||
}
|
}
|
||||||
@@ -1650,7 +1650,7 @@ void mjCFrame::Compile() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CopyFromSpec();
|
CopyFromSpec();
|
||||||
const char* err = ResolveOrientation(quat, model->spec.degree, model->spec.euler, alt);
|
const char* err = ResolveOrientation(quat, model->spec.degree, model->spec.eulerseq, alt);
|
||||||
if (err) {
|
if (err) {
|
||||||
throw mjCError(this, "orientation specification error '%s' in site %d", err, id);
|
throw mjCError(this, "orientation specification error '%s' in site %d", err, id);
|
||||||
}
|
}
|
||||||
@@ -2394,7 +2394,7 @@ void mjCGeom::Compile(void) {
|
|||||||
|
|
||||||
// not 'fromto': try alternative
|
// not 'fromto': try alternative
|
||||||
else {
|
else {
|
||||||
const char* err = ResolveOrientation(quat, model->degree, model->euler, alt);
|
const char* err = ResolveOrientation(quat, model->degree, model->eulerseq, alt);
|
||||||
if (err) {
|
if (err) {
|
||||||
throw mjCError(this, "orientation specification error '%s' in geom %d", err, id);
|
throw mjCError(this, "orientation specification error '%s' in geom %d", err, id);
|
||||||
}
|
}
|
||||||
@@ -2643,7 +2643,7 @@ void mjCSite::Compile(void) {
|
|||||||
|
|
||||||
// alternative orientation
|
// alternative orientation
|
||||||
else {
|
else {
|
||||||
const char* err = ResolveOrientation(quat, model->degree, model->euler, alt);
|
const char* err = ResolveOrientation(quat, model->degree, model->eulerseq, alt);
|
||||||
if (err) {
|
if (err) {
|
||||||
throw mjCError(this, "orientation specification error '%s' in site %d", err, id);
|
throw mjCError(this, "orientation specification error '%s' in site %d", err, id);
|
||||||
}
|
}
|
||||||
@@ -2754,7 +2754,7 @@ void mjCCamera::Compile(void) {
|
|||||||
userdata_.resize(model->nuser_cam);
|
userdata_.resize(model->nuser_cam);
|
||||||
|
|
||||||
// process orientation specifications
|
// process orientation specifications
|
||||||
const char* err = ResolveOrientation(quat, model->degree, model->euler, alt);
|
const char* err = ResolveOrientation(quat, model->degree, model->eulerseq, alt);
|
||||||
if (err) {
|
if (err) {
|
||||||
throw mjCError(this, "orientation specification error '%s' in camera %d", err, id);
|
throw mjCError(this, "orientation specification error '%s' in camera %d", err, id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -959,7 +959,7 @@ void mjXReader::Compiler(XMLElement* section, mjSpec* spec) {
|
|||||||
if (text.size()!=3) {
|
if (text.size()!=3) {
|
||||||
throw mjXError(section, "euler format must have length 3");
|
throw mjXError(section, "euler format must have length 3");
|
||||||
}
|
}
|
||||||
memcpy(spec->euler, text.c_str(), 3);
|
memcpy(spec->eulerseq, text.c_str(), 3);
|
||||||
}
|
}
|
||||||
if (ReadAttrTxt(section, "assetdir", text)) {
|
if (ReadAttrTxt(section, "assetdir", text)) {
|
||||||
mjs_setString(spec->meshdir, text.c_str());
|
mjs_setString(spec->meshdir, text.c_str());
|
||||||
@@ -3393,7 +3393,7 @@ void mjXReader::Body(XMLElement* section, mjsBody* pbody, mjsFrame* frame) {
|
|||||||
alt.type = mjORIENTATION_EULER;
|
alt.type = mjORIENTATION_EULER;
|
||||||
mjuu_copyvec(alt.euler, euler, 3);
|
mjuu_copyvec(alt.euler, euler, 3);
|
||||||
double rotation[4] = {1, 0, 0, 0};
|
double rotation[4] = {1, 0, 0, 0};
|
||||||
mjs_resolveOrientation(rotation, model->degree, model->euler, &alt);
|
mjs_resolveOrientation(rotation, model->degree, model->eulerseq, &alt);
|
||||||
|
|
||||||
// read childdef
|
// read childdef
|
||||||
mjsDefault* childdef = 0;
|
mjsDefault* childdef = 0;
|
||||||
@@ -3424,7 +3424,7 @@ void mjXReader::Body(XMLElement* section, mjsBody* pbody, mjsFrame* frame) {
|
|||||||
alt.euler[0] = i*euler[0];
|
alt.euler[0] = i*euler[0];
|
||||||
alt.euler[1] = i*euler[1];
|
alt.euler[1] = i*euler[1];
|
||||||
alt.euler[2] = i*euler[2];
|
alt.euler[2] = i*euler[2];
|
||||||
mjs_resolveOrientation(quat, model->degree, model->euler, &alt);
|
mjs_resolveOrientation(quat, model->degree, model->eulerseq, &alt);
|
||||||
mjuu_setvec(pframe->quat, quat[0], quat[1], quat[2], quat[3]);
|
mjuu_setvec(pframe->quat, quat[0], quat[1], quat[2], quat[3]);
|
||||||
|
|
||||||
// process suffix
|
// process suffix
|
||||||
|
|||||||
Reference in New Issue
Block a user