rdl_utils.h
Go to the documentation of this file.
1 /*
2  * Original Copyright (c) 2011-2016 Martin Felis <martin.felis@iwr.uni-heidelberg.de>
3  *
4  *
5  * RDL - Robot Dynamics Library
6  * Modifications Copyright (c) 2017 Jordan Lack <jlack1987@gmail.com>
7  *
8  * Licensed under the zlib license. See LICENSE for more details.
9  */
10 
11 #ifndef __RDL_UTILS_H__
12 #define __RDL_UTILS_H__
13 
18 #include <string>
19 
21 #include "rdl_dynamics/Model.h"
24 
25 namespace RobotDynamics
26 {
40 struct Model;
41 
43 namespace Utils
44 {
46 std::string getDofName(const Math::SpatialVector& joint_dof);
47 
49 std::string getBodyName(const RobotDynamics::Model& model, unsigned int body_id);
50 
52 std::string getModelHierarchy(const Model& model);
53 
55 std::string getModelDOFOverview(const Model& model);
56 
58 std::string getNamedBodyOriginsOverview(Model& model);
59 
69 void calcCenterOfMass(Model& model, const Math::VectorNd& q, Math::Vector3d& com, bool update_kinematics = true);
70 
79 void calcCenterOfMass(Model& model, const Math::VectorNd& q, Math::FramePoint& com, bool update_kinematics = true);
80 
96 void calcCenterOfMass(Model& model, const Math::VectorNd& q, const Math::VectorNd& qdot, double& mass, Math::Vector3d& com, Math::Vector3d* com_velocity = NULL,
97  Math::Vector3d* angular_momentum = NULL, bool update_kinematics = true);
98 
116 void calcCenterOfMass(Model& model, const Math::VectorNd& q, const Math::VectorNd& qdot, double& mass, Math::FramePoint& com, Math::FrameVector* com_velocity = nullptr,
117  Math::FrameVector* angular_momentum = nullptr, bool update_kinematics = true);
118 
133 void calcCenterOfMass(Model& model, const Math::VectorNd& q, const Math::VectorNd& qdot, Math::FramePoint& com, Math::FrameVector* com_velocity = nullptr,
134  bool update_kinematics = true);
135 
146 RobotDynamics::Math::FramePoint updateCenterOfMassFrame(Model& model, const Math::VectorNd& q, bool update_kinematics = true);
147 
159 RobotDynamics::Math::FramePoint updateCenterOfMassFrame(Model& model, const Math::VectorNd& q, const Math::Vector3d& euler_ypr, bool update_kinematics = true);
160 
172 RobotDynamics::Math::FramePoint updateCenterOfMassFrame(Model& model, const Math::VectorNd& q, const Math::Quaternion& orientation, bool update_kinematics = true);
173 
181 void updateCenterOfMassFrame(Model& model, const Math::Vector3d& p_com);
182 
192 void updateCenterOfMassFrame(Model& model, const Math::Vector3d& p_com, const Math::Vector3d& euler_ypr);
193 
203 void updateCenterOfMassFrame(Model& model, const Math::Vector3d& p_com, const Math::Quaternion& orientation);
204 
213 void calcCenterOfMassVelocity(Model& model, const Math::VectorNd& q, const Math::VectorNd& qdot, Math::Vector3d& com_vel, bool update_kinematics = true);
214 
223 void calcCenterOfMassVelocity(Model& model, const Math::VectorNd& q, const Math::VectorNd& qdot, Math::FrameVector& com_vel, bool update_kinematics = true);
224 
230 void calcCenterOfMassVelocity(Model& model, Math::Vector3d& com_vel);
231 
237 void calcCenterOfMassVelocity(Model& model, Math::FrameVector& com_vel);
238 
247 double calcPotentialEnergy(Model& model, const Math::VectorNd& q, bool update_kinematics = true);
248 
258 double calcKineticEnergy(Model& model, const Math::VectorNd& q, const Math::VectorNd& qdot, bool update_kinematics = true);
259 
270 Math::SpatialForce calcGravityWrenchOnCenterOfMass(Model& model, const Math::VectorNd& q, bool update_kinematics = true);
271 
280 void calcCenterOfMassJacobian(Model& model, const Math::VectorNd& q, Math::MatrixNd& jCom, bool update_kinematics = true);
281 
291 Math::Vector3d calcSubtreeCenterOfMassScaledByMass(Model& model, const unsigned int bodyId, const Math::VectorNd& q, bool updateKinematics = true);
292 
301 double calcSubtreeMass(Model& model, const unsigned int bodyId);
302 
318 void calcCentroidalMomentumMatrix(Model& model, const Math::VectorNd& q, Math::MatrixNd& A, bool update_kinematics = true);
319 
330 void calcCentroidalMomentumMatrixDot(Model& model, const Math::VectorNd& q, const Math::VectorNd& qdot, Math::MatrixNd& Adot, bool update_kinematics = true);
331 } // namespace Utils
332 } // namespace RobotDynamics
333 
338 #endif // ifndef __RDL_UTILS_H__
void calcCenterOfMassVelocity(Model &model, const Math::VectorNd &q, const Math::VectorNd &qdot, Math::Vector3d &com_vel, bool update_kinematics=true)
Computes the Center of Mass (COM) velocity in world frame.
Definition: rdl_utils.cc:420
void calcCenterOfMassJacobian(Model &model, const Math::VectorNd &q, Math::MatrixNd &jCom, bool update_kinematics=true)
Computes the matrix such that .
Definition: rdl_utils.cc:464
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:40
Math::Vector3d calcSubtreeCenterOfMassScaledByMass(Model &model, const unsigned int bodyId, const Math::VectorNd &q, bool updateKinematics=true)
Calculates the center of mass of a subtree starting with the body with ID bodyId and scales it by the...
Definition: rdl_utils.cc:500
std::string getNamedBodyOriginsOverview(Model &model)
Creates a human readable overview of the locations of all bodies that have names. ...
Definition: rdl_utils.cc:178
RobotDynamics::Math::FramePoint updateCenterOfMassFrame(Model &model, const Math::VectorNd &q, bool update_kinematics=true)
Computes the center of mass and updates the center of mass reference frame of the model...
Definition: rdl_utils.cc:348
std::string getModelHierarchy(const Model &model)
Creates a human readable overview of the model.
Definition: rdl_utils.cc:169
std::string getModelDOFOverview(const Model &model)
Creates a human readable overview of the Degrees of Freedom.
Definition: rdl_utils.cc:75
std::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.cc:59
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.cc:519
double calcPotentialEnergy(Model &model, const Math::VectorNd &q, bool update_kinematics=true)
Computes the potential energy of the full model.
Definition: rdl_utils.cc:533
Math::SpatialForce calcGravityWrenchOnCenterOfMass(Model &model, const Math::VectorNd &q, bool update_kinematics=true)
Computes the gravitational wrench experienced on the robots center of mass.
Definition: rdl_utils.cc:440
A FrameVector is a 3D vector with a ReferenceFrame, and all operations between FrameVectors and other...
Definition: FrameVector.hpp:33
void calcCentroidalMomentumMatrixDot(Model &model, const Math::VectorNd &q, const Math::VectorNd &qdot, Math::MatrixNd &Adot, bool update_kinematics=true)
Calculates the time derivative of the centroidal momentum matrix, i.e. the matrix computed by RobotDy...
Definition: rdl_utils.cc:613
Quaternion that are used for singularity free joints.
Definition: Quaternion.h:25
Eigen::VectorXd VectorNd
Definition: rdl_eigenmath.h:25
void updateKinematics(Model &model, const Math::VectorNd &Q, const Math::VectorNd &QDot, const Math::VectorNd &QDDot)
Updates and computes velocities and accelerations of the bodies.
Definition: Kinematics.cc:25
void calcCentroidalMomentumMatrix(Model &model, const Math::VectorNd &q, Math::MatrixNd &A, bool update_kinematics=true)
Calculates the centroidal momentum matrix, for a model. The centroidal momentum matrix is a matrix ...
Definition: rdl_utils.cc:560
std::string getDofName(const Math::SpatialVector &joint_dof)
get string abbreviation for dof name from spatial vector.
Definition: rdl_utils.cc:27
Contains all information about the rigid body model.
Definition: Model.h:121
void calcCenterOfMass(Model &model, const Math::VectorNd &q, Math::Vector3d &com, bool update_kinematics=true)
Computes the Center of Mass (COM) position.
Definition: rdl_utils.cc:202
Eigen::MatrixXd MatrixNd
Definition: rdl_eigenmath.h:26
A SpatialForce is a spatial vector with the angular part being three moments and the linear part bein...
double calcKineticEnergy(Model &model, const Math::VectorNd &q, const Math::VectorNd &qdot, bool update_kinematics=true)
Computes the kinetic energy of the full model.
Definition: rdl_utils.cc:544
Namespace for all structures of the RobotDynamics library.
Definition: Body.h:21


rdl_dynamics
Author(s):
autogenerated on Tue Apr 20 2021 02:25:27