aligator  0.9.0
A primal-dual augmented Lagrangian-type solver for nonlinear trajectory optimization.
Loading...
Searching...
No Matches
expose-continuous-dynamics.cpp
Go to the documentation of this file.
1
8
9namespace aligator {
10namespace python {
11using namespace ::aligator::dynamics;
12using context::MatrixXs;
13using context::Scalar;
14using context::VectorXs;
15
18
19struct ContinousDataWrapper : ContinuousDynamicsData,
20 bp::wrapper<ContinuousDynamicsData> {
21 using ContinuousDynamicsData::ContinuousDynamicsData;
22};
23
24void exposeODEs();
25
27 using ManifoldPtr = xyz::polymorphic<context::Manifold>;
28
29 register_polymorphic_to_python<
30 xyz::polymorphic<ContinuousDynamicsAbstract>>();
32
33 bp::class_<PyContinuousDynamics<>, boost::noncopyable>(
34 "ContinuousDynamicsAbstract",
35 "Base class for continuous-time dynamical models (DAEs and ODEs).",
36 bp::init<ManifoldPtr, int>("Default constructor: provide the working "
37 "manifold and control space "
38 "dimension.",
39 bp::args("self", "space", "nu")))
40 .add_property("ndx", &ContinuousDynamicsAbstract::ndx,
41 "State space dimension.")
42 .add_property("nu", &ContinuousDynamicsAbstract::nu,
43 "Control space dimension.")
44 .def("evaluate", bp::pure_virtual(&ContinuousDynamicsAbstract::evaluate),
45 bp::args("self", "x", "u", "xdot", "data"),
46 "Evaluate the DAE functions.")
47 .def("computeJacobians",
48 bp::pure_virtual(&ContinuousDynamicsAbstract::computeJacobians),
49 bp::args("self", "x", "u", "xdot", "data"),
50 "Evaluate the DAE function derivatives.")
51 .add_property("space",
52 bp::make_function(&ContinuousDynamicsAbstract::space,
53 bp::return_internal_reference<>()),
54 "Get the state space.")
55 .def(CreateDataPolymorphicPythonVisitor<ContinuousDynamicsAbstract,
57 .def(conversion_visitor);
58
59 bp::register_ptr_to_python<shared_ptr<ContinuousDynamicsData>>();
60 auto cont_data_cls =
61 bp::class_<ContinousDataWrapper, boost::noncopyable>(
62 "ContinuousDynamicsData",
63 "Data struct for continuous dynamics/DAE models.",
64 bp::init<int, int>(bp::args("self", "ndx", "nu")))
65 .add_property("value",
66 bp::make_getter(&ContinuousDynamicsData::value_,
67 bp::return_internal_reference<>()),
68 "Vector value of the DAE residual.")
69 .add_property("Jx",
70 bp::make_getter(&ContinuousDynamicsData::Jx_,
71 bp::return_internal_reference<>()),
72 "Jacobian with respect to state.")
73 .add_property("Ju",
74 bp::make_getter(&ContinuousDynamicsData::Ju_,
75 bp::return_internal_reference<>()),
76 "Jacobian with respect to controls.")
77 .add_property("Jxdot",
78 bp::make_getter(&ContinuousDynamicsData::Jxdot_,
79 bp::return_internal_reference<>()),
80 "Jacobian with respect to :math:`\\dot{x}`.")
81 .add_property("xdot",
82 bp::make_getter(&ContinuousDynamicsData::xdot_,
83 bp::return_internal_reference<>()),
84 "Time derivative :math:`\\dot{x}`.");
85
86 // Alias this for back-compatibility
87 bp::scope().attr("ODEData") = cont_data_cls;
88
89 exposeODEs();
90}
91
92} // namespace python
93} // namespace aligator
Base definitions for continuous dynamics.
dynamics::ContinuousDynamicsAbstractTpl< Scalar > ContinuousDynamicsAbstract
Definition context.hpp:9
dynamics::ContinuousDynamicsDataTpl< Scalar > ContinuousDynamicsData
Definition context.hpp:12
Namespace for modelling system dynamics.
void exposeContinuousDynamics()
Expose continuous dynamics.
Main package namespace.