aligator  0.9.0
A primal-dual augmented Lagrangian-type solver for nonlinear trajectory optimization.
Loading...
Searching...
No Matches
state-wrap.hpp
Go to the documentation of this file.
1#pragma once
2
4#include <proxsuite-nlp/manifold-base.hpp>
5
6#include <crocoddyl/core/state-base.hpp>
7#include <boost/shared_ptr.hpp>
8
10
13template <typename _Scalar>
14struct StateWrapperTpl : ManifoldAbstractTpl<_Scalar> {
15 using Scalar = _Scalar;
17 using PointType = Eigen::Matrix<Scalar, Eigen::Dynamic, 1>;
18 using TangentVectorType = Eigen::Matrix<Scalar, Eigen::Dynamic, 1>;
19
20 using StateAbstract = crocoddyl::StateAbstractTpl<Scalar>;
21
22 boost::shared_ptr<StateAbstract> croc_state;
23
24 explicit StateWrapperTpl(const boost::shared_ptr<StateAbstract> &state)
25 : croc_state(state) {}
26
27 int nx() const { return (int)croc_state->get_nx(); }
28 int ndx() const { return (int)croc_state->get_ndx(); }
29
30 PointType neutral() const { return croc_state->zero(); }
31 PointType rand() const { return croc_state->rand(); }
32
33 void integrate_impl(const ConstVectorRef &x, const ConstVectorRef &v,
34 VectorRef out) const {
35 croc_state->integrate(x, v, out);
36 }
37
38 void Jintegrate_impl(const ConstVectorRef &x, const ConstVectorRef &v,
39 MatrixRef Jout, int arg) const {
40 croc_state->Jintegrate(x, v, Jout, Jout, convert_to_firstsecond(arg));
41 }
42
43 void difference_impl(const ConstVectorRef &x0, const ConstVectorRef &x1,
44 VectorRef out) const {
45 croc_state->diff(x0, x1, out);
46 }
47
48 void Jdifference_impl(const ConstVectorRef &x0, const ConstVectorRef &x1,
49 MatrixRef Jout, int arg) const {
50 croc_state->Jdiff(x0, x1, Jout, Jout, convert_to_firstsecond(arg));
51 }
52
53 void JintegrateTransport(const ConstVectorRef &x, const ConstVectorRef &v,
54 MatrixRef Jout, int arg) const {
55 croc_state->JintegrateTransport(x, v, Jout, convert_to_firstsecond(arg));
56 }
57
58 static crocoddyl::Jcomponent convert_to_firstsecond(int arg) {
59 if (arg == 0) {
60 return crocoddyl::first;
61 } else if (arg == 1) {
62 return crocoddyl::second;
63 } else {
64 return crocoddyl::both;
65 }
66 }
67};
68
69#ifdef ALIGATOR_ENABLE_TEMPLATE_INSTANTIATION
70extern template struct StateWrapperTpl<context::Scalar>;
71#endif
72
73} // namespace aligator::compat::croc
Headers for the Crocoddyl compatibility module.
Wraps a crocoddyl::StateAbstractTpl to a manifold (proxsuite::nlp::ManifoldAbstractTpl).
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > TangentVectorType
static crocoddyl::Jcomponent convert_to_firstsecond(int arg)
crocoddyl::StateAbstractTpl< Scalar > StateAbstract
void Jdifference_impl(const ConstVectorRef &x0, const ConstVectorRef &x1, MatrixRef Jout, int arg) const
void JintegrateTransport(const ConstVectorRef &x, const ConstVectorRef &v, MatrixRef Jout, int arg) const
void difference_impl(const ConstVectorRef &x0, const ConstVectorRef &x1, VectorRef out) const
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > PointType
void Jintegrate_impl(const ConstVectorRef &x, const ConstVectorRef &v, MatrixRef Jout, int arg) const
StateWrapperTpl(const boost::shared_ptr< StateAbstract > &state)
boost::shared_ptr< StateAbstract > croc_state
void integrate_impl(const ConstVectorRef &x, const ConstVectorRef &v, VectorRef out) const