allow specifying static bodies when parsing URDF
PiperOrigin-RevId: 547664406 Change-Id: I4b555431d1877fb7547c6b550387cd4230c2b0c4
This commit is contained in:
committed by
Copybara-Service
parent
242aea93c6
commit
8f3c488de8
+5
-3
@@ -79,7 +79,9 @@ std::string mjXURDF::GetPrefixedName(const std::string& name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// actual parser
|
// 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;
|
std::string name, text;
|
||||||
XMLElement *elem, *temp;
|
XMLElement *elem, *temp;
|
||||||
int id_parent, id_child;
|
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
|
// add a free joint to allow motion of the body
|
||||||
// if the mass is 0, assume the object is static
|
// if the mass is 0, assume the object is static
|
||||||
if (pbody->mass > 0) {
|
if (!static_body && pbody->mass > 0) {
|
||||||
auto pjoint = pbody->AddJoint();
|
auto pjoint = pbody->AddJoint();
|
||||||
pjoint->name = urName[i] + "_free_joint";
|
pjoint->name = urName[i] + "_free_joint";
|
||||||
pjoint->type = mjJNT_FREE;
|
pjoint->type = mjJNT_FREE;
|
||||||
@@ -350,7 +352,7 @@ void mjXURDF::Parse(XMLElement* root) {
|
|||||||
mjuu_setvec(pos, 0, 0, 0);
|
mjuu_setvec(pos, 0, 0, 0);
|
||||||
double quat[4] = {1, 0, 0, 0};
|
double quat[4] = {1, 0, 0, 0};
|
||||||
mjuu_setvec(quat, 1, 0, 0, 0);
|
mjuu_setvec(quat, 1, 0, 0, 0);
|
||||||
Parse(root, /*prefix=*/"", pos, quat);
|
Parse(root, /*prefix=*/"", pos, quat, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// parse joint
|
// parse joint
|
||||||
|
|||||||
+6
-1
@@ -35,7 +35,12 @@ class mjXURDF : public mjXBase {
|
|||||||
virtual ~mjXURDF(); // destructor
|
virtual ~mjXURDF(); // destructor
|
||||||
|
|
||||||
// parse and set frame of base link and append a prefix to the name
|
// 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
|
void Parse(tinyxml2::XMLElement* root); // main parser
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user