aligator  0.14.0
A primal-dual augmented Lagrangian-type solver for nonlinear trajectory optimization.
Loading...
Searching...
No Matches
expose-stage.cpp
Go to the documentation of this file.
1
5
9
10#include <eigenpy/deprecation-policy.hpp>
11
12namespace aligator {
13namespace python {
14
18
19 bp::register_ptr_to_python<shared_ptr<StageData>>();
20 StdVectorPythonVisitor<std::vector<shared_ptr<StageData>>, true>::expose(
21 "StdVec_StageData");
22
23 bp::class_<StageData>("StageData", "Data struct for StageModel objects.",
24 bp::init<const StageModel &>())
25 .def_readonly("cost_data", &StageData::cost_data)
26 .def_readwrite("dynamics_data", &StageData::dynamics_data)
27 .def_readwrite("constraint_data", &StageData::constraint_data);
28}
29
33 using context::Scalar;
35
39 using PolyCstrSet = xyz::polymorphic<ConstraintSet>;
40 using PolyStage = xyz::polymorphic<StageModel>;
41
43
44 using StageVec = std::vector<PolyStage>;
45 StdVectorPythonVisitor<StageVec, true>::expose(
46 "StdVec_StageModel",
47 eigenpy::details::overload_base_get_item_for_std_vector<StageVec>());
48
49#pragma GCC diagnostic push
50#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
51 bp::class_<StageModel>(
52 "StageModel",
53 "A stage of the control problem. Holds costs, dynamics, and constraints.",
54 bp::no_init)
55 .def(bp::init<const PolyCost &, const PolyDynamics &>(
56 ("self"_a, "cost", "dynamics")))
57 .def<void (StageModel::*)(const context::StageConstraint &)>(
58 "addConstraint", &StageModel::addConstraint,
59 eigenpy::deprecated_member<>("This method has been deprecated since "
60 "StageConstraint is deprecated."),
61 ("self"_a, "constraint"), "Add an existing constraint to the stage.")
62 .def<void (StageModel::*)(const PolyFunction &, const PolyCstrSet &)>(
63 "addConstraint", &StageModel::addConstraint,
64 ("self"_a, "func", "cstr_set"),
65 "Constructs a new constraint (from the underlying function and set) "
66 "and adds it to the stage.")
67 .def_readonly("constraints", &StageModel::constraints_,
68 "Get the set of constraints.")
69 .def_readonly("dynamics", &StageModel::dynamics_, "Stage dynamics.")
70 .add_property("xspace",
71 bp::make_getter(&StageModel::xspace_,
72 bp::return_internal_reference<>()),
73 "State space for the current state :math:`x_k`.")
74 .add_property("xspace_next",
75 bp::make_getter(&StageModel::xspace_next_,
76 bp::return_internal_reference<>()),
77 "State space corresponding to next state :math:`x_{k+1}`.")
78 .add_property("uspace",
79 bp::make_getter(&StageModel::uspace_,
80 bp::return_internal_reference<>()),
81 "Control space.")
82 .add_property("cost",
83 bp::make_getter(&StageModel::cost_,
84 bp::return_internal_reference<>()),
85 "Stage cost.")
86 .def("evaluate", &StageModel::evaluate, ("self"_a, "x", "u", "y", "data"),
87 "Evaluate the stage cost, dynamics, constraints.")
88 .def("computeFirstOrderDerivatives",
89 &StageModel::computeFirstOrderDerivatives,
90 ("self"_a, "x", "u", "y", "data"),
91 "Compute gradients of the stage cost and jacobians of the dynamics "
92 "and "
93 "constraints.")
94 .def("computeSecondOrderDerivatives",
95 &StageModel::computeSecondOrderDerivatives,
96 ("self"_a, "x", "u", "data"), "Compute Hessians of the stage cost.")
97 .add_property("ndx1", &StageModel::ndx1)
98 .add_property("ndx2", &StageModel::ndx2)
99 .add_property("nu", &StageModel::nu, "Control space dimension.")
100 .add_property("num_primal", &StageModel::numPrimal,
101 "Number of primal variables.")
102 .add_property("num_dual", &StageModel::numDual,
103 "Number of dual variables.")
108#pragma GCC diagnostic pop
109
111}
112
113} // namespace python
114} // namespace aligator
StageModelTpl< Scalar > StageModel
Definition context.hpp:30
ManifoldAbstractTpl< Scalar > Manifold
Definition context.hpp:14
StageDataTpl< Scalar > StageData
Definition context.hpp:31
ConstraintSetTpl< Scalar > ConstraintSet
Definition context.hpp:22
The Python bindings.
Definition blk-matrix.hpp:5
xyz::polymorphic< StageFunction > PolyFunction
void exposeStage()
Expose StageModel and StageData.
void register_polymorphic_to_python()
Expose a polymorphic value type, e.g. xyz::polymorphic<T, A>.
xyz::polymorphic< CostAbstract > PolyCost
Main package namespace.