Add sleep related data structures
PiperOrigin-RevId: 829055431 Change-Id: I1ccbd77a57044a754ae7db611b4c2c0010fbda53
This commit is contained in:
committed by
Copybara-Service
parent
3080e3424f
commit
252a0d73df
@@ -26,6 +26,7 @@
|
||||
|
||||
// keyword maps (defined in implementation files)
|
||||
extern const int joint_sz;
|
||||
extern const int bodysleep_sz;
|
||||
extern const int camlight_sz;
|
||||
extern const int lighttype_sz;
|
||||
extern const int integrator_sz;
|
||||
@@ -50,6 +51,7 @@ extern const mjMap bool_map[];
|
||||
extern const mjMap fluid_map[];
|
||||
extern const mjMap TFAuto_map[];
|
||||
extern const mjMap joint_map[];
|
||||
extern const mjMap bodysleep_map[];
|
||||
extern const mjMap geom_map[];
|
||||
extern const mjMap camlight_map[];
|
||||
extern const mjMap lighttype_map[];
|
||||
|
||||
@@ -110,18 +110,18 @@ const char* MJCF[nMJCF][mjXATTRNUM] = {
|
||||
"inttotal", "interval", "tolrange"},
|
||||
{">"},
|
||||
|
||||
{"option", "*", "26",
|
||||
{"option", "*", "27",
|
||||
"timestep", "impratio", "tolerance", "ls_tolerance", "noslip_tolerance",
|
||||
"ccd_tolerance", "gravity", "wind", "magnetic", "density", "viscosity",
|
||||
"ccd_tolerance", "sleep_tolerance", "gravity", "wind", "magnetic", "density", "viscosity",
|
||||
"o_margin", "o_solref", "o_solimp", "o_friction",
|
||||
"integrator", "cone", "jacobian",
|
||||
"solver", "iterations", "ls_iterations", "noslip_iterations", "ccd_iterations",
|
||||
"sdf_iterations", "sdf_initpoints", "actuatorgroupdisable"},
|
||||
{"<"},
|
||||
{"flag", "?", "24", "constraint", "equality", "frictionloss", "limit", "contact",
|
||||
"spring", "damper", "gravity", "clampctrl", "warmstart",
|
||||
"filterparent", "actuation", "refsafe", "sensor", "midphase", "eulerdamp", "autoreset",
|
||||
"nativeccd", "island", "override", "energy", "fwdinv", "invdiscrete", "multiccd"},
|
||||
{"flag", "?", "25", "constraint", "equality", "frictionloss", "limit", "contact",
|
||||
"spring", "damper", "gravity", "clampctrl", "warmstart", "filterparent", "actuation",
|
||||
"refsafe", "sensor", "midphase", "eulerdamp", "autoreset", "nativeccd", "island",
|
||||
"override", "energy", "fwdinv", "invdiscrete", "multiccd", "sleep"},
|
||||
{">"},
|
||||
|
||||
{"size", "*", "14", "memory", "njmax", "nconmax", "nstack", "nuserdata", "nkey",
|
||||
@@ -257,8 +257,8 @@ const char* MJCF[nMJCF][mjXATTRNUM] = {
|
||||
{"model", "*", "3", "name", "file", "content_type"},
|
||||
{">"},
|
||||
|
||||
{"body", "R", "11", "name", "childclass", "pos", "quat", "mocap",
|
||||
"axisangle", "xyaxes", "zaxis", "euler", "gravcomp", "user"},
|
||||
{"body", "R", "12", "name", "childclass", "pos", "quat", "mocap",
|
||||
"axisangle", "xyaxes", "zaxis", "euler", "gravcomp", "sleep", "user"},
|
||||
{"<"},
|
||||
{"inertial", "?", "9", "pos", "quat", "mass", "diaginertia",
|
||||
"axisangle", "xyaxes", "zaxis", "euler", "fullinertia"},
|
||||
@@ -554,6 +554,15 @@ const mjMap TFAuto_map[3] = {
|
||||
};
|
||||
|
||||
|
||||
// body sleep type
|
||||
const int bodysleep_sz = 4;
|
||||
const mjMap bodysleep_map[bodysleep_sz] = {
|
||||
{"auto", mjSLEEP_AUTO},
|
||||
{"never", mjSLEEP_NEVER},
|
||||
{"allowed", mjSLEEP_ALLOWED},
|
||||
{"init", mjSLEEP_INIT}
|
||||
};
|
||||
|
||||
// joint type
|
||||
const int joint_sz = 4;
|
||||
const mjMap joint_map[joint_sz] = {
|
||||
@@ -1136,6 +1145,7 @@ void mjXReader::Option(XMLElement* section, mjOption* opt) {
|
||||
ReadAttr(section, "ls_tolerance", 1, &opt->ls_tolerance, text);
|
||||
ReadAttr(section, "noslip_tolerance", 1, &opt->noslip_tolerance, text);
|
||||
ReadAttr(section, "ccd_tolerance", 1, &opt->ccd_tolerance, text);
|
||||
ReadAttr(section, "sleep_tolerance", 1, &opt->sleep_tolerance, text);
|
||||
ReadAttr(section, "gravity", 3, opt->gravity, text);
|
||||
ReadAttr(section, "wind", 3, opt->wind, text);
|
||||
ReadAttr(section, "magnetic", 3, opt->magnetic, text);
|
||||
@@ -1213,6 +1223,7 @@ void mjXReader::Option(XMLElement* section, mjOption* opt) {
|
||||
READENBL("fwdinv", mjENBL_FWDINV)
|
||||
READENBL("invdiscrete", mjENBL_INVDISCRETE)
|
||||
READENBL("multiccd", mjENBL_MULTICCD)
|
||||
READENBL("sleep", mjENBL_SLEEP)
|
||||
#undef READENBL
|
||||
}
|
||||
}
|
||||
@@ -3709,8 +3720,11 @@ void mjXReader::Body(XMLElement* section, mjsBody* body, mjsFrame* frame,
|
||||
}
|
||||
ReadAlternative(elem, child->alt);
|
||||
|
||||
// read gravcomp
|
||||
// gravcomp, sleep policy
|
||||
ReadAttr(elem, "gravcomp", 1, &child->gravcomp, text);
|
||||
if (MapValue(elem, "sleep", &n, bodysleep_map, bodysleep_sz)) {
|
||||
child->sleep = (mjtSleepPolicy) n;
|
||||
}
|
||||
|
||||
// read userdata
|
||||
std::vector<double> userdata;
|
||||
|
||||
@@ -995,6 +995,7 @@ void mjXWriter::Option(XMLElement* root) {
|
||||
WriteAttr(section, "ls_tolerance", 1, &model->option.ls_tolerance, &opt.ls_tolerance);
|
||||
WriteAttr(section, "noslip_tolerance", 1, &model->option.noslip_tolerance, &opt.noslip_tolerance);
|
||||
WriteAttr(section, "ccd_tolerance", 1, &model->option.ccd_tolerance, &opt.ccd_tolerance);
|
||||
WriteAttr(section, "sleep_tolerance", 1, &model->option.sleep_tolerance, &opt.sleep_tolerance);
|
||||
WriteAttr(section, "gravity", 3, model->option.gravity, opt.gravity);
|
||||
WriteAttr(section, "wind", 3, model->option.wind, opt.wind);
|
||||
WriteAttr(section, "magnetic", 3, model->option.magnetic, opt.magnetic);
|
||||
@@ -1067,6 +1068,7 @@ void mjXWriter::Option(XMLElement* root) {
|
||||
WRITEENBL("fwdinv", mjENBL_FWDINV)
|
||||
WRITEENBL("invdiscrete", mjENBL_INVDISCRETE)
|
||||
WRITEENBL("multiccd", mjENBL_MULTICCD)
|
||||
WRITEENBL("sleep", mjENBL_SLEEP)
|
||||
#undef WRITEENBL
|
||||
}
|
||||
|
||||
@@ -1644,6 +1646,14 @@ void mjXWriter::Body(XMLElement* elem, mjCBody* body, mjCFrame* frame, string_vi
|
||||
if (body->gravcomp) {
|
||||
WriteAttr(elem, "gravcomp", 1, &body->gravcomp);
|
||||
}
|
||||
|
||||
// sleep policy
|
||||
if (body->sleep != mjSLEEP_AUTO &&
|
||||
body->sleep != mjSLEEP_AUTO_NEVER &&
|
||||
body->sleep != mjSLEEP_AUTO_ALLOWED) {
|
||||
WriteAttrKey(elem, "sleep", bodysleep_map, bodysleep_sz, body->sleep);
|
||||
}
|
||||
|
||||
// userdata
|
||||
WriteVector(elem, "user", body->get_userdata());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user