5 #ifndef __pinocchio_energy_hpp__ 6 #define __pinocchio_energy_hpp__ 8 #include "pinocchio/multibody/model.hpp" 9 #include "pinocchio/multibody/data.hpp" 10 #include "pinocchio/algorithm/kinematics.hpp" 11 #include "pinocchio/algorithm/check.hpp" 30 template<
typename Scalar,
int Options,
template<
typename,
int>
class JointCollectionTpl,
typename ConfigVectorType,
typename TangentVectorType>
32 kineticEnergy(
const ModelTpl<Scalar,Options,JointCollectionTpl> & model,
33 DataTpl<Scalar,Options,JointCollectionTpl> & data,
34 const Eigen::MatrixBase<ConfigVectorType> & q,
35 const Eigen::MatrixBase<TangentVectorType> & v,
36 const bool update_kinematics =
true);
51 template<
typename Scalar,
int Options,
template<
typename,
int>
class JointCollectionTpl,
typename ConfigVectorType>
53 potentialEnergy(
const ModelTpl<Scalar,Options,JointCollectionTpl> & model,
54 DataTpl<Scalar,Options,JointCollectionTpl> & data,
55 const Eigen::MatrixBase<ConfigVectorType> & q,
56 const bool update_kinematics =
true);
65 template<
typename Scalar,
int Options,
template<
typename,
int>
class JointCollectionTpl,
typename ConfigVectorType,
typename TangentVectorType>
69 const Eigen::MatrixBase<ConfigVectorType> & q,
70 const Eigen::MatrixBase<TangentVectorType> & v,
71 const bool update_kinematics)
73 assert(model.
check(data) &&
"data is not consistent with model.");
74 assert(q.size() == model.
nq &&
"The configuration vector is not of right size");
75 assert(v.size() == model.
nv &&
"The velocity vector is not of right size");
78 typedef typename Model::JointIndex JointIndex;
82 if (update_kinematics)
85 for(JointIndex i=1; i<(JointIndex)(model.
njoints); ++i)
93 template<
typename Scalar,
int Options,
template<
typename,
int>
class JointCollectionTpl,
typename ConfigVectorType>
97 const Eigen::MatrixBase<ConfigVectorType> & q,
98 const bool update_kinematics)
100 assert(model.
check(data) &&
"data is not consistent with model.");
101 assert(q.size() == model.
nq &&
"The configuration vector is not of right size");
104 typedef typename Model::JointIndex JointIndex;
108 const typename Motion::ConstLinearType & g = model.
gravity.linear();
110 if (update_kinematics)
113 typename Data::Vector3 com_global;
114 for(JointIndex i=1; i<(JointIndex)(model.
njoints); ++i)
116 com_global.noalias() = data.
oMi[i].translation() + data.
oMi[i].rotation() * model.
inertias[i].lever();
123 #endif // __pinocchio_energy_hpp__ Scalar kineticEnergy(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data, const Eigen::MatrixBase< ConfigVectorType > &q, const Eigen::MatrixBase< TangentVectorType > &v, const bool update_kinematics=true)
Computes the kinetic energy of the system. The result is accessible through data.kinetic_energy.
int njoints
Number of joints.
int nv
Dimension of the velocity vector space.
container::aligned_vector< SE3 > oMi
Vector of absolute joint placements (wrt the world).
Motion gravity
Spatial gravity of the model.
void forwardKinematics(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data, const Eigen::MatrixBase< ConfigVectorType > &q)
Update the joint placements according to the current joint configuration.
bool check(const AlgorithmCheckerBase< D > &checker=AlgorithmCheckerBase< D >()) const
container::aligned_vector< Motion > v
Vector of joint velocities expressed at the centers of the joints.
Main pinocchio namespace.
container::aligned_vector< Inertia > inertias
Spatial inertias of the body i expressed in the supporting joint frame i.
Scalar kinetic_energy
Kinetic energy of the model.
int nq
Dimension of the configuration vector representation.
Scalar potentialEnergy(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data, const Eigen::MatrixBase< ConfigVectorType > &q, const bool update_kinematics=true)
Computes the potential energy of the system, i.e. the potential energy linked to the gravity field...
Scalar potential_energy
Potential energy of the model.