Robot Dynamics Library
rdl_utils.hpp
Go to the documentation of this file.
1 // Copyright (c) 2017 Jordan Lack <jlack1987@gmail.com>
2 // Copyright (c) 2011-2016 Martin Felis <martin.felis@iwr.uni-heidelberg.de>
3 // RDL - Robot Dynamics Library
4 // Licensed under the zlib license. See LICENSE for more details.
5 
6 #ifndef __RDL_UTILS_H__
7 #define __RDL_UTILS_H__
8 
13 #include <string>
14 
16 #include "rdl_dynamics/Model.hpp"
18 
19 namespace RobotDynamics
20 {
34 struct Model;
35 
37 namespace Utils
38 {
40 std::string getDofName(const Math::SpatialVector& joint_dof);
41 
43 std::string getBodyName(const RobotDynamics::Model& model, unsigned int body_id);
44 
46 std::string getModelHierarchy(const Model& model);
47 
49 std::string getModelDOFOverview(const Model& model);
50 
52 std::string getNamedBodyOriginsOverview(Model& model);
53 
63 void calcCenterOfMass(Model& model, const Math::VectorNd& q, Math::Vector3d& com, bool update_kinematics = true);
64 
73 void calcCenterOfMass(Model& model, const Math::VectorNd& q, Math::FramePoint& com, bool update_kinematics = true);
74 
89 void calcCenterOfMass(Model& model, const Math::VectorNd& q, const Math::VectorNd& qdot, Math::Vector3d& com, Math::Vector3d* com_velocity = NULL,
90  Math::Vector3d* angular_momentum = NULL, bool update_kinematics = true);
91 
108 void calcCenterOfMass(Model& model, const Math::VectorNd& q, const Math::VectorNd& qdot, Math::FramePoint& com, Math::FrameVector& com_velocity,
109  Math::FrameVector* angular_momentum = nullptr, bool update_kinematics = true);
110 
125 void calcCenterOfMass(Model& model, const Math::VectorNd& q, const Math::VectorNd& qdot, Math::FramePoint& com, Math::FrameVector* com_velocity = nullptr,
126  bool update_kinematics = true);
127 
137 void calcCenterOfMass(Model& model, const Math::VectorNd& q, const Math::VectorNd& qdot, Math::Vector3d& com, Math::Vector3d& com_velocity,
138  bool update_kinematics = true);
139 
150 RobotDynamics::Math::FramePoint updateCenterOfMassFrame(Model& model, const Math::VectorNd& q, bool update_kinematics = true);
151 
163 RobotDynamics::Math::FramePoint updateCenterOfMassFrame(Model& model, const Math::VectorNd& q, const Math::Vector3d& euler_ypr, bool update_kinematics = true);
164 
176 RobotDynamics::Math::FramePoint updateCenterOfMassFrame(Model& model, const Math::VectorNd& q, const Math::Quaternion& orientation, bool update_kinematics = true);
177 
185 void updateCenterOfMassFrame(Model& model, const Math::Vector3d& p_com);
186 
196 void updateCenterOfMassFrame(Model& model, const Math::Vector3d& p_com, const Math::Vector3d& euler_ypr);
197 
207 void updateCenterOfMassFrame(Model& model, const Math::Vector3d& p_com, const Math::Quaternion& orientation);
208 
217 void calcCenterOfMassVelocity(Model& model, const Math::VectorNd& q, const Math::VectorNd& qdot, Math::Vector3d& com_vel, bool update_kinematics = true);
218 
227 void calcCenterOfMassVelocity(Model& model, const Math::VectorNd& q, const Math::VectorNd& qdot, Math::FrameVector& com_vel, bool update_kinematics = true);
228 
234 void calcCenterOfMassVelocity(Model& model, Math::Vector3d& com_vel);
235 
241 void calcCenterOfMassVelocity(Model& model, Math::FrameVector& com_vel);
242 
251 double calcPotentialEnergy(Model& model, const Math::VectorNd& q, bool update_kinematics = true);
252 
262 double calcKineticEnergy(Model& model, const Math::VectorNd& q, const Math::VectorNd& qdot, bool update_kinematics = true);
263 
274 Math::SpatialForce calcGravityWrenchOnCenterOfMass(Model& model, const Math::VectorNd& q, bool update_kinematics = true);
275 
284 void calcCenterOfMassJacobian(Model& model, const Math::VectorNd& q, Math::MatrixNd& jCom, bool update_kinematics = true);
285 
295 Math::Vector3d calcSubtreeCenterOfMassScaledByMass(Model& model, const unsigned int bodyId, const Math::VectorNd& q, bool updateKinematics = true);
296 
305 double calcSubtreeMass(Model& model, const unsigned int bodyId);
306 
325 void calcCentroidalMomentumMatrix(Model& model, const Math::VectorNd& q, Math::MatrixNd& A, bool update_kinematics = true);
326 
343 void calcCentroidalMomentumMatrix(Model& model, const Math::VectorNd& q, Math::MatrixNd& A, Math::Vector3d com, bool update_kinematics = true);
344 
357 void calcCentroidalMomentumMatrixDot(Model& model, const Math::VectorNd& q, const Math::VectorNd& qdot, Math::MatrixNd& Adot, Math::Vector3d com,
358  Math::Vector3d com_velocity, bool update_kinematics = true);
359 
373 void calcCentroidalMomentumMatrixDot(Model& model, const Math::VectorNd& q, const Math::VectorNd& qdot, Math::MatrixNd& Adot, bool update_kinematics = true);
374 
390  Math::Vector3d com, Math::Vector3d com_velocity, bool update_kinematics = true);
391 
408  bool update_kinematics = true);
409 
410 } // namespace Utils
411 } // namespace RobotDynamics
412 
413 #endif // ifndef __RDL_UTILS_H__
File containing the FramePoint<T> object definition.
A FramePoint is a 3D point that is expressed in a ReferenceFrame. To change the ReferenceFrame a Fram...
Definition: FramePoint.hpp:38
void updateKinematics(Model &model, const VectorNd &Q, const VectorNd &QDot, const VectorNd &QDDot)
Updates and computes velocities and accelerations of the bodies.
Definition: Kinematics.cpp:19
RobotDynamics::Math::FramePoint updateCenterOfMassFrame(Model &model, const Math::VectorNd &q, bool update_kinematics)
Computes the center of mass and updates the center of mass reference frame of the model.
Definition: rdl_utils.cpp:377
double calcSubtreeMass(Model &model, const unsigned int bodyId)
Calculates the total mass of the subtree beginning with body bodyId and traversing outwards from ther...
Definition: rdl_utils.cpp:548
void calcCenterOfMass(Model &model, const Math::VectorNd &q, Math::Vector3d &com, bool update_kinematics)
Computes the Center of Mass (COM) position.
Definition: rdl_utils.cpp:197
double calcKineticEnergy(Model &model, const Math::VectorNd &q, const Math::VectorNd &qdot, bool update_kinematics)
Computes the kinetic energy of the full model.
Definition: rdl_utils.cpp:572
void calcCenterOfMassJacobian(Model &model, const Math::VectorNd &q, Math::MatrixNd &jCom, bool update_kinematics)
Computes the matrix such that .
Definition: rdl_utils.cpp:493
Math::SpatialForce calcGravityWrenchOnCenterOfMass(Model &model, const Math::VectorNd &q, bool update_kinematics)
Computes the gravitational wrench experienced on the robots center of mass.
Definition: rdl_utils.cpp:469
void calcCenterOfMassVelocity(Model &model, Math::Vector3d &com_vel)
Computes the Center of Mass (COM) velocity in world frame.
Definition: rdl_utils.cpp:416
std::string getModelDOFOverview(const Model &model)
Creates a human readable overview of the Degrees of Freedom.
Definition: rdl_utils.cpp:70
Math::Vector3d calcSubtreeCenterOfMassScaledByMass(Model &model, const unsigned int bodyId, const VectorNd &q, bool updateKinematics)
Calculates the center of mass of a subtree starting with the body with ID bodyId and scales it by the...
Definition: rdl_utils.cpp:529
std::string getNamedBodyOriginsOverview(Model &model)
Creates a human readable overview of the locations of all bodies that have names.
Definition: rdl_utils.cpp:173
string getBodyName(const RobotDynamics::Model &model, unsigned int body_id)
get body name, returns empty string if bodyid is virtual and has multiple child bodies
Definition: rdl_utils.cpp:54
string getDofName(const SpatialVector &joint_dof)
get string abbreviation for dof name from spatial vector.
Definition: rdl_utils.cpp:22
double calcPotentialEnergy(Model &model, const Math::VectorNd &q, bool update_kinematics)
Computes the potential energy of the full model.
Definition: rdl_utils.cpp:562
void calcCentroidalMomentumMatrixDot(Model &model, const Math::VectorNd &q, const Math::VectorNd &qdot, Math::MatrixNd &Adot, Math::Vector3d com, Math::Vector3d com_velocity, bool update_kinematics)
Calculates the time derivative of the centroidal momentum matrix, i.e. the matrix computed by RobotDy...
Definition: rdl_utils.cpp:646
void calcCentroidalMomentumMatrix(Model &model, const Math::VectorNd &q, Math::MatrixNd &A, Math::Vector3d com, bool update_kinematics)
Calculates the centroidal momentum matrix, for a model. The centroidal momentum matrix is a matrix ...
Definition: rdl_utils.cpp:588
std::string getModelHierarchy(const Model &model)
Creates a human readable overview of the model.
Definition: rdl_utils.cpp:164
void calcCentroidalMomentumMatrixAndMatrixDot(Model &model, const Math::VectorNd &q, const Math::VectorNd &qdot, Math::MatrixNd &A, Math::MatrixNd &Adot, bool update_kinematics)
Calculates the centroidal momentum matrix and its time derivative, but in a more efficient way than c...
Definition: rdl_utils.cpp:714
Eigen::VectorXd VectorNd
Definition: rdl_eigenmath.hpp:20
Eigen::MatrixXd MatrixNd
Definition: rdl_eigenmath.hpp:21
Namespace for all structures of the RobotDynamics library.
Definition: examples.hpp:19
Contains all information about the rigid body model.
Definition: Model.hpp:112