rbd::MultiBodyGraph Class Reference

#include <RBDyn/RBDyn/MultiBodyGraph.h>

Classes

struct  Arc
 
struct  Node
 

Public Member Functions

 MultiBodyGraph (const std::string rootName="Root")
 
 MultiBodyGraph (const MultiBodyGraph &mbg)
 
 ~MultiBodyGraph ()
 
MultiBodyGraphoperator= (const MultiBodyGraph &mbg)
 
void clear ()
 
void addBody (const Body &B)
 
void addJoint (const Joint &J)
 
void linkBodies (const std::string &b1Name, const sva::PTransformd &tB1, const std::string &b2Name, const sva::PTransformd &tB2, const std::string &jointName, bool isB1toB2=true)
 
const std::shared_ptr< NodenodeByName (const std::string &name) const
 
const std::shared_ptr< JointjointByName (const std::string &name) const
 
std::size_t nrNodes () const
 
std::size_t nrJoints () const
 
MultiBody makeMultiBody (const std::string &rootBodyName, bool isFixed, const sva::PTransformd &X_0_j0=sva::PTransformd::Identity(), const sva::PTransformd &X_b0_j0=sva::PTransformd::Identity()) const
 
MultiBody makeMultiBody (const std::string &rootBodyName, Joint::Type rootJointType, const sva::PTransformd &X_0_j0=sva::PTransformd::Identity(), const sva::PTransformd &X_b0_j0=sva::PTransformd::Identity()) const
 
MultiBody makeMultiBody (const std::string &rootBodyName, Joint::Type rootJointType, const Eigen::Vector3d &axis, const sva::PTransformd &X_0_j0=sva::PTransformd::Identity(), const sva::PTransformd &X_b0_j0=sva::PTransformd::Identity()) const
 
void removeJoint (const std::string &rootBodyName, const std::string &jointName)
 
void removeJoints (const std::string &rootBodyName, const std::vector< std::string > &joints)
 
void mergeSubBodies (const std::string &rootBodyName, const std::string &jointName, const std::map< std::string, std::vector< double >> &jointPosByName)
 
std::map< std::string, sva::PTransformd > bodiesBaseTransform (const std::string &rootBodyName, const sva::PTransformd &X_b0_j0=sva::PTransformd::Identity())
 
std::map< std::string, std::vector< std::string > > successorJoints (const std::string &rootBodyName)
 
std::map< std::string, std::string > predecessorJoint (const std::string &rootBodyName)
 

Static Public Member Functions

static MultiBodyGraph fixJoints (const MultiBodyGraph &other, const std::vector< std::string > &jointsToFix, bool fixAllJoints=false)
 

Protected Attributes

std::string rootJointName_
 
std::vector< std::shared_ptr< Node > > nodes_
 
std::vector< std::shared_ptr< Joint > > joints_
 
std::map< std::string, std::shared_ptr< Node > > bodyNameToNode_
 
std::map< std::string, std::shared_ptr< Joint > > jointNameToJoint_
 

Detailed Description

Graph representation of the robot. Provide a undirected graph representation of the robot that allow to create a kinematic tree from any body as root. The graph must be cycle free (closed loop is not supported).

Constructor & Destructor Documentation

◆ MultiBodyGraph() [1/2]

rbd::MultiBodyGraph::MultiBodyGraph ( const std::string  rootName = "Root")

◆ MultiBodyGraph() [2/2]

rbd::MultiBodyGraph::MultiBodyGraph ( const MultiBodyGraph mbg)

◆ ~MultiBodyGraph()

rbd::MultiBodyGraph::~MultiBodyGraph ( )

Member Function Documentation

◆ addBody()

void rbd::MultiBodyGraph::addBody ( const Body B)

Add a node to the graph.

Parameters
BBody to add, his body name must be unique.
Exceptions
std::domain_errorif the body name already exists

◆ addJoint()

void rbd::MultiBodyGraph::addJoint ( const Joint J)

Add a joint.

Parameters
JJoint to add, his joint name must be unique.
Exceptions
std::domain_errorif the joint name already exists

◆ bodiesBaseTransform()

std::map<std::string, sva::PTransformd> rbd::MultiBodyGraph::bodiesBaseTransform ( const std::string &  rootBodyName,
const sva::PTransformd &  X_b0_j0 = sva::PTransformd::Identity() 
)

Compute the transformation to apply on each bodies to find their original base.

Parameters
rootBodyNameName of graph root.
X_b0_j0Transformation from the root body to the root joint.
Returns
Computed transformations by body name.
Exceptions
std::out_of_range.

◆ clear()

void rbd::MultiBodyGraph::clear ( )

◆ fixJoints()

static MultiBodyGraph rbd::MultiBodyGraph::fixJoints ( const MultiBodyGraph other,
const std::vector< std::string > &  jointsToFix,
bool  fixAllJoints = false 
)
static

Return a copy of a graph with the specified joints fixed.

Parameters
otherGraph to be copied.
jointsToFixNames of the joints to be fixed.
fixAllJointsIf true, all joints are fixed. The value of jointsToFix is disregarded.
Returns
a copy of other with some joints fixed according to parameters.

◆ jointByName()

const std::shared_ptr<Joint> rbd::MultiBodyGraph::jointByName ( const std::string &  name) const
Parameters
nameName of the joint.
Returns
Joint with the Name name.
Exceptions
std::out_of_rangeIf name don't exist.

◆ linkBodies()

void rbd::MultiBodyGraph::linkBodies ( const std::string &  b1Name,
const sva::PTransformd &  tB1,
const std::string &  b2Name,
const sva::PTransformd &  tB2,
const std::string &  jointName,
bool  isB1toB2 = true 
)

Create an arc to the graph.

Parameters
b1NameBody 1 name.
tB1Transformation from body 1 to joint in body 1 coordinate.
b2NameBody 2 name.
tB2Transformation from body 2 to joint in body 2 coordinate.
jointNameJoint between the two body name.
isB1toB2If true use the joint forward value as body 1 to body 2 forward value of the joint and the inverse value for body 2 to body 1 joint. If false the behavior is inversed.
Exceptions
std::out_of_rangeIf b1Name or b2Name or jointName don't exist.

◆ makeMultiBody() [1/3]

MultiBody rbd::MultiBodyGraph::makeMultiBody ( const std::string &  rootBodyName,
bool  isFixed,
const sva::PTransformd &  X_0_j0 = sva::PTransformd::Identity(),
const sva::PTransformd &  X_b0_j0 = sva::PTransformd::Identity() 
) const

Create a MultiBody from the graph.

Parameters
rootBodyNameName of the root body.
isFixedTrue if the root is fixed, false if the root is free.
X_0_j0Transformation to the root joint.
X_b0_j0Transformation from the root body to the root joint.
Exceptions
std::out_of_rangeIf rootBodyId don't exist.

◆ makeMultiBody() [2/3]

MultiBody rbd::MultiBodyGraph::makeMultiBody ( const std::string &  rootBodyName,
Joint::Type  rootJointType,
const Eigen::Vector3d &  axis,
const sva::PTransformd &  X_0_j0 = sva::PTransformd::Identity(),
const sva::PTransformd &  X_b0_j0 = sva::PTransformd::Identity() 
) const

Create a MultiBody from the graph.

Parameters
rootBodyNameName of the root body.
rootJointTypeMultiBody root joint type.
axisMultiBody root joint axis.
X_0_j0Transformation to the root joint.
X_b0_j0Transformation from the root body to the root joint.
Exceptions
std::out_of_rangeIf rootBodyId don't exist.

◆ makeMultiBody() [3/3]

MultiBody rbd::MultiBodyGraph::makeMultiBody ( const std::string &  rootBodyName,
Joint::Type  rootJointType,
const sva::PTransformd &  X_0_j0 = sva::PTransformd::Identity(),
const sva::PTransformd &  X_b0_j0 = sva::PTransformd::Identity() 
) const

Create a MultiBody from the graph.

Parameters
rootBodyNameName of the root body.
rootJointTypeMultiBody root joint type.
X_0_j0Transformation to the root joint.
X_b0_j0Transformation from the root body to the root joint.
Exceptions
std::out_of_rangeIf rootBodyId don't exist.

◆ mergeSubBodies()

void rbd::MultiBodyGraph::mergeSubBodies ( const std::string &  rootBodyName,
const std::string &  jointName,
const std::map< std::string, std::vector< double >> &  jointPosByName 
)

Merge jointName child bodies in jointName parent body (merge inertia matrix)

Parameters
rootBodyNameName of graph root.
jointNameMerge all node after jointName in jointName parent node.
jointPosByNameJoint configuration by joint name.
Exceptions
std::out_of_range,std::domain_error.

◆ nodeByName()

const std::shared_ptr<Node> rbd::MultiBodyGraph::nodeByName ( const std::string &  name) const
Parameters
nameName of the node.
Returns
Node with the Name name.
Exceptions
std::out_of_rangeif id don't exist.

◆ nrJoints()

std::size_t rbd::MultiBodyGraph::nrJoints ( ) const
Returns
Numbers of joints.

◆ nrNodes()

std::size_t rbd::MultiBodyGraph::nrNodes ( ) const
Returns
Numbers of nodes.

◆ operator=()

MultiBodyGraph& rbd::MultiBodyGraph::operator= ( const MultiBodyGraph mbg)

◆ predecessorJoint()

std::map<std::string, std::string> rbd::MultiBodyGraph::predecessorJoint ( const std::string &  rootBodyName)

Return the dictionary of predecessor joint name by body name.

Parameters
rootBodyNameName of graph root.
Returns
dictionary of predecessor joint name by body name.
Exceptions
std::out_of_range.

◆ removeJoint()

void rbd::MultiBodyGraph::removeJoint ( const std::string &  rootBodyName,
const std::string &  jointName 
)

Remove a joint (and successor joints and bodies) from the graph.

Parameters
rootBodyNameName of graph root.
jointNameName of joint to remove.
Exceptions
std::out_of_rangeIf rootBodyName doesn't exist.

◆ removeJoints()

void rbd::MultiBodyGraph::removeJoints ( const std::string &  rootBodyName,
const std::vector< std::string > &  joints 
)

Remove joints (and successor joints and bodies) from the graph. Do nothing for each joint name that doesn't exist.

Parameters
rootBodyNameName of the graph root.
jointsList of joints names to remove.
Exceptions
std::out_of_rangeIf rootBodyName doesn't exist.

◆ successorJoints()

std::map<std::string, std::vector<std::string> > rbd::MultiBodyGraph::successorJoints ( const std::string &  rootBodyName)

Return the dictionary of successor joints name by body name.

Parameters
rootBodyNameName of graph root.
Returns
dictionary of successor joints id by body id.
Exceptions
std::out_of_range.

Member Data Documentation

◆ bodyNameToNode_

std::map<std::string, std::shared_ptr<Node> > rbd::MultiBodyGraph::bodyNameToNode_
protected

◆ jointNameToJoint_

std::map<std::string, std::shared_ptr<Joint> > rbd::MultiBodyGraph::jointNameToJoint_
protected

◆ joints_

std::vector<std::shared_ptr<Joint> > rbd::MultiBodyGraph::joints_
protected

◆ nodes_

std::vector<std::shared_ptr<Node> > rbd::MultiBodyGraph::nodes_
protected

◆ rootJointName_

std::string rbd::MultiBodyGraph::rootJointName_
protected

The documentation for this class was generated from the following file: