12 using context::ConstVectorRef;
23 using PolyFunction = xyz::polymorphic<context::StageFunction>;
24 using PolyStage = xyz::polymorphic<StageModel>;
25 using PolyCost = xyz::polymorphic<CostAbstract>;
27 using PolySet = xyz::polymorphic<context::ConstraintSet>;
29 bp::class_<TrajOptProblem>(
"TrajOptProblem",
"Define a shooting problem.",
33 "Constructor adding the initial constraint explicitly.",
34 (
"self"_a,
"init_constraint",
"stages",
"term_cost")))
35 .def(bp::init<ConstVectorRef,
const std::vector<PolyStage> &,
PolyCost>(
36 "Constructor for an initial value problem.",
37 (
"self"_a,
"x0",
"stages",
"term_cost")))
38 .def(bp::init<PolyUnaryFunction, PolyCost>(
39 "Constructor adding the initial constraint explicitly (without "
41 (
"self"_a,
"init_constraint",
"term_cost")))
42 .def(bp::init<ConstVectorRef, const int, PolyManifold, PolyCost>(
43 "Constructor for an initial value problem (without pre-allocated "
45 (
"self"_a,
"x0",
"nu",
"space",
"term_cost")))
46 .def<void (TrajOptProblem::*)(
const PolyStage &)>(
47 "addStage", &TrajOptProblem::addStage, (
"self"_a,
"new_stage"),
48 "Add a stage to the problem.")
49 .def_readonly(
"stages", &TrajOptProblem::stages_,
50 "Stages of the shooting problem.")
51 .def_readwrite(
"term_cost", &TrajOptProblem::term_cost_,
52 "Problem terminal cost.")
53 .def_readwrite(
"term_constraints", &TrajOptProblem::term_cstrs_,
54 "Set of terminal constraints.")
55 .add_property(
"num_steps", &TrajOptProblem::numSteps,
56 "Number of stages in the problem.CostPtr")
57 .add_property(
"x0_init", &TrajOptProblem::getInitState,
58 &TrajOptProblem::setInitState,
"Initial state.")
59 .add_property(
"init_constraint", &TrajOptProblem::init_constraint_,
60 "Get initial state constraint.")
61 .def<void (TrajOptProblem::*)(
const context::StageConstraint &)>(
62 "addTerminalConstraint", &TrajOptProblem::addTerminalConstraint,
63 eigenpy::deprecated_member<>(
"This method is deprecated (because "
64 "StageConstraint has been deprecated)."),
65 (
"self"_a,
"constraint"),
"Add a terminal constraint.")
67 "addTerminalConstraint", &TrajOptProblem::addTerminalConstraint,
68 (
"self"_a,
"func",
"set"),
"Add a terminal constraint.")
69 .def(
"removeTerminalConstraint",
70 &TrajOptProblem::removeTerminalConstraints,
71 eigenpy::deprecated_member<>(
72 "This method is deprecated (due to a typo which was fixed). Use "
73 "removeTerminalConstraints instead."),
74 (
"self"_a),
"Remove all terminal constraints.")
75 .def(
"removeTerminalConstraints",
76 &TrajOptProblem::removeTerminalConstraints,
"self"_a,
77 "Remove all terminal constraints.")
78 .def(
"evaluate", &TrajOptProblem::evaluate,
79 (
"self"_a,
"xs",
"us",
"prob_data",
"num_threads"_a = 1),
80 "Evaluate the problem costs, dynamics, and constraints.")
81 .def(
"computeDerivatives", &TrajOptProblem::computeDerivatives,
82 (
"self"_a,
"xs",
"us",
"prob_data",
"num_threads"_a = 1,
83 "compute_second_order"_a =
true),
84 "Evaluate the problem derivatives. Call `evaluate()` first.")
85 .def(
"replaceStageCircular", &TrajOptProblem::replaceStageCircular,
87 "Circularly replace the last stage in the problem, dropping the "
89 .def(
"checkIntegrity", &TrajOptProblem::checkIntegrity, (
"self"_a));
93 "Compute trajectory cost (call evaluate() first!)");
95 bp::class_<TrajOptData>(
96 "TrajOptData",
"Data struct for shooting problems.",
97 bp::init<const TrajOptProblem &>((
"self"_a,
"problem")))
98 .def_readwrite(
"init_data", &TrajOptData::init_data,
99 "Initial stage contraint data.")
100 .def_readwrite(
"cost", &TrajOptData::cost_,
101 "Current cost of the TO problem.")
102 .def_readwrite(
"term_cost", &TrajOptData::term_cost_data,
103 "Terminal cost data.")
104 .def_readwrite(
"term_constraint", &TrajOptData::term_cstr_data,
105 "Terminal constraint data.")
106 .def_readonly(
"stage_data", &TrajOptData::stage_data,
107 "Data for each stage.");
ManifoldAbstractTpl< Scalar > Manifold