Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/RcsCore/Rcs_URDFParser.c
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,33 @@ RcsJoint* parseJointURDF(xmlNode* node)
return jnt;
}

/*******************************************************************************
* Corrects the joint order.
* When executing the connectURDF function, previous joints do not necessarily
* exist (yet) which can mess up the joint order for the Jacobian backward traversal.
* Therefore, after calling connectURDF, this function must be called for making
* the joint order consistent.
******************************************************************************/
static void makeJointOrderConsistent(RcsBody* bdy)
{
RCSBODY_TRAVERSE_BODIES(bdy)
{
RcsBody* parentBdy = BODY->parent;
RcsJoint* prevJnt = RcsBody_lastJointBeforeBody(parentBdy);
RCSBODY_TRAVERSE_JOINTS(BODY)
{
if(prevJnt != JNT->prev)
{
RLOG(5, "Joint \"%s\" previous joint was \"%s\", previous joint now \"%s\"",
JNT->name, (JNT->prev == NULL) ? "NULL" : JNT->prev->name,
(prevJnt == NULL) ? "NULL" : prevJnt->name);
JNT->prev = prevJnt;
JNT->next = NULL;
}
}
}
}

/*******************************************************************************
* Connect bodies and joints.
* URDF is a bit limited in the sense that there's only one actuated joint
Expand Down Expand Up @@ -1049,6 +1076,9 @@ RcsBody* RcsGraph_rootBodyFromURDFFile(const char* filename,
RCHECK_MSG(root, "Couldn't find root link in URFD model - did you "
"define a cyclic model?");

// Make the joint order consistent
makeJointOrderConsistent(root);

// Clean up
xmlFreeDoc(doc);
RFREE(bdyVec);
Expand Down