Crocoddyl
multibody.hpp
1 // BSD 3-Clause License
3 //
4 // Copyright (C) 2019-2021, LAAS-CNRS, University of Edinburgh
5 // Copyright note valid unless otherwise stated in individual files.
6 // All rights reserved.
8 
9 #ifndef CROCODDYL_MULTIBODY_STATES_MULTIBODY_HPP_
10 #define CROCODDYL_MULTIBODY_STATES_MULTIBODY_HPP_
11 
12 #include <pinocchio/multibody/model.hpp>
13 
14 #include "crocoddyl/core/state-base.hpp"
15 #include "crocoddyl/multibody/fwd.hpp"
16 
17 namespace crocoddyl {
18 
34 template <typename _Scalar>
35 class StateMultibodyTpl : public StateAbstractTpl<_Scalar> {
36  public:
37  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
38 
39  typedef _Scalar Scalar;
42  typedef pinocchio::ModelTpl<Scalar> PinocchioModel;
43  typedef typename MathBase::VectorXs VectorXs;
44  typedef typename MathBase::MatrixXs MatrixXs;
45 
51  explicit StateMultibodyTpl(boost::shared_ptr<PinocchioModel> model);
53  virtual ~StateMultibodyTpl();
54 
60  virtual VectorXs zero() const;
61 
68  virtual VectorXs rand() const;
69 
70  virtual void diff(const Eigen::Ref<const VectorXs>& x0,
71  const Eigen::Ref<const VectorXs>& x1,
72  Eigen::Ref<VectorXs> dxout) const;
73  virtual void integrate(const Eigen::Ref<const VectorXs>& x,
74  const Eigen::Ref<const VectorXs>& dx,
75  Eigen::Ref<VectorXs> xout) const;
76  virtual void Jdiff(const Eigen::Ref<const VectorXs>&,
77  const Eigen::Ref<const VectorXs>&,
78  Eigen::Ref<MatrixXs> Jfirst, Eigen::Ref<MatrixXs> Jsecond,
79  const Jcomponent firstsecond = both) const;
80 
81  virtual void Jintegrate(const Eigen::Ref<const VectorXs>& x,
82  const Eigen::Ref<const VectorXs>& dx,
83  Eigen::Ref<MatrixXs> Jfirst,
84  Eigen::Ref<MatrixXs> Jsecond,
85  const Jcomponent firstsecond = both,
86  const AssignmentOp = setto) const;
87  virtual void JintegrateTransport(const Eigen::Ref<const VectorXs>& x,
88  const Eigen::Ref<const VectorXs>& dx,
89  Eigen::Ref<MatrixXs> Jin,
90  const Jcomponent firstsecond) const;
91 
95  const boost::shared_ptr<PinocchioModel>& get_pinocchio() const;
96 
97  protected:
98  using Base::has_limits_;
99  using Base::lb_;
100  using Base::ndx_;
101  using Base::nq_;
102  using Base::nv_;
103  using Base::nx_;
104  using Base::ub_;
105 
106  private:
107  boost::shared_ptr<PinocchioModel> pinocchio_;
108  VectorXs x0_;
109 };
110 
111 } // namespace crocoddyl
112 
113 /* --- Details -------------------------------------------------------------- */
114 /* --- Details -------------------------------------------------------------- */
115 /* --- Details -------------------------------------------------------------- */
116 #include "crocoddyl/multibody/states/multibody.hxx"
117 
118 #endif // CROCODDYL_MULTIBODY_STATES_MULTIBODY_HPP_
Abstract class for the state representation.
Definition: state-base.hpp:46
std::size_t nv_
Velocity dimension.
Definition: state-base.hpp:321
std::size_t nx_
State dimension.
Definition: state-base.hpp:318
bool has_limits_
Indicates whether any of the state limits is finite.
Definition: state-base.hpp:324
std::size_t nq_
Configuration dimension.
Definition: state-base.hpp:320
VectorXs lb_
Lower state limits.
Definition: state-base.hpp:322
VectorXs ub_
Upper state limits.
Definition: state-base.hpp:323
std::size_t ndx_
State rate dimension.
Definition: state-base.hpp:319
State multibody representation.
Definition: multibody.hpp:35
virtual void integrate(const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &dx, Eigen::Ref< VectorXs > xout) const
Compute the state manifold integration.
virtual VectorXs zero() const
Generate a zero state.
virtual void diff(const Eigen::Ref< const VectorXs > &x0, const Eigen::Ref< const VectorXs > &x1, Eigen::Ref< VectorXs > dxout) const
Compute the state manifold differentiation.
virtual void Jintegrate(const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &dx, Eigen::Ref< MatrixXs > Jfirst, Eigen::Ref< MatrixXs > Jsecond, const Jcomponent firstsecond=both, const AssignmentOp=setto) const
Compute the Jacobian of the state manifold integration.
const boost::shared_ptr< PinocchioModel > & get_pinocchio() const
Return the Pinocchio model (i.e., model of the rigid body system)
StateMultibodyTpl(boost::shared_ptr< PinocchioModel > model)
Initialize the multibody state.
virtual VectorXs rand() const
Generate a random state.
virtual void JintegrateTransport(const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &dx, Eigen::Ref< MatrixXs > Jin, const Jcomponent firstsecond) const
Parallel transport from integrate(x, dx) to x.
virtual void Jdiff(const Eigen::Ref< const VectorXs > &, const Eigen::Ref< const VectorXs > &, Eigen::Ref< MatrixXs > Jfirst, Eigen::Ref< MatrixXs > Jsecond, const Jcomponent firstsecond=both) const
Compute the Jacobian of the state manifold differentiation.