Remember compiler options during attach.
Note: - Move compiler options into `mjsCompiler` struct. - The compiler options from the attached model are not written by mj_SaveXML. PiperOrigin-RevId: 689391440 Change-Id: I1d63c146a32f87c737b7a55b64a54b0ffe3aecc9
This commit is contained in:
committed by
Copybara-Service
parent
1043633cc3
commit
159f23e6b4
+2
-2
@@ -365,8 +365,8 @@ mjSpec* ParseXML(const char* filename, const mjVFS* vfs,
|
||||
// set reasonable default for parsing a URDF
|
||||
// this is separate from the Parser to allow multiple URDFs to be loaded.
|
||||
spec->strippath = true;
|
||||
spec->fusestatic = true;
|
||||
spec->discardvisual = true;
|
||||
spec->compiler.fusestatic = true;
|
||||
spec->compiler.discardvisual = true;
|
||||
|
||||
parser.SetModel(spec);
|
||||
parser.Parse(root);
|
||||
|
||||
@@ -972,19 +972,19 @@ void mjXReader::Compiler(XMLElement* section, mjSpec* spec) {
|
||||
|
||||
// top-level attributes
|
||||
if (MapValue(section, "autolimits", &n, bool_map, 2)) {
|
||||
spec->autolimits = (n==1);
|
||||
spec->compiler.autolimits = (n==1);
|
||||
}
|
||||
ReadAttr(section, "boundmass", 1, &spec->boundmass, text);
|
||||
ReadAttr(section, "boundinertia", 1, &spec->boundinertia, text);
|
||||
ReadAttr(section, "settotalmass", 1, &spec->settotalmass, text);
|
||||
ReadAttr(section, "boundmass", 1, &spec->compiler.boundmass, text);
|
||||
ReadAttr(section, "boundinertia", 1, &spec->compiler.boundinertia, text);
|
||||
ReadAttr(section, "settotalmass", 1, &spec->compiler.settotalmass, text);
|
||||
if (MapValue(section, "balanceinertia", &n, bool_map, 2)) {
|
||||
spec->balanceinertia = (n==1);
|
||||
spec->compiler.balanceinertia = (n==1);
|
||||
}
|
||||
if (MapValue(section, "strippath", &n, bool_map, 2)) {
|
||||
spec->strippath = (n==1);
|
||||
}
|
||||
if (MapValue(section, "fitaabb", &n, bool_map, 2)) {
|
||||
spec->fitaabb = (n==1);
|
||||
spec->compiler.fitaabb = (n==1);
|
||||
}
|
||||
if (MapValue(section, "coordinate", &n, coordinate_map, 2)) {
|
||||
if (n==1) {
|
||||
@@ -993,13 +993,13 @@ void mjXReader::Compiler(XMLElement* section, mjSpec* spec) {
|
||||
}
|
||||
}
|
||||
if (MapValue(section, "angle", &n, angle_map, 2)) {
|
||||
spec->degree = (n==1);
|
||||
spec->compiler.degree = (n==1);
|
||||
}
|
||||
if (ReadAttrTxt(section, "eulerseq", text)) {
|
||||
if (text.size()!=3) {
|
||||
throw mjXError(section, "euler format must have length 3");
|
||||
}
|
||||
memcpy(spec->eulerseq, text.c_str(), 3);
|
||||
memcpy(spec->compiler.eulerseq, text.c_str(), 3);
|
||||
}
|
||||
if (ReadAttrTxt(section, "assetdir", text)) {
|
||||
mjs_setString(spec->meshdir, text.c_str());
|
||||
@@ -1014,27 +1014,27 @@ void mjXReader::Compiler(XMLElement* section, mjSpec* spec) {
|
||||
mjs_setString(spec->texturedir, texturedir.c_str());
|
||||
}
|
||||
if (MapValue(section, "discardvisual", &n, bool_map, 2)) {
|
||||
spec->discardvisual = (n==1);
|
||||
spec->compiler.discardvisual = (n==1);
|
||||
}
|
||||
if (MapValue(section, "convexhull", &n, bool_map, 2)) {
|
||||
spec->convexhull = (n==1);
|
||||
spec->compiler.convexhull = (n==1);
|
||||
}
|
||||
if (MapValue(section, "usethread", &n, bool_map, 2)) {
|
||||
spec->usethread = (n==1);
|
||||
spec->compiler.usethread = (n==1);
|
||||
}
|
||||
if (MapValue(section, "fusestatic", &n, bool_map, 2)) {
|
||||
spec->fusestatic = (n==1);
|
||||
spec->compiler.fusestatic = (n==1);
|
||||
}
|
||||
MapValue(section, "inertiafromgeom", &spec->inertiafromgeom, TFAuto_map, 3);
|
||||
ReadAttr(section, "inertiagrouprange", 2, spec->inertiagrouprange, text);
|
||||
MapValue(section, "inertiafromgeom", &spec->compiler.inertiafromgeom, TFAuto_map, 3);
|
||||
ReadAttr(section, "inertiagrouprange", 2, spec->compiler.inertiagrouprange, text);
|
||||
if (MapValue(section, "alignfree", &n, bool_map, 2)) {
|
||||
spec->alignfree = (n==1);
|
||||
spec->compiler.alignfree = (n==1);
|
||||
}
|
||||
|
||||
// lengthrange subelement
|
||||
XMLElement* elem = FindSubElem(section, "lengthrange");
|
||||
if (elem) {
|
||||
mjLROpt* opt = &(spec->LRopt);
|
||||
mjLROpt* opt = &(spec->compiler.LRopt);
|
||||
|
||||
// flags
|
||||
MapValue(elem, "mode", &opt->mode, lrmode_map, lrmode_sz);
|
||||
@@ -2759,7 +2759,7 @@ void mjXReader::OneFlexcomp(XMLElement* elem, mjsBody* body, const mjVFS* vfs) {
|
||||
|
||||
// make flexcomp
|
||||
char error[200];
|
||||
bool res = fcomp.Make(spec, body, error, 200);
|
||||
bool res = fcomp.Make(body, error, 200);
|
||||
|
||||
// throw error
|
||||
if (!res) {
|
||||
@@ -3575,7 +3575,7 @@ void mjXReader::Body(XMLElement* section, mjsBody* body, mjsFrame* frame,
|
||||
alt.type = mjORIENTATION_EULER;
|
||||
mjuu_copyvec(alt.euler, euler, 3);
|
||||
double rotation[4] = {1, 0, 0, 0};
|
||||
mjs_resolveOrientation(rotation, spec->degree, spec->eulerseq, &alt);
|
||||
mjs_resolveOrientation(rotation, spec->compiler.degree, spec->compiler.eulerseq, &alt);
|
||||
|
||||
// read childdef
|
||||
mjsDefault* childdef = 0;
|
||||
@@ -3610,7 +3610,7 @@ void mjXReader::Body(XMLElement* section, mjsBody* body, mjsFrame* frame,
|
||||
alt.euler[0] = i*euler[0];
|
||||
alt.euler[1] = i*euler[1];
|
||||
alt.euler[2] = i*euler[2];
|
||||
mjs_resolveOrientation(quat, spec->degree, spec->eulerseq, &alt);
|
||||
mjs_resolveOrientation(quat, spec->compiler.degree, spec->compiler.eulerseq, &alt);
|
||||
mjuu_setvec(pframe->quat, quat[0], quat[1], quat[2], quat[3]);
|
||||
|
||||
// process suffix
|
||||
|
||||
@@ -920,8 +920,8 @@ void mjXWriter::Compiler(XMLElement* root) {
|
||||
XMLElement* section = InsertEnd(root, "compiler");
|
||||
|
||||
// settings
|
||||
if (!model->convexhull) {
|
||||
WriteAttrTxt(section, "convexhull", FindValue(bool_map, 2, model->convexhull));
|
||||
if (!model->compiler.convexhull) {
|
||||
WriteAttrTxt(section, "convexhull", FindValue(bool_map, 2, model->compiler.convexhull));
|
||||
}
|
||||
WriteAttrTxt(section, "angle", "radian");
|
||||
if (!model->get_meshdir().empty()) {
|
||||
@@ -930,20 +930,20 @@ void mjXWriter::Compiler(XMLElement* root) {
|
||||
if (!model->get_texturedir().empty()) {
|
||||
WriteAttrTxt(section, "texturedir", model->get_texturedir());
|
||||
}
|
||||
if (!model->usethread) {
|
||||
if (!model->compiler.usethread) {
|
||||
WriteAttrTxt(section, "usethread", "false");
|
||||
}
|
||||
|
||||
if (model->boundmass) {
|
||||
WriteAttr(section, "boundmass", 1, &model->boundmass);
|
||||
if (model->compiler.boundmass) {
|
||||
WriteAttr(section, "boundmass", 1, &model->compiler.boundmass);
|
||||
}
|
||||
if (model->boundinertia) {
|
||||
WriteAttr(section, "boundinertia", 1, &model->boundinertia);
|
||||
if (model->compiler.boundinertia) {
|
||||
WriteAttr(section, "boundinertia", 1, &model->compiler.boundinertia);
|
||||
}
|
||||
if (model->alignfree) {
|
||||
if (model->compiler.alignfree) {
|
||||
WriteAttrTxt(section, "alignfree", "true");
|
||||
}
|
||||
if (!model->autolimits) {
|
||||
if (!model->compiler.autolimits) {
|
||||
WriteAttrTxt(section, "autolimits", "false");
|
||||
}
|
||||
}
|
||||
@@ -1611,7 +1611,7 @@ void mjXWriter::Body(XMLElement* elem, mjCBody* body, mjCFrame* frame, string_vi
|
||||
WriteVector(elem, "user", body->get_userdata());
|
||||
|
||||
// write inertial
|
||||
if (body->explicitinertial && model->inertiafromgeom!=mjINERTIAFROMGEOM_TRUE) {
|
||||
if (body->explicitinertial && model->compiler.inertiafromgeom!=mjINERTIAFROMGEOM_TRUE) {
|
||||
XMLElement* inertial = InsertEnd(elem, "inertial");
|
||||
WriteAttr(inertial, "pos", 3, body->ipos);
|
||||
WriteAttr(inertial, "quat", 4, body->iquat, unitq);
|
||||
|
||||
+2
-2
@@ -109,7 +109,7 @@ void mjXURDF::Parse(
|
||||
}
|
||||
|
||||
// enforce required compiler defaults for URDF
|
||||
spec->degree = false;
|
||||
spec->compiler.degree = false;
|
||||
|
||||
// get model name
|
||||
std::string modelname;
|
||||
@@ -316,7 +316,7 @@ void mjXURDF::Body(XMLElement* body_elem) {
|
||||
}
|
||||
}
|
||||
// create geom if not discarded
|
||||
if (!spec->discardvisual) {
|
||||
if (!spec->compiler.discardvisual) {
|
||||
pgeom = Geom(elem, pbody, false);
|
||||
|
||||
// save color
|
||||
|
||||
Reference in New Issue
Block a user