11 using context::ConstVectorRef;
21 bp::class_<TrajOptProblem>(
"TrajOptProblem",
"Define a shooting problem.",
23 .def(bp::init<shared_ptr<UnaryFunction>,
24 const std::vector<shared_ptr<StageModel>> &,
25 shared_ptr<CostAbstract>>(
26 "Constructor adding the initial constraint explicitly.",
27 (
"self"_a,
"init_constraint",
"stages",
"term_cost")))
28 .def(bp::init<ConstVectorRef,
const std::vector<shared_ptr<StageModel>> &,
29 shared_ptr<CostAbstract>>(
30 "Constructor for an initial value problem.",
31 (
"self"_a,
"x0",
"stages",
"term_cost")))
32 .def(bp::init<shared_ptr<UnaryFunction>, shared_ptr<CostAbstract>>(
33 "Constructor adding the initial constraint explicitly (without "
35 (
"self"_a,
"init_constraint",
"term_cost")))
36 .def(bp::init<ConstVectorRef,
const int, shared_ptr<Manifold>,
37 shared_ptr<CostAbstract>>(
38 "Constructor for an initial value problem (without pre-allocated "
40 (
"self"_a,
"x0",
"nu",
"space",
"term_cost")))
41 .def<void (TrajOptProblem::*)(
const shared_ptr<StageModel> &)>(
42 "addStage", &TrajOptProblem::addStage, (
"self"_a,
"new_stage"),
43 "Add a stage to the problem.")
44 .def_readonly(
"stages", &TrajOptProblem::stages_,
45 "Stages of the shooting problem.")
46 .def_readwrite(
"term_cost", &TrajOptProblem::term_cost_,
47 "Problem terminal cost.")
48 .def_readwrite(
"term_constraints", &TrajOptProblem::term_cstrs_,
49 "Set of terminal constraints.")
50 .add_property(
"num_steps", &TrajOptProblem::numSteps,
51 "Number of stages in the problem.")
52 .add_property(
"x0_init", &TrajOptProblem::getInitState,
53 &TrajOptProblem::setInitState,
"Initial state.")
54 .add_property(
"init_constraint", &TrajOptProblem::init_condition_,
55 "Get initial state constraint.")
56 .def(
"addTerminalConstraint", &TrajOptProblem::addTerminalConstraint,
57 (
"self"_a,
"constraint"),
"Add a terminal constraint.")
58 .def(
"removeTerminalConstraint",
59 &TrajOptProblem::removeTerminalConstraints,
"self"_a,
60 "Remove all terminal constraints.")
61 .def(
"evaluate", &TrajOptProblem::evaluate,
62 (
"self"_a,
"xs",
"us",
"prob_data",
"num_threads"_a = 1),
63 "Evaluate the problem costs, dynamics, and constraints.")
64 .def(
"computeDerivatives", &TrajOptProblem::computeDerivatives,
65 (
"self"_a,
"xs",
"us",
"prob_data",
"num_threads"_a = 1,
66 "compute_second_order"_a =
true),
67 "Evaluate the problem derivatives. Call `evaluate()` first.")
68 .def(
"replaceStageCircular", &TrajOptProblem::replaceStageCircular,
70 "Circularly replace the last stage in the problem, dropping the "
73 bp::register_ptr_to_python<shared_ptr<TrajOptData>>();
74 bp::class_<TrajOptData>(
75 "TrajOptData",
"Data struct for shooting problems.",
76 bp::init<const TrajOptProblem &>((
"self"_a,
"problem")))
77 .def_readwrite(
"init_data", &TrajOptData::init_data,
78 "Initial stage contraint data.")
79 .def_readwrite(
"cost", &TrajOptData::cost_,
80 "Current cost of the TO problem.")
81 .def_readwrite(
"term_cost", &TrajOptData::term_cost_data,
82 "Terminal cost data.")
83 .def_readwrite(
"term_constraint", &TrajOptData::term_cstr_data,
84 "Terminal constraint data.")
85 .def_readonly(
"stage_data", &TrajOptData::stage_data,
86 "Data for each stage.");
ManifoldAbstractTpl< Scalar > Manifold
TrajOptProblemTpl< Scalar > TrajOptProblem