aligator  0.9.0
A primal-dual augmented Lagrangian-type solver for nonlinear trajectory optimization.
Loading...
Searching...
No Matches
expose-explicit-dynamics.cpp
Go to the documentation of this file.
1
7
8namespace aligator {
9namespace python {
10
15using context::Scalar;
16using PolyManifold = xyz::polymorphic<context::Manifold>;
17PolymorphicMultiBaseVisitor<DynamicsModel, ExplicitDynamics>
19
20// fwd declaration
23// fwd declaration, see expose-direct-sum.cpp
25
27
33
34struct ExplicitDataWrapper : ExplicitDynamicsData,
35 bp::wrapper<ExplicitDynamicsData> {
36 using ExplicitDynamicsData::ExplicitDynamicsData;
37};
38
40
41 using PolyExplicitDynamics = xyz::polymorphic<ExplicitDynamics>;
42 StdVectorPythonVisitor<std::vector<PolyExplicitDynamics>, true>::expose(
43 "StdVec_ExplicitDynamics",
44 eigenpy::details::overload_base_get_item_for_std_vector<
45 std::vector<PolyExplicitDynamics>>{});
46
47 register_polymorphic_to_python<PolyExplicitDynamics>();
48
49 bp::class_<PyExplicitDynamics<>, bp::bases<DynamicsModel>,
50 boost::noncopyable>(
51 "ExplicitDynamicsModel", "Base class for explicit dynamics.",
52 bp::init<const PolyManifold &, const int>(
53 "Constructor with state space and control dimension.",
54 ("self"_a, "space", "nu")))
55 .def("forward", bp::pure_virtual(&ExplicitDynamics::forward),
56 ("self"_a, "x", "u", "data"), "Call for forward discrete dynamics.")
57 .def("dForward", bp::pure_virtual(&ExplicitDynamics::dForward),
58 ("self"_a, "x", "u", "data"),
59 "Compute the derivatives of forward discrete dynamics.")
61 .def(CreateDataPolymorphicPythonVisitor<ExplicitDynamics,
63
64 bp::register_ptr_to_python<shared_ptr<ExplicitDynamicsData>>();
65
66 bp::class_<ExplicitDataWrapper, bp::bases<DynamicsData>, boost::noncopyable>(
67 "ExplicitDynamicsData", "Data struct for explicit dynamics models.",
68 bp::init<int, int, int, int>(("self"_a, "ndx1", "nu", "nx2", "ndx2")))
69 .add_property(
70 "xnext",
71 bp::make_getter(&ExplicitDynamicsData::xnext_ref,
72 bp::return_value_policy<bp::return_by_value>()))
73 .add_property(
74 "dx", bp::make_getter(&ExplicitDynamicsData::dx_ref,
75 bp::return_value_policy<bp::return_by_value>()))
77}
78
80 using context::MatrixXs;
81 using context::VectorXs;
82 using namespace aligator::dynamics;
83
84 bp::class_<LinearDiscreteDynamicsTpl<Scalar>,
85 bp::bases<context::ExplicitDynamics>>(
86 "LinearDiscreteDynamics",
87 "Linear discrete dynamics :math:`x[t+1] = Ax[t] + Bu[t] + c[t]` in "
88 "Euclidean space, or "
89 "on the tangent state space.",
90 bp::init<const MatrixXs &, const MatrixXs &, const VectorXs &>(
91 ("self"_a, "A", "B", "c")))
92 .def_readonly("A", &LinearDiscreteDynamicsTpl<Scalar>::A_)
93 .def_readonly("B", &LinearDiscreteDynamicsTpl<Scalar>::B_)
94 .def_readonly("c", &LinearDiscreteDynamicsTpl<Scalar>::c_)
96}
97
98} // namespace python
99} // namespace aligator
DynamicsModelTpl< Scalar > DynamicsModel
Definition context.hpp:27
ExplicitDynamicsModelTpl< Scalar > ExplicitDynamics
Definition context.hpp:38
DynamicsDataTpl< Scalar > DynamicsData
Definition context.hpp:28
ExplicitDynamicsDataTpl< Scalar > ExplicitDynamicsData
Definition context.hpp:39
Namespace for modelling system dynamics.
PolymorphicMultiBaseVisitor< DynamicsModel, ExplicitDynamics > exp_dynamics_visitor
xyz::polymorphic< Manifold > PolyManifold
Main package namespace.