1 |
|
|
/////////////////////////////////////////////////////////////////////////////// |
2 |
|
|
// 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. |
7 |
|
|
/////////////////////////////////////////////////////////////////////////////// |
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 |
|
|
|
19 |
|
|
/** |
20 |
|
|
* @brief State multibody representation |
21 |
|
|
* |
22 |
|
|
* A multibody state is described by the configuration point and its tangential |
23 |
|
|
* velocity, or in other words, by the generalized position and velocity |
24 |
|
|
* coordinates of a rigid-body system. For this state, we describe its |
25 |
|
|
* operators: difference, integrates, transport and their derivatives for any |
26 |
|
|
* Pinocchio model. |
27 |
|
|
* |
28 |
|
|
* For more details about these operators, please read the documentation of the |
29 |
|
|
* `StateAbstractTpl` class. |
30 |
|
|
* |
31 |
|
|
* \sa `diff()`, `integrate()`, `Jdiff()`, `Jintegrate()` and |
32 |
|
|
* `JintegrateTransport()` |
33 |
|
|
*/ |
34 |
|
|
template <typename _Scalar> |
35 |
|
|
class StateMultibodyTpl : public StateAbstractTpl<_Scalar> { |
36 |
|
|
public: |
37 |
|
|
EIGEN_MAKE_ALIGNED_OPERATOR_NEW |
38 |
|
|
|
39 |
|
|
typedef _Scalar Scalar; |
40 |
|
|
typedef MathBaseTpl<Scalar> MathBase; |
41 |
|
|
typedef StateAbstractTpl<Scalar> Base; |
42 |
|
|
typedef pinocchio::ModelTpl<Scalar> PinocchioModel; |
43 |
|
|
typedef typename MathBase::VectorXs VectorXs; |
44 |
|
|
typedef typename MathBase::MatrixXs MatrixXs; |
45 |
|
|
|
46 |
|
|
/** |
47 |
|
|
* @brief Initialize the multibody state |
48 |
|
|
* |
49 |
|
|
* @param[in] model Pinocchio model |
50 |
|
|
*/ |
51 |
|
|
explicit StateMultibodyTpl(boost::shared_ptr<PinocchioModel> model); |
52 |
|
|
StateMultibodyTpl(); |
53 |
|
|
virtual ~StateMultibodyTpl(); |
54 |
|
|
|
55 |
|
|
/** |
56 |
|
|
* @brief Generate a zero state. |
57 |
|
|
* |
58 |
|
|
* Note that the zero configuration is computed using `pinocchio::neutral`. |
59 |
|
|
*/ |
60 |
|
|
virtual VectorXs zero() const; |
61 |
|
|
|
62 |
|
|
/** |
63 |
|
|
* @brief Generate a random state |
64 |
|
|
* |
65 |
|
|
* Note that the random configuration is computed using `pinocchio::random` |
66 |
|
|
* which satisfies the manifold definition (e.g., the quaterion definition) |
67 |
|
|
*/ |
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 |
|
|
|
92 |
|
|
/** |
93 |
|
|
* @brief Return the Pinocchio model (i.e., model of the rigid body system) |
94 |
|
|
*/ |
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_; //!< Pinocchio model |
108 |
|
|
VectorXs x0_; //!< Zero state |
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_ |