pinocchio  2.7.0
A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives
energy.hpp
1 //
2 // Copyright (c) 2016-2020 CNRS INRIA
3 //
4 
5 #ifndef __pinocchio_algorithm_energy_hpp__
6 #define __pinocchio_algorithm_energy_hpp__
7 
8 #include "pinocchio/multibody/model.hpp"
9 #include "pinocchio/multibody/data.hpp"
10 #include "pinocchio/algorithm/kinematics.hpp"
11 #include "pinocchio/algorithm/check.hpp"
12 
13 namespace pinocchio {
14 
26  template<typename Scalar, int Options, template<typename,int> class JointCollectionTpl>
27  inline Scalar
28  computeKineticEnergy(const ModelTpl<Scalar,Options,JointCollectionTpl> & model,
29  DataTpl<Scalar,Options,JointCollectionTpl> & data);
30 
46  template<typename Scalar, int Options, template<typename,int> class JointCollectionTpl, typename ConfigVectorType, typename TangentVectorType>
47  inline Scalar
50  const Eigen::MatrixBase<ConfigVectorType> & q,
51  const Eigen::MatrixBase<TangentVectorType> & v)
52  {
53  forwardKinematics(model,data,q.derived(),v.derived());
54  return computeKineticEnergy(model,data);
55  }
56 
73  template<typename Scalar, int Options, template<typename,int> class JointCollectionTpl, typename ConfigVectorType, typename TangentVectorType>
74  PINOCCHIO_DEPRECATED
75  inline Scalar
78  const Eigen::MatrixBase<ConfigVectorType> & q,
79  const Eigen::MatrixBase<TangentVectorType> & v,
80  const bool update_kinematics)
81  {
82  if(update_kinematics)
83  return computeKineticEnergy(model,data,q.derived(),v.derived());
84  else
85  return computeKineticEnergy(model,data);
86  }
87 
106  template<typename Scalar, int Options, template<typename,int> class JointCollectionTpl>
107  inline Scalar
108  computePotentialEnergy(const ModelTpl<Scalar,Options,JointCollectionTpl> & model,
109  DataTpl<Scalar,Options,JointCollectionTpl> & data);
110 
129  template<typename Scalar, int Options, template<typename,int> class JointCollectionTpl, typename ConfigVectorType>
130  inline Scalar
133  const Eigen::MatrixBase<ConfigVectorType> & q)
134  {
135  forwardKinematics(model,data,q);
136  return computePotentialEnergy(model,data);
137  }
138 
153  template<typename Scalar, int Options, template<typename,int> class JointCollectionTpl, typename ConfigVectorType>
154  PINOCCHIO_DEPRECATED
155  inline Scalar
158  const Eigen::MatrixBase<ConfigVectorType> & q,
159  const bool update_kinematics)
160  {
161  if(update_kinematics)
162  return computePotentialEnergy(model,data,q);
163  else
164  return computePotentialEnergy(model,data);
165  }
166 }
167 
168 #include "pinocchio/algorithm/energy.hxx"
169 
170 #endif // __pinocchio_algorithm_energy_hpp__
pinocchio::computePotentialEnergy
Scalar computePotentialEnergy(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data)
Computes the potential energy of the system, i.e. the potential energy linked to the gravity field....
pinocchio::DataTpl
Definition: data.hpp:29
pinocchio::forwardKinematics
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.
pinocchio::kineticEnergy
PINOCCHIO_DEPRECATED 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)
Computes the kinetic energy of the system. The result is accessible through data.kinetic_energy.
Definition: energy.hpp:76
pinocchio::computeKineticEnergy
Scalar computeKineticEnergy(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data)
Computes the kinetic energy of the system. The result is accessible through data.kinetic_energy.
pinocchio::potentialEnergy
PINOCCHIO_DEPRECATED Scalar potentialEnergy(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data, const Eigen::MatrixBase< ConfigVectorType > &q, const bool update_kinematics)
Computes the potential energy of the system, i.e. the potential energy linked to the gravity field....
Definition: energy.hpp:156
pinocchio::ModelTpl< Scalar, Options, JointCollectionTpl >
pinocchio
Main pinocchio namespace.
Definition: treeview.dox:11