Support spherical joint in URDF.

PiperOrigin-RevId: 642326650
Change-Id: Iec766800bc9ab7e022bd586fc5881df576d01331
This commit is contained in:
Baruch Tabanpour
2024-06-11 11:07:06 -07:00
committed by Copybara-Service
parent 07fc95ca9a
commit 5ed464b489
3 changed files with 107 additions and 6 deletions
+11 -2
View File
@@ -32,14 +32,15 @@
using tinyxml2::XMLElement;
// URDF joint type
static const int urJoint_sz = 6;
static const int urJoint_sz = 7;
static const mjMap urJoint_map[urJoint_sz] = {
{"revolute", 0},
{"continuous", 1},
{"prismatic", 2},
{"fixed", 3},
{"floating", 4},
{"planar", 5}
{"planar", 5},
{"spherical", 6} // Bullet physics supports ball joints (non-standard URDF)
};
@@ -474,6 +475,14 @@ void mjXURDF::Joint(XMLElement* joint_elem) {
pjoint2->type = mjJNT_HINGE;
mjuu_setvec(pjoint2->pos, 0, 0, 0);
mjuu_copyvec(pjoint2->axis, axis, 3);
break;
case 6: // ball joint
pjoint = mjs_addJoint(pbody, 0);
mjs_setString(pjoint->name, jntname.c_str());
pjoint->type = mjJNT_BALL;
mjuu_setvec(pjoint->pos, 0, 0, 0);
mjuu_copyvec(pjoint->axis, axis, 3);
}
// dynamics element