allow specifying static bodies when parsing URDF

PiperOrigin-RevId: 547664406
Change-Id: I4b555431d1877fb7547c6b550387cd4230c2b0c4
This commit is contained in:
Google DeepMind
2023-07-12 19:33:47 -07:00
committed by Copybara-Service
parent 242aea93c6
commit 8f3c488de8
2 changed files with 11 additions and 4 deletions
+5 -3
View File
@@ -79,7 +79,9 @@ std::string mjXURDF::GetPrefixedName(const std::string& name) {
}
// actual parser
void mjXURDF::Parse(XMLElement* root, const std::string& prefix, double* pos, double* quat) {
void mjXURDF::Parse(
XMLElement* root, const std::string& prefix, double* pos, double* quat,
const bool static_body) {
std::string name, text;
XMLElement *elem, *temp;
int id_parent, id_child;
@@ -208,7 +210,7 @@ void mjXURDF::Parse(XMLElement* root, const std::string& prefix, double* pos, do
// add a free joint to allow motion of the body
// if the mass is 0, assume the object is static
if (pbody->mass > 0) {
if (!static_body && pbody->mass > 0) {
auto pjoint = pbody->AddJoint();
pjoint->name = urName[i] + "_free_joint";
pjoint->type = mjJNT_FREE;
@@ -350,7 +352,7 @@ void mjXURDF::Parse(XMLElement* root) {
mjuu_setvec(pos, 0, 0, 0);
double quat[4] = {1, 0, 0, 0};
mjuu_setvec(quat, 1, 0, 0, 0);
Parse(root, /*prefix=*/"", pos, quat);
Parse(root, /*prefix=*/"", pos, quat, true);
}
// parse joint
+6 -1
View File
@@ -35,7 +35,12 @@ class mjXURDF : public mjXBase {
virtual ~mjXURDF(); // destructor
// parse and set frame of base link and append a prefix to the name
void Parse(tinyxml2::XMLElement* root, const std::string& prefix, double* pos, double* quat); // parse and set frame of base link
void Parse(
tinyxml2::XMLElement* root,
const std::string& prefix,
double* pos,
double* quat,
bool static_body);
void Parse(tinyxml2::XMLElement* root); // main parser
private: