31 bp::class_<ConstantCostTpl<Scalar>, bp::bases<CostAbstract>>(
32 "ConstantCost",
"A constant cost term.",
33 bp::init<xyz::polymorphic<Manifold>, int, Scalar>(
34 bp::args(
"self",
"space",
"nu",
"value")))
39 bp::class_<QuadraticCost, bp::bases<CostAbstract>>(
41 "Quadratic cost in both state and control - only for Euclidean spaces.",
43 .def(bp::init<ConstMatrixRef, ConstMatrixRef, ConstMatrixRef,
44 ConstVectorRef, ConstVectorRef>(
45 bp::args(
"self",
"w_x",
"w_u",
"w_cross",
"interp_x",
"interp_u")))
46 .def(bp::init<ConstMatrixRef, ConstMatrixRef, ConstVectorRef,
48 bp::args(
"self",
"w_x",
"w_u",
"interp_x",
"interp_u")))
49 .def(bp::init<ConstMatrixRef, ConstMatrixRef>(
50 "Constructor with just weights (no cross-term).",
51 bp::args(
"self",
"w_x",
"w_u")))
52 .def(bp::init<ConstMatrixRef, ConstMatrixRef, ConstMatrixRef>(
53 "Constructor with just weights (with cross-term).",
54 bp::args(
"self",
"w_x",
"w_u",
"w_cross")))
60 "Whether there is a cross term.")
66 bp::class_<QuadraticCost::Data, bp::bases<CostData>>(
67 "QuadraticCostData",
"Quadratic cost data.", bp::no_init);
80 register_polymorphic_to_python<PolyCost>();
81 bp::class_<PyCostFunction, boost::noncopyable>(
82 "CostAbstract",
"Base class for cost functions.", bp::no_init)
83 .def(bp::init<
const xyz::polymorphic<Manifold> &,
const int>(
84 bp::args(
"self",
"space",
"nu")))
85 .def(
"evaluate", bp::pure_virtual(&CostAbstract::evaluate),
86 bp::args(
"self",
"x",
"u",
"data"),
"Evaluate the cost function.")
87 .def(
"computeGradients",
88 bp::pure_virtual(&CostAbstract::computeGradients),
89 bp::args(
"self",
"x",
"u",
"data"),
90 "Compute the cost function gradients.")
91 .def(
"computeHessians", bp::pure_virtual(&CostAbstract::computeHessians),
92 bp::args(
"self",
"x",
"u",
"data"),
93 "Compute the cost function hessians.")
94 .def_readonly(
"space", &CostAbstract::space)
95 .add_property(
"nx", &CostAbstract::nx)
96 .add_property(
"ndx", &CostAbstract::ndx)
97 .add_property(
"nu", &CostAbstract::nu)
101 bp::register_ptr_to_python<shared_ptr<CostData>>();
102 bp::class_<CostDataWrapper, boost::noncopyable>(
103 "CostData",
"Cost function data struct.", bp::no_init)
104 .def(bp::init<const int, const int>(bp::args(
"self",
"ndx",
"nu")))
105 .def(bp::init<const CostAbstract &>(bp::args(
"self",
"cost")))
106 .def_readwrite(
"value", &CostData::value_)
107 .def_readwrite(
"grad", &CostData::grad_)
108 .def_readwrite(
"hess", &CostData::hess_)
110 "Lx", bp::make_getter(&CostData::Lx_,
111 bp::return_value_policy<bp::return_by_value>()))
113 "Lu", bp::make_getter(&CostData::Lu_,
114 bp::return_value_policy<bp::return_by_value>()))
115 .add_property(
"Lxx", bp::make_getter(
117 bp::return_value_policy<bp::return_by_value>()))
118 .add_property(
"Lxu", bp::make_getter(
120 bp::return_value_policy<bp::return_by_value>()))
121 .add_property(
"Lux", bp::make_getter(
123 bp::return_value_policy<bp::return_by_value>()))
124 .add_property(
"Luu", bp::make_getter(
126 bp::return_value_policy<bp::return_by_value>()));
128 StdVectorPythonVisitor<std::vector<PolyCost>,
true>::expose(
129 "StdVec_CostAbstract",
130 eigenpy::details::overload_base_get_item_for_std_vector<
131 std::vector<PolyCost>>{});
132 StdVectorPythonVisitor<std::vector<shared_ptr<CostData>>,
true>::expose(
CostAbstractTpl< Scalar > CostAbstract
ManifoldAbstractTpl< Scalar > Manifold
CostDataAbstractTpl< Scalar > CostData