aligator  0.10.0
A primal-dual augmented Lagrangian-type solver for nonlinear trajectory optimization.
Loading...
Searching...
No Matches
explicit-dynamics.hpp
Go to the documentation of this file.
1
3#pragma once
4
6
7#include <proxsuite-nlp/manifold-base.hpp>
8
9#include <fmt/format.h>
10
11namespace aligator {
12
19template <typename _Scalar>
20struct ExplicitDynamicsModelTpl : DynamicsModelTpl<_Scalar> {
21public:
22 using Scalar = _Scalar;
27 using Manifold = ManifoldAbstractTpl<Scalar>;
28 using ManifoldPtr = xyz::polymorphic<Manifold>;
29
30 bool isExplicit() const { return true; }
31
34 virtual ~ExplicitDynamicsModelTpl() = default;
35
37 void virtual forward(const ConstVectorRef &x, const ConstVectorRef &u,
38 Data &data) const = 0;
39
41 void virtual dForward(const ConstVectorRef &x, const ConstVectorRef &u,
42 Data &data) const = 0;
43
44 void evaluate(const ConstVectorRef &x, const ConstVectorRef &u,
45 const ConstVectorRef &y, BaseData &data) const;
46
47 void computeJacobians(const ConstVectorRef &x, const ConstVectorRef &u,
48 const ConstVectorRef &y, BaseData &data) const;
49
50 virtual shared_ptr<BaseData> createData() const;
51};
52
55template <typename _Scalar>
57 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
58 using Scalar = _Scalar;
61 using Base::Ju_;
62 using Base::Jx_;
63 using Base::Jy_;
64 using Base::value_;
66 VectorXs xnext_;
68 VectorXs dx_;
70 MatrixXs Jtmp_xnext;
71
72 VectorRef xnext_ref;
73 VectorRef dx_ref;
74
75 ExplicitDynamicsDataTpl(const int ndx1, const int nu, const int nx2,
76 const int ndx2);
77 virtual ~ExplicitDynamicsDataTpl() = default;
78
79 template <typename S>
80 friend std::ostream &operator<<(std::ostream &oss,
81 const ExplicitDynamicsDataTpl<S> &self);
82};
83
84template <typename S>
85std::ostream &operator<<(std::ostream &oss,
86 const ExplicitDynamicsDataTpl<S> &self) {
87 oss << "ExplicitDynamicsData { ";
88 oss << fmt::format("ndx: {:d}, ", self.ndx1);
89 oss << fmt::format("nu: {:d}", self.nu);
90 oss << " }";
91 return oss;
92}
93
94} // namespace aligator
95
96#ifdef ALIGATOR_ENABLE_TEMPLATE_INSTANTIATION
97#include "aligator/core/explicit-dynamics.txx"
98#endif
Main package namespace.
std::ostream & operator<<(std::ostream &oss, const ExplicitDynamicsDataTpl< S > &self)
MatrixRef Jx_
Jacobian with respect to .
Definition dynamics.hpp:93
MatrixRef Jy_
Jacobian with respect to .
Definition dynamics.hpp:97
VectorXs value_
Function value.
Definition dynamics.hpp:88
MatrixRef Ju_
Jacobian with respect to .
Definition dynamics.hpp:95
Dynamics model: describes system dynamics through an implicit relation .
Definition fwd.hpp:68
const Manifold & space() const
Definition dynamics.hpp:32
Specific data struct for explicit dynamics ExplicitDynamicsModelTpl.
Definition fwd.hpp:80
ExplicitDynamicsDataTpl(const int ndx1, const int nu, const int nx2, const int ndx2)
virtual ~ExplicitDynamicsDataTpl()=default
friend std::ostream & operator<<(std::ostream &oss, const ExplicitDynamicsDataTpl< S > &self)
VectorXs dx_
Difference vector between current state x and xnext_.
virtual shared_ptr< BaseData > createData() const
bool isExplicit() const
Check if this dynamics model is implicit or explicit.
ManifoldAbstractTpl< Scalar > Manifold
virtual void forward(const ConstVectorRef &x, const ConstVectorRef &u, Data &data) const =0
Evaluate the forward discrete dynamics.
void computeJacobians(const ConstVectorRef &x, const ConstVectorRef &u, const ConstVectorRef &y, BaseData &data) const
virtual ~ExplicitDynamicsModelTpl()=default
ExplicitDynamicsModelTpl(const ManifoldPtr &space, const int nu)
Constructor requires providing the next state's manifold.
virtual void dForward(const ConstVectorRef &x, const ConstVectorRef &u, Data &data) const =0
Compute the Jacobians of the forward dynamics.
xyz::polymorphic< Manifold > ManifoldPtr
void evaluate(const ConstVectorRef &x, const ConstVectorRef &u, const ConstVectorRef &y, BaseData &data) const