aligator  0.10.0
A primal-dual augmented Lagrangian-type solver for nonlinear trajectory optimization.
Loading...
Searching...
No Matches
multibody-free-fwd.hpp
Go to the documentation of this file.
1
2#pragma once
3
5
6#ifdef ALIGATOR_WITH_PINOCCHIO
7#include <proxsuite-nlp/modelling/spaces/multibody.hpp>
8#include <pinocchio/multibody/data.hpp>
9
10namespace aligator {
11namespace dynamics {
12template <typename Scalar> struct MultibodyFreeFwdDataTpl;
13
24template <typename _Scalar>
25struct MultibodyFreeFwdDynamicsTpl : ODEAbstractTpl<_Scalar> {
26 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
27 using Scalar = _Scalar;
29 using Base = ODEAbstractTpl<Scalar>;
30 using BaseData = ContinuousDynamicsDataTpl<Scalar>;
31 using ContDataAbstract = ContinuousDynamicsDataTpl<Scalar>;
32 using Data = MultibodyFreeFwdDataTpl<Scalar>;
33 using Manifold = proxsuite::nlp::MultibodyPhaseSpace<Scalar>;
34 using ManifoldPtr = xyz::polymorphic<Manifold>;
35
36 using Base::nu_;
37
38 Manifold space_;
39 MatrixXs actuation_matrix_;
40
41 const Manifold &space() const { return space_; }
42 int ntau() const { return space_.getModel().nv; }
43
44 MultibodyFreeFwdDynamicsTpl(const Manifold &state, const MatrixXs &actuation);
45 MultibodyFreeFwdDynamicsTpl(const Manifold &state);
46
52 bool isUnderactuated() const {
53 long nv = space().getModel().nv;
54 return act_matrix_rank < nv;
55 }
56
57 Eigen::Index getActuationMatrixRank() const { return act_matrix_rank; }
58
59 virtual void forward(const ConstVectorRef &x, const ConstVectorRef &u,
60 BaseData &data) const;
61 virtual void dForward(const ConstVectorRef &x, const ConstVectorRef &u,
62 BaseData &data) const;
63
64 shared_ptr<ContDataAbstract> createData() const;
65
66private:
67 Eigen::FullPivLU<MatrixXs> lu_decomp_;
68 Eigen::Index act_matrix_rank;
69};
70
71template <typename Scalar>
72struct MultibodyFreeFwdDataTpl : ContinuousDynamicsDataTpl<Scalar> {
73 using Base = ContinuousDynamicsDataTpl<Scalar>;
74 using VectorXs = typename math_types<Scalar>::VectorXs;
75 using MatrixXs = typename math_types<Scalar>::MatrixXs;
76 using PinDataType = pinocchio::DataTpl<Scalar>;
77 VectorXs tau_;
78 MatrixXs dtau_dx_;
79 MatrixXs dtau_du_;
80 PinDataType pin_data_;
81 MultibodyFreeFwdDataTpl(const MultibodyFreeFwdDynamicsTpl<Scalar> *cont_dyn);
82};
83
84} // namespace dynamics
85} // namespace aligator
86
87#ifdef ALIGATOR_ENABLE_TEMPLATE_INSTANTIATION
88#include "aligator/modelling/dynamics/multibody-free-fwd.txx"
89#endif
90#endif
#define ALIGATOR_DYNAMIC_TYPEDEFS(Scalar)
Definition math.hpp:8
Main package namespace.
Defines a class representing ODEs.