33 #ifndef DART_DYNAMICS_REFERENTIALSKELETON_HPP_
34 #define DART_DYNAMICS_REFERENTIALSKELETON_HPP_
36 #include <unordered_map>
37 #include <unordered_set>
66 const std::string&
setName(
const std::string& _name)
override;
69 const std::string&
getName()
const override;
113 const std::vector<const BodyNode*>&
getBodyNodes()
const override;
126 const std::string&
name)
const override;
160 std::vector<Joint*>
getJoints()
override;
163 std::vector<const Joint*>
getJoints()
const override;
169 std::vector<Joint*>
getJoints(
const std::string&
name)
override;
175 std::vector<const Joint*>
getJoints(
const std::string&
name)
const override;
181 std::size_t
getIndexOf(
const Joint* _joint,
bool _warning=
true)
const override;
193 const std::vector<DegreeOfFreedom*>&
getDofs()
override;
196 std::vector<const DegreeOfFreedom*>
getDofs()
const override;
200 bool _warning=
true)
const override;
214 const Frame* _inCoordinatesOf)
const override;
219 const Eigen::Vector3d& _localOffset)
const override;
224 const Eigen::Vector3d& _localOffset,
225 const Frame* _inCoordinatesOf)
const override;
232 const Eigen::Vector3d& _localOffset)
const override;
242 const Eigen::Vector3d& _localOffset,
257 const Frame* _inCoordinatesOf)
const override;
262 const Eigen::Vector3d& _localOffset)
const override;
267 const Eigen::Vector3d& _localOffset,
268 const Frame* _inCoordinatesOf)
const override;
277 const Frame* _inCoordinatesOf)
const override;
282 const Eigen::Vector3d& _localOffset,
293 const Eigen::Vector3d& _localOffset,
311 double getMass()
const override;
364 const
Frame* _withRespectTo =
Frame::World()) const override;
369 const
Frame* _inCoordinatesOf =
Frame::World()) const override;
374 const
Frame* _inCoordinatesOf =
Frame::World()) const override;
379 const
Frame* _inCoordinatesOf =
Frame::World()) const override;
384 const
Frame* _inCoordinatesOf =
Frame::World()) const override;
388 const
Frame* _inCoordinatesOf =
Frame::World()) const override;
392 const
Frame* _inCoordinatesOf =
Frame::World()) const override;
396 const
Frame* _inCoordinatesOf =
Frame::World()) const override;
400 const
Frame* _inCoordinatesOf =
Frame::World()) const override;
468 bool isExpired()
const;
496 std::vector<DegreeOfFreedomPtr>
mDofs;
509 std::unordered_map<const BodyNode*, IndexMap>
mIndexMap;
512 mutable Eigen::MatrixXd
mM;
527 mutable Eigen::VectorXd
mG;
530 mutable Eigen::VectorXd
mCg;
536 mutable Eigen::VectorXd
mFc;
#define DART_DEPRECATED(version)
Definition: Deprecated.hpp:51
std::string * name
Definition: SkelParser.cpp:1642
BodyNode class represents a single node of the skeleton.
Definition: BodyNode.hpp:78
DegreeOfFreedom class is a proxy class for accessing single degrees of freedom (aka generalized coord...
Definition: DegreeOfFreedom.hpp:53
The Frame class serves as the backbone of DART's kinematic tree structure.
Definition: Frame.hpp:57
static Frame * World()
Definition: Frame.cpp:72
The JacobianNode class serves as a common interface for BodyNodes and EndEffectors to both be used as...
Definition: JacobianNode.hpp:54
class Joint
Definition: Joint.hpp:59
ReferentialSkeleton is a base class used to implement Linkage, Group, and other classes that are used...
Definition: ReferentialSkeleton.hpp:48
const std::string & setName(const std::string &_name) override
Set the name of this MetaSkeleton.
Definition: ReferentialSkeleton.cpp:54
math::LinearJacobian getCOMLinearJacobian(const Frame *_inCoordinatesOf=Frame::World()) const override
Get the MetaSkeleton's COM Linear Jacobian in terms of any Frame (default is World Frame)
Definition: ReferentialSkeleton.cpp:1111
std::size_t getNumSkeletons() const
Returns number of skeletons associated with this ReferentialSkeleton.
Definition: ReferentialSkeleton.cpp:72
const Eigen::VectorXd & getConstraintForces() const override
Get constraint force vector.
Definition: ReferentialSkeleton.cpp:922
math::AngularJacobian getAngularJacobianDeriv(const JacobianNode *_node, const Frame *_inCoordinatesOf=Frame::World()) const override
Get the angular Jacobian time derivative of a BodyNode.
Definition: ReferentialSkeleton.cpp:784
Eigen::MatrixXd mAugM
Cache for Augmented Mass Matrix.
Definition: ReferentialSkeleton.hpp:515
std::vector< Joint * > getJoints() override
Returns all the joints that are held by this MetaSkeleton.
Definition: ReferentialSkeleton.cpp:282
void clearExternalForces() override
Clear the external forces of the BodyNodes in this MetaSkeleton.
Definition: ReferentialSkeleton.cpp:929
void updateCaches()
Update the caches to match any changes to the structure of this ReferentialSkeleton.
Definition: ReferentialSkeleton.cpp:1423
bool hasBodyNode(const BodyNode *bodyNode) const override
Returns whether this Skeleton contains bodyNode.
Definition: ReferentialSkeleton.cpp:192
Eigen::VectorXd mCg
Cache for combined Coriolis and gravity vector.
Definition: ReferentialSkeleton.hpp:530
std::string mName
Name of this ReferentialSkeleton.
Definition: ReferentialSkeleton.hpp:472
Eigen::Vector6d getCOMSpatialAcceleration(const Frame *_relativeTo=Frame::World(), const Frame *_inCoordinatesOf=Frame::World()) const override
Get the Skeleton's COM spatial acceleration in terms of any Frame (default is World Frame)
Definition: ReferentialSkeleton.cpp:1046
bool hasSkeleton(const Skeleton *skel) const
Returns whether this ReferentialSkeleton contains any BodyNode or Joint from skel.
Definition: ReferentialSkeleton.cpp:78
Joint * getJoint(std::size_t _idx) override
Get Joint whose index is _idx.
Definition: ReferentialSkeleton.cpp:237
const std::vector< DegreeOfFreedom * > & getDofs() override
Get the vector of DegreesOfFreedom for this MetaSkeleton.
Definition: ReferentialSkeleton.cpp:388
std::set< std::mutex * > mSkeletonMutexes
Mutexes of the skeletons.
Definition: ReferentialSkeleton.hpp:480
const Eigen::VectorXd & getExternalForces() const override
Get external force vector of the MetaSkeleton.
Definition: ReferentialSkeleton.cpp:915
math::Jacobian getWorldJacobian(const JacobianNode *_node) const override
Get the spatial Jacobian targeting the origin of a BodyNode.
Definition: ReferentialSkeleton.cpp:563
std::vector< const BodyNode * > mRawConstBodyNodes
Raw const BodyNode pointers. This vector is used for the MetaSkeleton API.
Definition: ReferentialSkeleton.hpp:490
void registerDegreeOfFreedom(DegreeOfFreedom *_dof)
Add a DegreeOfFreedom to this ReferentialSkeleton.
Definition: ReferentialSkeleton.cpp:1221
virtual ~ReferentialSkeleton()=default
Default destructor.
const std::string & getName() const override
Get the name of this MetaSkeleton.
Definition: ReferentialSkeleton.cpp:66
Eigen::VectorXd mCvec
Cache for Coriolis vector.
Definition: ReferentialSkeleton.hpp:524
double getMass() const override
Get the total mass of all BodyNodes in this ReferentialSkeleton.
Definition: ReferentialSkeleton.cpp:791
math::Jacobian getCOMJacobian(const Frame *_inCoordinatesOf=Frame::World()) const override
Get the MetaSkeleton's COM Jacobian in terms of any Frame (default is World Frame)
Definition: ReferentialSkeleton.cpp:1102
std::vector< DegreeOfFreedomPtr > mDofs
DegreesOfFreedom that this ReferentialSkeleton references.
Definition: ReferentialSkeleton.hpp:496
void unregisterBodyNode(BodyNode *_bn, bool _unregisterDofs)
Remove a BodyNode from this ReferentialSkeleton, ignoring its parent DegreesOfFreedom.
Definition: ReferentialSkeleton.cpp:1267
std::vector< BodyNodePtr > mBodyNodes
BodyNodes that this ReferentialSkeleton references.
Definition: ReferentialSkeleton.hpp:484
const Eigen::MatrixXd & getInvMassMatrix() const override
Get inverse of Mass Matrix of the MetaSkeleton.
Definition: ReferentialSkeleton.cpp:856
Eigen::VectorXd mFext
Cache for external force vector.
Definition: ReferentialSkeleton.hpp:533
std::size_t getNumJoints() const override
Get number of Joints.
Definition: ReferentialSkeleton.cpp:231
const Eigen::MatrixXd & getAugMassMatrix() const override
Get augmented mass matrix of the skeleton.
Definition: ReferentialSkeleton.cpp:849
const Eigen::VectorXd & getCoriolisForces() const override
Get Coriolis force vector of the MetaSkeleton's BodyNodes.
Definition: ReferentialSkeleton.cpp:894
std::size_t getNumBodyNodes() const override
Get number of body nodes.
Definition: ReferentialSkeleton.cpp:84
math::Jacobian getJacobian(const JacobianNode *_node) const override
Get the spatial Jacobian targeting the origin of a BodyNode.
Definition: ReferentialSkeleton.cpp:517
Eigen::Vector3d getCOMLinearVelocity(const Frame *_relativeTo=Frame::World(), const Frame *_inCoordinatesOf=Frame::World()) const override
Get the Skeleton's COM linear velocity in terms of any Frame (default is World Frame)
Definition: ReferentialSkeleton.cpp:1038
void unregisterSkeleton(const Skeleton *skel)
Removes a Skeleton from this ReferentialSkeleton.
Definition: ReferentialSkeleton.cpp:1479
void registerComponent(BodyNode *_bn)
Add a BodyNode, along with its parent Joint and parent DegreesOfFreedom to this ReferentialSkeleton.
Definition: ReferentialSkeleton.cpp:1140
double computeKineticEnergy() const override
Get the kinetic energy of this MetaSkeleton.
Definition: ReferentialSkeleton.cpp:943
Eigen::MatrixXd mM
Cache for Mass Matrix.
Definition: ReferentialSkeleton.hpp:512
std::unordered_set< const Skeleton * > mSkeletons
Skeletons that this ReferentialSkeleton contains any BodyNode or Joint from the Skeletons.
Definition: ReferentialSkeleton.hpp:476
Eigen::MatrixXd mInvAugM
Cache for inverse Augmented Mass Matrix.
Definition: ReferentialSkeleton.hpp:521
void unregisterDegreeOfFreedom(BodyNode *_bn, std::size_t _localIndex)
Remove a DegreeOfFreedom from this ReferentialSkeleton.
Definition: ReferentialSkeleton.cpp:1375
math::AngularJacobian getAngularJacobian(const JacobianNode *_node, const Frame *_inCoordinatesOf=Frame::World()) const override
Get the angular Jacobian of a BodyNode.
Definition: ReferentialSkeleton.cpp:632
math::Jacobian getJacobianSpatialDeriv(const JacobianNode *_node) const override
Get the spatial Jacobian time derivative targeting the origin of a BodyNode.
Definition: ReferentialSkeleton.cpp:657
std::vector< DegreeOfFreedom * > mRawDofs
Raw DegreeOfFreedom vector. This vector is used for the MetaSkeleton API.
Definition: ReferentialSkeleton.hpp:499
void clearInternalForces() override
Clear the internal forces of the BodyNodes in this MetaSkeleton.
Definition: ReferentialSkeleton.cpp:936
Eigen::VectorXd mFc
Cache for constraint force vector.
Definition: ReferentialSkeleton.hpp:536
ReferentialSkeleton & operator=(const ReferentialSkeleton &_other)=delete
Remove copy operator TODO(MXG): Consider allowing this.
BodyNode * getBodyNode(std::size_t _idx) override
Get BodyNode whose index is _idx.
Definition: ReferentialSkeleton.cpp:90
const Eigen::MatrixXd & getMassMatrix() const override
Get the Mass Matrix of the MetaSkeleton.
Definition: ReferentialSkeleton.cpp:843
double computePotentialEnergy() const override
Get the potential energy of this MetaSkeleton.
Definition: ReferentialSkeleton.cpp:955
void clearCollidingBodies() override
Clear collision flags of the BodyNodes in this MetaSkeleton.
Definition: ReferentialSkeleton.cpp:969
std::vector< const DegreeOfFreedom * > mRawConstDofs
Raw const DegreeOfFreedom vector.
Definition: ReferentialSkeleton.hpp:503
std::weak_ptr< MetaSkeleton > mPtr
Weak pointer to this Skeleton.
Definition: ReferentialSkeleton.hpp:447
void unregisterComponent(BodyNode *_bn)
Completely remove a BodyNode and its parent DegreesOfFreedom from this ReferentialSkeleton.
Definition: ReferentialSkeleton.cpp:1259
std::vector< BodyNode * > mRawBodyNodes
Raw BodyNode pointers. This vector is used for the MetaSkeleton API.
Definition: ReferentialSkeleton.hpp:487
std::size_t getNumDofs() const override
Return the number of degrees of freedom in this skeleton.
Definition: ReferentialSkeleton.cpp:370
void unregisterJoint(BodyNode *_child)
Remove a Joint from this ReferentialSkeleton.
Definition: ReferentialSkeleton.cpp:1322
bool hasJoint(const Joint *joint) const override
Returns whether this Skeleton contains join.
Definition: ReferentialSkeleton.cpp:333
Eigen::MatrixXd mInvM
Cache for inverse Mass Matrix.
Definition: ReferentialSkeleton.hpp:518
std::unordered_map< const BodyNode *, IndexMap > mIndexMap
Raw const DegreeOfFreedom. This vector is used for the MetaSkeleton API.
Definition: ReferentialSkeleton.hpp:509
math::LinearJacobian getLinearJacobian(const JacobianNode *_node, const Frame *_inCoordinatesOf=Frame::World()) const override
Get the linear Jacobian targeting the origin of a BodyNode.
Definition: ReferentialSkeleton.cpp:596
DegreeOfFreedom * getDof(std::size_t _idx) override
Get degree of freedom (aka generalized coordinate) whose index is _idx.
Definition: ReferentialSkeleton.cpp:376
const std::vector< BodyNode * > & getBodyNodes() override
Get all the BodyNodes that are held by this MetaSkeleton.
Definition: ReferentialSkeleton.cpp:146
const Eigen::MatrixXd & getInvAugMassMatrix() const override
Get inverse of augmented Mass Matrix of the MetaSkeleton.
Definition: ReferentialSkeleton.cpp:863
const Eigen::VectorXd & getGravityForces() const override
Get gravity force vector of the MetaSkeleton.
Definition: ReferentialSkeleton.cpp:901
void registerBodyNode(BodyNode *_bn)
Add a BodyNode to this ReferentialSkeleton, ignoring its Joint and DegreesOfFreedom.
Definition: ReferentialSkeleton.cpp:1151
math::LinearJacobian getLinearJacobianDeriv(const JacobianNode *_node, const Frame *_inCoordinatesOf=Frame::World()) const override
of a BodyNode.
Definition: ReferentialSkeleton.cpp:748
const Eigen::VectorXd & getCoriolisAndGravityForces() const override
Get combined vector of Coriolis force and gravity force of the MetaSkeleton.
Definition: ReferentialSkeleton.cpp:908
Eigen::VectorXd mG
Cache for gravity vector.
Definition: ReferentialSkeleton.hpp:527
Eigen::Vector3d getCOMLinearAcceleration(const Frame *_relativeTo=Frame::World(), const Frame *_inCoordinatesOf=Frame::World()) const override
Get the MetaSkeleton's COM linear acceleration in terms of any Frame (default is World Frame)
Definition: ReferentialSkeleton.cpp:1055
void registerJoint(Joint *_joint)
Add a Joint to this Referential Skeleton, ignoring its DegreesOfFreedom.
Definition: ReferentialSkeleton.cpp:1183
std::vector< JointPtr > mJoints
Joints that this ReferentialSkeleton references.
Definition: ReferentialSkeleton.hpp:493
Eigen::Vector6d getCOMSpatialVelocity(const Frame *_relativeTo=Frame::World(), const Frame *_inCoordinatesOf=Frame::World()) const override
Get the Skeleton's COM spatial velocity in terms of any Frame (default is World Frame)
Definition: ReferentialSkeleton.cpp:1030
math::Jacobian getCOMJacobianSpatialDeriv(const Frame *_inCoordinatesOf=Frame::World()) const override
Get the Skeleton's COM Jacobian spatial time derivative in terms of any Frame (default is World Frame...
Definition: ReferentialSkeleton.cpp:1120
math::LinearJacobian getCOMLinearJacobianDeriv(const Frame *_inCoordinatesOf=Frame::World()) const override
Get the Skeleton's COM Linear Jacobian time derivative in terms of any Frame (default is World Frame)...
Definition: ReferentialSkeleton.cpp:1130
Eigen::Vector3d getCOM(const Frame *_withRespectTo=Frame::World()) const override
Get the MetaSkeleton's COM with respect to any Frame (default is World Frame)
Definition: ReferentialSkeleton.cpp:990
void registerSkeleton(const Skeleton *skel)
Add a Skeleton to this ReferentialSkeleton, ignoring its Joint and DegreesOfFreedom.
Definition: ReferentialSkeleton.cpp:1465
std::size_t getIndexOf(const BodyNode *_bn, bool _warning=true) const override
Get the index of a specific BodyNode within this ReferentialSkeleton.
Definition: ReferentialSkeleton.cpp:199
std::unique_ptr< common::LockableReference > getLockableReference() const override
Returns mutex.
Definition: ReferentialSkeleton.cpp:46
math::Jacobian getJacobianClassicDeriv(const JacobianNode *_node) const override
Get the spatial Jacobian (classical) time derivative targeting the origin of a BodyNode.
Definition: ReferentialSkeleton.cpp:705
class Skeleton
Definition: Skeleton.hpp:59
Definition: Random-impl.hpp:92
Matrix< double, 6, 1 > Vector6d
Definition: MathTypes.hpp:49
Eigen::Matrix< double, 6, Eigen::Dynamic > Jacobian
Definition: MathTypes.hpp:108
Eigen::Matrix< double, 3, Eigen::Dynamic > AngularJacobian
Definition: MathTypes.hpp:107
Eigen::Matrix< double, 3, Eigen::Dynamic > LinearJacobian
Definition: MathTypes.hpp:106
Definition: BulletCollisionDetector.cpp:63
Definition: SharedLibraryManager.hpp:43
A simple struct that contains the indexing of a BodyNode and its parent DegreesOfFreedom.
Definition: ReferentialSkeleton.hpp:452
std::size_t mBodyNodeIndex
Index of the BodyNode.
Definition: ReferentialSkeleton.hpp:454
std::size_t mJointIndex
Index of the parent Joint.
Definition: ReferentialSkeleton.hpp:457
std::vector< std::size_t > mDofIndices
Indices of the parent DegreesOfFreedom.
Definition: ReferentialSkeleton.hpp:460