26 using PolyCost = xyz::polymorphic<context::CostAbstract>;
27 using PolyDynamics = xyz::polymorphic<context::DynamicsModel>;
28 using PolyFunction = xyz::polymorphic<context::StageFunction>;
29 using PolyCstrSet = xyz::polymorphic<ConstraintSet>;
30 using PolyStage = xyz::polymorphic<StageModel>;
32 register_polymorphic_to_python<PolyStage>();
34 using StageVec = std::vector<PolyStage>;
35 StdVectorPythonVisitor<StageVec, true>::expose(
37 eigenpy::details::overload_base_get_item_for_std_vector<StageVec>());
39#pragma GCC diagnostic push
40#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
41 bp::class_<StageModel>(
43 "A stage of the control problem. Holds costs, dynamics, and constraints.",
45 .def(bp::init<const PolyCost &, const PolyDynamics &>(
46 (
"self"_a,
"cost",
"dynamics")))
47 .def<void (StageModel::*)(
const context::StageConstraint &)>(
48 "addConstraint", &StageModel::addConstraint,
49 eigenpy::deprecated_member<>(
"This method has been deprecated since "
50 "StageConstraint is deprecated."),
51 (
"self"_a,
"constraint"),
"Add an existing constraint to the stage.")
52 .def<void (StageModel::*)(
const PolyFunction &,
const PolyCstrSet &)>(
53 "addConstraint", &StageModel::addConstraint,
54 (
"self"_a,
"func",
"cstr_set"),
55 "Constructs a new constraint (from the underlying function and set) "
56 "and adds it to the stage.")
57 .def_readonly(
"constraints", &StageModel::constraints_,
58 "Get the set of constraints.")
59 .def_readonly(
"dynamics", &StageModel::dynamics_,
"Stage dynamics.")
60 .add_property(
"xspace",
61 bp::make_getter(&StageModel::xspace_,
62 bp::return_internal_reference<>()),
63 "State space for the current state :math:`x_k`.")
64 .add_property(
"xspace_next",
65 bp::make_getter(&StageModel::xspace_next_,
66 bp::return_internal_reference<>()),
67 "State space corresponding to next state :math:`x_{k+1}`.")
68 .add_property(
"uspace",
69 bp::make_getter(&StageModel::uspace_,
70 bp::return_internal_reference<>()),
73 bp::make_getter(&StageModel::cost_,
74 bp::return_internal_reference<>()),
76 .def(
"evaluate", &StageModel::evaluate, (
"self"_a,
"x",
"u",
"y",
"data"),
77 "Evaluate the stage cost, dynamics, constraints.")
78 .def(
"computeFirstOrderDerivatives",
79 &StageModel::computeFirstOrderDerivatives,
80 (
"self"_a,
"x",
"u",
"y",
"data"),
81 "Compute gradients of the stage cost and jacobians of the dynamics "
84 .def(
"computeSecondOrderDerivatives",
85 &StageModel::computeSecondOrderDerivatives,
86 (
"self"_a,
"x",
"u",
"data"),
"Compute Hessians of the stage cost.")
87 .add_property(
"ndx1", &StageModel::ndx1)
88 .add_property(
"ndx2", &StageModel::ndx2)
89 .add_property(
"nu", &StageModel::nu,
"Control space dimension.")
90 .add_property(
"num_primal", &StageModel::numPrimal,
91 "Number of primal variables.")
92 .add_property(
"num_dual", &StageModel::numDual,
93 "Number of dual variables.")
97 .def(PolymorphicVisitor<PolyStage>());
98#pragma GCC diagnostic pop
ManifoldAbstractTpl< Scalar > Manifold
ConstraintSetTpl< Scalar > ConstraintSet