Use enum instead of NaNs for alternative orientation specification.
PiperOrigin-RevId: 627413508 Change-Id: I9f1a682a1533e1a3fa3cac0a462f28ce9b0fa192
This commit is contained in:
committed by
Copybara-Service
parent
f457789de1
commit
cf433a4ad9
+19
-7
@@ -54,13 +54,25 @@ void mjXBase::SetModel(mjSpec* _model) {
|
||||
// read alternative orientation specification
|
||||
int mjXBase::ReadAlternative(XMLElement* elem, mjsOrientation& alt) {
|
||||
string text;
|
||||
int read = (int)(elem->Attribute("quat") != 0) +
|
||||
(ReadAttr(elem, "axisangle", 4, alt.axisangle, text) ? 1 : 0) +
|
||||
(ReadAttr(elem, "xyaxes", 6, alt.xyaxes, text) ? 1 : 0) +
|
||||
(ReadAttr(elem, "zaxis", 3, alt.zaxis, text) ? 1 : 0) +
|
||||
(ReadAttr(elem, "euler", 3, alt.euler, text) ? 1 : 0);
|
||||
if (read > 1) {
|
||||
int numspec = (int)(elem->Attribute("quat") != 0);
|
||||
if (ReadAttr(elem, "axisangle", 4, alt.axisangle, text)) {
|
||||
numspec++;
|
||||
alt.type = mjORIENTATION_AXISANGLE;
|
||||
}
|
||||
if (ReadAttr(elem, "xyaxes", 6, alt.xyaxes, text)) {
|
||||
numspec++;
|
||||
alt.type = mjORIENTATION_XYAXES;
|
||||
}
|
||||
if (ReadAttr(elem, "zaxis", 3, alt.zaxis, text)) {
|
||||
numspec++;
|
||||
alt.type = mjORIENTATION_ZAXIS;
|
||||
}
|
||||
if (ReadAttr(elem, "euler", 3, alt.euler, text)) {
|
||||
numspec++;
|
||||
alt.type = mjORIENTATION_EULER;
|
||||
}
|
||||
if (numspec > 1) {
|
||||
throw mjXError(elem, "multiple orientation specifiers are not allowed");
|
||||
}
|
||||
return read;
|
||||
return numspec;
|
||||
}
|
||||
|
||||
@@ -635,6 +635,7 @@ void mjXURDF::Origin(XMLElement* origin_elem, double* pos, double* quat) {
|
||||
mjsOrientation alt;
|
||||
mjs_defaultOrientation(alt);
|
||||
if (ReadAttr(temp, "rpy", 3, alt.euler, text)) {
|
||||
alt.type = mjORIENTATION_EULER;
|
||||
mjs_resolveOrientation(quat, 0, "XYZ", &alt);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user