Replace name attribute with setters and getters in the C API of mjSpec.
PiperOrigin-RevId: 778816015 Change-Id: Ieffb7a5bce37e887ff009f9a02d2434435e79ca1
This commit is contained in:
committed by
Copybara-Service
parent
1c5d47c94b
commit
594e17074a
+13
-13
@@ -216,7 +216,7 @@ void mjXURDF::Parse(
|
||||
// if the mass is 0, assume the object is static
|
||||
if (!static_body && pbody->mass > 0) {
|
||||
mjsJoint* pjoint = mjs_addJoint(pbody, 0);
|
||||
mjs_setString(pjoint->name, (urName[i] + "_free_joint").c_str());
|
||||
mjs_setName(pjoint->element, (urName[i] + "_free_joint").c_str());
|
||||
pjoint->type = mjJNT_FREE;
|
||||
}
|
||||
}
|
||||
@@ -327,7 +327,7 @@ void mjXURDF::Body(XMLElement* body_elem) {
|
||||
mjXUtil::ReadAttrTxt(elem, "name", geom_name);
|
||||
name = GetPrefixedName(name);
|
||||
if (urGeomNames.find(geom_name) == urGeomNames.end()) {
|
||||
mjs_setString(pgeom->name, geom_name.c_str());
|
||||
mjs_setName(pgeom->element, geom_name.c_str());
|
||||
urGeomNames.insert(geom_name);
|
||||
} else if (!geom_name.empty()) {
|
||||
std::cerr << "WARNING: Geom with duplicate name '" << geom_name
|
||||
@@ -350,7 +350,7 @@ void mjXURDF::Body(XMLElement* body_elem) {
|
||||
mjXUtil::ReadAttrTxt(elem, "name", geom_name);
|
||||
geom_name = GetPrefixedName(geom_name);
|
||||
if (urGeomNames.find(geom_name) == urGeomNames.end()) {
|
||||
mjs_setString(pgeom->name, geom_name.c_str());
|
||||
mjs_setName(pgeom->element, geom_name.c_str());
|
||||
urGeomNames.insert(geom_name);
|
||||
} else if (!geom_name.empty()) {
|
||||
std::cerr << "WARNING: Geom with duplicate name '" << geom_name
|
||||
@@ -420,7 +420,7 @@ void mjXURDF::Joint(XMLElement* joint_elem) {
|
||||
case 0: // revolute
|
||||
case 1: // continuous
|
||||
pjoint = mjs_addJoint(pbody, 0);
|
||||
mjs_setString(pjoint->name, jntname.c_str());
|
||||
mjs_setName(pjoint->element, jntname.c_str());
|
||||
pjoint->type = mjJNT_HINGE;
|
||||
mjuu_setvec(pjoint->pos, 0, 0, 0);
|
||||
mjuu_copyvec(pjoint->axis, axis, 3);
|
||||
@@ -428,7 +428,7 @@ void mjXURDF::Joint(XMLElement* joint_elem) {
|
||||
|
||||
case 2: // prismatic
|
||||
pjoint = mjs_addJoint(pbody, 0);
|
||||
mjs_setString(pjoint->name, jntname.c_str());
|
||||
mjs_setName(pjoint->element, jntname.c_str());
|
||||
pjoint->type = mjJNT_SLIDE;
|
||||
mjuu_setvec(pjoint->pos, 0, 0, 0);
|
||||
mjuu_copyvec(pjoint->axis, axis, 3);
|
||||
@@ -439,7 +439,7 @@ void mjXURDF::Joint(XMLElement* joint_elem) {
|
||||
|
||||
case 4: // floating
|
||||
pjoint = mjs_addJoint(pbody, 0);
|
||||
mjs_setString(pjoint->name, jntname.c_str());
|
||||
mjs_setName(pjoint->element, jntname.c_str());
|
||||
pjoint->type = mjJNT_FREE;
|
||||
break;
|
||||
|
||||
@@ -450,7 +450,7 @@ void mjXURDF::Joint(XMLElement* joint_elem) {
|
||||
|
||||
// construct slider along x
|
||||
pjoint = mjs_addJoint(pbody, 0);
|
||||
mjs_setString(pjoint->name, (jntname + "_TX").c_str());
|
||||
mjs_setName(pjoint->element, (jntname + "_TX").c_str());
|
||||
pjoint->type = mjJNT_SLIDE;
|
||||
tmpaxis[0] = mat[0];
|
||||
tmpaxis[1] = mat[3];
|
||||
@@ -460,7 +460,7 @@ void mjXURDF::Joint(XMLElement* joint_elem) {
|
||||
|
||||
// construct slider along y
|
||||
pjoint1 = mjs_addJoint(pbody, 0);
|
||||
mjs_setString(pjoint1->name, (jntname + "_TY").c_str());
|
||||
mjs_setName(pjoint1->element, (jntname + "_TY").c_str());
|
||||
pjoint1->type = mjJNT_SLIDE;
|
||||
tmpaxis[0] = mat[1];
|
||||
tmpaxis[1] = mat[4];
|
||||
@@ -470,7 +470,7 @@ void mjXURDF::Joint(XMLElement* joint_elem) {
|
||||
|
||||
// construct hinge around z = locaxis
|
||||
pjoint2 = mjs_addJoint(pbody, 0);
|
||||
mjs_setString(pjoint2->name, (jntname + "_RZ").c_str());
|
||||
mjs_setName(pjoint2->element, (jntname + "_RZ").c_str());
|
||||
pjoint2->type = mjJNT_HINGE;
|
||||
mjuu_setvec(pjoint2->pos, 0, 0, 0);
|
||||
mjuu_copyvec(pjoint2->axis, axis, 3);
|
||||
@@ -478,7 +478,7 @@ void mjXURDF::Joint(XMLElement* joint_elem) {
|
||||
|
||||
case 6: // ball joint
|
||||
pjoint = mjs_addJoint(pbody, 0);
|
||||
mjs_setString(pjoint->name, jntname.c_str());
|
||||
mjs_setName(pjoint->element, jntname.c_str());
|
||||
pjoint->type = mjJNT_BALL;
|
||||
mjuu_setvec(pjoint->pos, 0, 0, 0);
|
||||
mjuu_copyvec(pjoint->axis, axis, 3);
|
||||
@@ -530,7 +530,7 @@ mjsGeom* mjXURDF::Geom(XMLElement* geom_elem, mjsBody* pbody, bool collision) {
|
||||
|
||||
// add BOX geom, modify type later
|
||||
mjsGeom* pgeom = mjs_addGeom(pbody, 0);
|
||||
mjs_setString(pgeom->name, "");
|
||||
mjs_setName(pgeom->element, "");
|
||||
pgeom->type = mjGEOM_BOX;
|
||||
if (collision) {
|
||||
pgeom->contype = 1;
|
||||
@@ -624,7 +624,7 @@ mjsGeom* mjXURDF::Geom(XMLElement* geom_elem, mjsBody* pbody, bool collision) {
|
||||
// set fields
|
||||
if (newmesh) {
|
||||
mjs_setString(pmesh->file, meshfile.c_str());
|
||||
mjs_setString(pmesh->name, meshname.c_str());
|
||||
mjs_setName(pmesh->element, meshname.c_str());
|
||||
pmesh->scale[0] = meshscale[0];
|
||||
pmesh->scale[1] = meshscale[1];
|
||||
pmesh->scale[2] = meshscale[2];
|
||||
@@ -726,7 +726,7 @@ void mjXURDF::AddToTree(int n) {
|
||||
// add this body
|
||||
if (urName[n] != "world") {
|
||||
child = mjs_addBody(parent, 0);
|
||||
mjs_setString(child->name, urName[n].c_str());
|
||||
mjs_setName(child->element, urName[n].c_str());
|
||||
}
|
||||
|
||||
// add children recursively
|
||||
|
||||
Reference in New Issue
Block a user