1 #ifndef SimTK_SIMMATH_MULTIBODY_GRAPH_MAKER_H_
2 #define SimTK_SIMMATH_MULTIBODY_GRAPH_MAKER_H_
164 int addJointType(
const std::string& name,
166 bool haveGoodLoopJointAvailable =
false,
191 void addBody(
const std::string& name,
204 bool deleteBody(
const std::string& name);
238 void addJoint(
const std::string& name,
239 const std::string& type,
240 const std::string& parentBodyName,
241 const std::string& childBodyName,
242 bool mustBeLoopJoint,
253 bool deleteJoint(
const std::string& name);
257 void generateGraph();
261 void dumpGraph(std::ostream& out)
const;
273 {
return mobilizers[mobilizerNum]; }
286 {
return constraints[loopConstraintNum]; }
299 std::map<std::string,int>::const_iterator p =
300 bodyName2Num.find(bodyName);
301 return p==bodyName2Num.end() ? -1 : p->second;
316 std::map<std::string,int>::const_iterator p =
317 jointName2Num.find(jointName);
318 return p==jointName2Num.end() ? -1 : p->second;
325 {
return jointTypes[jointTypeNum]; }
328 std::map<std::string,int>::const_iterator p =
329 jointTypeName2Num.find(jointTypeName);
330 return p==jointTypeName2Num.end() ? -1 : p->second;
336 void setWeldJointTypeName(
const std::string& name)
337 { weldTypeName=name; initialize(); }
345 void setFreeJointTypeName(
const std::string& name)
346 { freeTypeName=name; initialize(); }
353 const std::string& getGroundBodyName()
const;
356 Body& updBody(
int bodyNum) {
return bodies[bodyNum];}
357 Joint& updJoint(
int jointNum) {
return joints[jointNum];}
358 Joint& updJoint(
const std::string& name) {
return joints[jointName2Num[name]];}
361 int splitBody(
int bodyNum);
362 int chooseNewBaseBody()
const;
363 void connectBodyToGround(
int bodyNum);
364 int addMobilizerForJoint(
int jointNum);
365 int findHeaviestUnassignedForwardJoint(
int inboardBody)
const;
366 int findHeaviestUnassignedReverseJoint(
int inboardBody)
const;
369 bool bodiesAreConnected(
int b1,
int b2)
const;
373 bodies.clear(); joints.clear(); jointTypes.clear();
374 bodyName2Num.clear(); jointName2Num.clear(); jointTypeName2Num.clear();
375 mobilizers.clear(); constraints.clear();
378 std::string weldTypeName, freeTypeName;
379 std::vector<Body> bodies;
380 std::vector<Joint> joints;
381 std::vector<JointType> jointTypes;
382 std::map<std::string,int> bodyName2Num;
383 std::map<std::string,int> jointName2Num;
384 std::map<std::string,int> jointTypeName2Num;
387 std::vector<Mobilizer> mobilizers;
388 std::vector<LoopConstraint> constraints;
397 explicit Body(
const std::string& name,
401 : name(name), mass(mass), mustBeBaseBody(mustBeBaseBody),
440 bool mustBeLoopJoint,
void*
userRef)
441 : name(name), jointTypeNum(jointTypeNum),
442 parentBodyNum(parentBodyNum), childBodyNum(childBodyNum),
443 mustBeLoopJoint(mustBeLoopJoint), userRef(userRef),
479 : name(name), numMobilities(numMobilities),
480 haveGoodLoopJointAvailable(haveGoodLoopJointAvailable),
497 : joint(-1), level(-1), inboardBody(-1), outboardBody(-1),
498 isReversed(false), mgm(0) {}
499 Mobilizer(
int jointNum,
int level,
int inboardBodyNum,
int outboardBodyNum,
501 : joint(jointNum), level(level), inboardBody(inboardBodyNum),
502 outboardBody(outboardBodyNum), isReversed(isReversed),
564 int getOutboardMasterBodyNum()
const
587 int parentBodyNum,
int childBodyNum,
589 : type(type), joint(jointNum),
590 parentBody(parentBodyNum), childBody(childBodyNum),
624 #endif // SimTK_SIMMATH_MULTIBODY_GRAPH_MAKER_H_