aligator  0.6.1
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
3#include "aligator/fwd.hpp"
4#include <proxsuite-nlp/manifold-base.hpp>
5
6#include <crocoddyl/core/state-base.hpp>
7#include <boost/shared_ptr.hpp>
8
9namespace aligator {
10namespace compat {
11namespace croc {
12
15template <typename _Scalar>
16struct StateWrapperTpl : ManifoldAbstractTpl<_Scalar> {
17 using Scalar = _Scalar;
19 using PointType = Eigen::Matrix<Scalar, Eigen::Dynamic, 1>;
20 using TangentVectorType = Eigen::Matrix<Scalar, Eigen::Dynamic, 1>;
21
22 using StateAbstract = crocoddyl::StateAbstractTpl<Scalar>;
23
24 boost::shared_ptr<StateAbstract> croc_state;
25
26 explicit StateWrapperTpl(const boost::shared_ptr<StateAbstract> &state)
27 : croc_state(state) {}
28
29 int nx() const { return (int)croc_state->get_nx(); }
30 int ndx() const { return (int)croc_state->get_ndx(); }
31
32 PointType neutral() const { return croc_state->zero(); }
33 PointType rand() const { return croc_state->rand(); }
34
35 void integrate_impl(const ConstVectorRef &x, const ConstVectorRef &v,
36 VectorRef out) const {
37 croc_state->integrate(x, v, out);
38 }
39
40 void Jintegrate_impl(const ConstVectorRef &x, const ConstVectorRef &v,
41 MatrixRef Jout, int arg) const {
42 croc_state->Jintegrate(x, v, Jout, Jout, convert_to_firstsecond(arg));
43 }
44
45 void difference_impl(const ConstVectorRef &x0, const ConstVectorRef &x1,
46 VectorRef out) const {
47 croc_state->diff(x0, x1, out);
48 }
49
50 void Jdifference_impl(const ConstVectorRef &x0, const ConstVectorRef &x1,
51 MatrixRef Jout, int arg) const {
52 croc_state->Jdiff(x0, x1, Jout, Jout, convert_to_firstsecond(arg));
53 }
54
55 void JintegrateTransport(const ConstVectorRef &x, const ConstVectorRef &v,
56 MatrixRef Jout, int arg) const {
57 croc_state->JintegrateTransport(x, v, Jout, convert_to_firstsecond(arg));
58 }
59
60 static crocoddyl::Jcomponent convert_to_firstsecond(int arg) {
61 if (arg == 0) {
62 return crocoddyl::first;
63 } else if (arg == 1) {
64 return crocoddyl::second;
65 } else {
66 return crocoddyl::both;
67 }
68 }
69};
70
71} // namespace croc
72} // namespace compat
73} // namespace aligator
Forward declarations.
Main package namespace.
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