aligator  0.15.0
A primal-dual augmented Lagrangian-type solver for nonlinear trajectory optimization.
Loading...
Searching...
No Matches
expose-ode.cpp
Go to the documentation of this file.
1
11
12namespace aligator::python {
13using namespace ::aligator::dynamics;
15using context::MatrixXs;
18using context::Scalar;
20using context::VectorXs;
21using PolyManifold = xyz::polymorphic<context::Manifold>;
22
30
31void exposeODEs() {
34 ode_visitor;
35
36 bp::class_<PyODEAbstract<>, bp::bases<ContinuousDynamicsAbstract>,
37 boost::noncopyable>(
38 "ODEAbstract",
39 "Continuous dynamics described by ordinary differential equations "
40 "(ODEs).",
41 bp::init<const PolyManifold &, int>(bp::args("self", "space", "nu")))
42 .def("forward", bp::pure_virtual(&ODEAbstract::forward),
43 bp::args("self", "x", "u", "data"),
44 "Compute the value of the ODE vector field, i.e. the "
45 "state time derivative :math:`\\dot{x}`.")
46 .def("dForward", bp::pure_virtual(&ODEAbstract::dForward),
47 bp::args("self", "x", "u", "data"),
48 "Compute the derivatives of the ODE vector field with respect "
49 "to the state-control pair :math:`(x, u)`.")
51 .def(ode_visitor);
52
53 bp::class_<LinearODETpl<Scalar>, bp::bases<ODEAbstract>>(
54 "LinearODE",
55 "Linear ordinary differential equation, :math:`\\dot{x} = Ax + Bu`.",
56 bp::init<PolyManifold, MatrixXs, MatrixXs, VectorXs>(
57 bp::args("self", "A", "B", "c")))
58 .def(bp::init<MatrixXs, MatrixXs, VectorXs>(
59 "Constructor with just the matrices; a Euclidean state space is "
60 "assumed.",
61 bp::args("self", "A", "B", "c")))
62 .def_readonly("A", &LinearODETpl<Scalar>::A_, "State transition matrix.")
63 .def_readonly("B", &LinearODETpl<Scalar>::B_, "Control matrix.")
64 .def_readonly("c", &LinearODETpl<Scalar>::c_, "Constant drift term.")
65 .def(ode_visitor);
66
67 bp::class_<CentroidalFwdDynamics, bp::bases<ODEAbstract>>(
68 "CentroidalFwdDynamics",
69 "Nonlinear centroidal dynamics with preplanned feet positions",
70 bp::init<const VectorSpace &, const double, const Vector3s &,
71 const ContactMap &, const int>(
72 bp::args("self", "space", "total mass", "gravity", "contact_map",
73 "force_size")))
74 .def_readwrite("contact_map", &CentroidalFwdDynamics::contact_map_)
76 .def(ode_visitor);
77
78 bp::register_ptr_to_python<shared_ptr<CentroidalFwdDataTpl<Scalar>>>();
79 bp::class_<CentroidalFwdDataTpl<Scalar>, bp::bases<ODEData>>(
80 "CentroidalFwdData", bp::no_init);
81
82 bp::class_<ContinuousCentroidalFwdDynamics, bp::bases<ODEAbstract>>(
83 "ContinuousCentroidalFwdDynamics",
84 "Nonlinear centroidal dynamics with preplanned feet positions and smooth "
85 "forces",
86 bp::init<const VectorSpace &, const double, const Vector3s &,
87 const ContactMap &, const int>(
88 bp::args("self", "space", "total mass", "gravity", "contact_map",
89 "force_size")))
90 .def_readwrite("contact_map",
93 .def(ode_visitor);
94
95 bp::register_ptr_to_python<
96 shared_ptr<ContinuousCentroidalFwdDataTpl<Scalar>>>();
97 bp::class_<ContinuousCentroidalFwdDataTpl<Scalar>, bp::bases<ODEData>>(
98 "ContinuousCentroidalFwdData", bp::no_init);
99 bp::class_<WheeledInvertedPendulumDynamics, bp::bases<ODEAbstract>>(
100 "WheeledInvertedPendulumDynamics",
101 "Wheeled inverted pendulum dynamics with integrator dynamics for the yaw",
102 bp::init<const Scalar, const Scalar>(
103 bp::args("self", "gravity", "length")))
105 .def(ode_visitor);
106}
107} // namespace aligator::python
dynamics::ContinuousDynamicsDataTpl< Scalar > ODEData
Definition context.hpp:16
dynamics::ContinuousDynamicsAbstractTpl< Scalar > ContinuousDynamicsAbstract
Definition context.hpp:9
dynamics::ODEAbstractTpl< Scalar > ODEAbstract
Definition context.hpp:14
VectorSpaceTpl< Scalar, Eigen::Dynamic > VectorSpace
Definition context.hpp:15
The Python bindings.
Definition blk-matrix.hpp:5
typename math_types< Scalar >::Vector3s Vector3s
xyz::polymorphic< Manifold > PolyManifold
CentroidalFwdDynamicsTpl< Scalar > CentroidalFwdDynamics
ContinuousCentroidalFwdDynamicsTpl< Scalar > ContinuousCentroidalFwdDynamics
void register_polymorphic_to_python()
Expose a polymorphic value type, e.g. xyz::polymorphic<T, A>.
WheeledInvertedPendulumDynamicsTpl< Scalar > WheeledInvertedPendulumDynamics
ContactMapTpl< Scalar > ContactMap
Contact map for centroidal costs and dynamics.
Nonlinear centroidal forward dynamics.
Nonlinear centroidal forward dynamics with smooth control.
virtual void forward(const ConstVectorRef &x, const ConstVectorRef &u, Data &data) const=0
virtual void dForward(const ConstVectorRef &x, const ConstVectorRef &u, Data &data) const=0
Typedefs for math (Eigen vectors, matrices) depending on scalar type.
Definition math.hpp:100