Add engine settings to mjmModel.
PiperOrigin-RevId: 608915453 Change-Id: Ic58566d7a9cdb57e25954caec69f595c8c9ee88a
This commit is contained in:
committed by
Copybara-Service
parent
a4a621f6e3
commit
7edacd39cd
@@ -39,7 +39,6 @@
|
||||
#include "user/user_api.h"
|
||||
#include "user/user_composite.h"
|
||||
#include "user/user_flexcomp.h"
|
||||
#include "user/user_model.h"
|
||||
#include "user/user_util.h"
|
||||
#include "xml/xml_base.h"
|
||||
#include "xml/xml_util.h"
|
||||
@@ -805,7 +804,10 @@ void mjXReader::Parse(XMLElement* root) {
|
||||
}
|
||||
|
||||
// get model name
|
||||
ReadAttrTxt(root, "model", model->modelname);
|
||||
string modelname;
|
||||
if (ReadAttrTxt(root, "model", modelname)) {
|
||||
mjm_setString(model->spec.modelname, modelname.c_str());
|
||||
}
|
||||
|
||||
// get comment
|
||||
if (root->FirstChild() && root->FirstChild()->ToComment()) {
|
||||
@@ -823,12 +825,12 @@ void mjXReader::Parse(XMLElement* root) {
|
||||
|
||||
for (XMLElement* section = FirstChildElement(root, "option"); section;
|
||||
section = NextSiblingElement(section, "option")) {
|
||||
Option(section, &model->option);
|
||||
Option(section, &model->spec.option);
|
||||
}
|
||||
|
||||
for (XMLElement* section = FirstChildElement(root, "size"); section;
|
||||
section = NextSiblingElement(section, "size")) {
|
||||
Size(section, model);
|
||||
Size(section, &model->spec);
|
||||
}
|
||||
|
||||
//------------------ parse MJCF-specific sections
|
||||
@@ -1096,7 +1098,7 @@ void mjXReader::Option(XMLElement* section, mjOption* opt) {
|
||||
|
||||
|
||||
// size section parser
|
||||
void mjXReader::Size(XMLElement* section, mjCModel* mod) {
|
||||
void mjXReader::Size(XMLElement* section, mjmModel* mod) {
|
||||
// read memory bytes
|
||||
{
|
||||
constexpr char err_msg[] =
|
||||
@@ -2936,7 +2938,7 @@ void mjXReader::Custom(XMLElement* section) {
|
||||
void mjXReader::Visual(XMLElement* section) {
|
||||
string text, name;
|
||||
XMLElement* elem;
|
||||
mjVisual* vis = &model->visual;
|
||||
mjVisual* vis = &model->spec.visual;
|
||||
|
||||
// iterate over child elements
|
||||
elem = FirstChildElement(section);
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
|
||||
#include <mujoco/mujoco.h>
|
||||
#include "user/user_api.h"
|
||||
#include "user/user_model.h"
|
||||
#include "xml/xml_base.h"
|
||||
#include "xml/xml_util.h"
|
||||
|
||||
@@ -45,7 +44,7 @@ class mjXReader : public mjXBase {
|
||||
// XML sections embedded in all formats
|
||||
static void Compiler(tinyxml2::XMLElement* section, mjmModel* mod); // compiler section
|
||||
static void Option(tinyxml2::XMLElement* section, mjOption* opt); // option section
|
||||
static void Size(tinyxml2::XMLElement* section, mjCModel* mod); // size section
|
||||
static void Size(tinyxml2::XMLElement* section, mjmModel* mod); // size section
|
||||
|
||||
private:
|
||||
// XML section specific to MJCF
|
||||
|
||||
@@ -775,7 +775,7 @@ string mjXWriter::Write(char *error, size_t error_sz) {
|
||||
// create document and root
|
||||
XMLDocument doc;
|
||||
XMLElement* root = doc.NewElement("mujoco");
|
||||
root->SetAttribute("model", model->modelname.c_str());
|
||||
root->SetAttribute("model", mjm_getString(model->modelname));
|
||||
|
||||
// insert root
|
||||
doc.InsertFirstChild(root);
|
||||
|
||||
+6
-3
@@ -97,11 +97,11 @@ void mjXURDF::Parse(
|
||||
}
|
||||
|
||||
if ((section = FindSubElem(mjc, "option"))) {
|
||||
mjXReader::Option(section, &model->option);
|
||||
mjXReader::Option(section, &model->spec.option);
|
||||
}
|
||||
|
||||
if ((section = FindSubElem(mjc, "size"))) {
|
||||
mjXReader::Size(section, model);
|
||||
mjXReader::Size(section, &model->spec);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,7 +109,10 @@ void mjXURDF::Parse(
|
||||
model->spec.degree = false;
|
||||
|
||||
// get model name
|
||||
ReadAttrTxt(root, "name", model->modelname);
|
||||
std::string modelname;
|
||||
if (ReadAttrTxt(root, "name", modelname)) {
|
||||
mjm_setString(model->spec.modelname, modelname.c_str());
|
||||
}
|
||||
|
||||
// find and register all materials
|
||||
MakeMaterials(root);
|
||||
|
||||
Reference in New Issue
Block a user