28 using CostKey = CostStack::CostKey;
29 using PolyCost = CostStack::PolyCost;
31 using CostItem = CostStack::CostItem;
32 using CostMap = CostStack::CostMap;
33 eigenpy::StdPairConverter<CostItem>::registration();
34 eigenpy::VariantConverter<CostKey>::registration();
38 bp::class_<CostStack, bp::bases<CostAbstract>>(
39 "CostStack",
"A weighted sum of other cost functions.", bp::no_init)
41 bp::init<
PolyManifold,
const int,
const std::vector<PolyCost> &,
42 const std::vector<Scalar> &>(
43 (
"self"_a,
"space",
"nu",
"components"_a = bp::list(),
44 "weights"_a = bp::list())))
45 .def(bp::init<const PolyCost &>((
"self"_a,
"cost")))
47 .def(bp::init<PolyManifold, int, const CostMap &>(
48 (
"self"_a,
"components"),
49 "Construct the CostStack from a CostMap object."))
50 .def_readonly(
"components", &CostStack::components_,
51 "Components of this cost stack.")
55 +[](CostStack &self,
const CostKey &key) ->
PolyCost & {
56 if (!self.components_.contains(key)) {
57 PyErr_SetString(PyExc_KeyError,
"Key not found.");
58 bp::throw_error_already_set();
60 auto &c = self.components_.at(key);
63 (
"self"_a,
"key"), bp::return_internal_reference<>())
66 +[](CostStack &self,
const PolyCost &cost,
const Scalar weight)
67 ->
PolyCost & {
return self.addCost(cost, weight).first; },
68 bp::return_internal_reference<>(),
69 (
"self"_a,
"cost",
"weight"_a = 1.))
72 +[](CostStack &self, CostKey key,
const PolyCost &cost,
74 return self.addCost(key, cost, weight).first;
76 bp::return_internal_reference<>(),
77 (
"self"_a,
"key",
"cost",
"weight"_a = 1.))
78 .def(
"size", &CostStack::size,
"Get the number of cost components.")
81#if ALIGATOR_EIGENPY_HAS_MAP_SUPPORT
82 eigenpy::GenericMapVisitor<CostMap, true>::expose(
"CostMap");
87 bp::register_ptr_to_python<shared_ptr<CostStackData>>();
89 bp::class_<CostStackData, bp::bases<CostData>>(
90 "CostStackData",
"Data struct for CostStack.", bp::no_init)
91 .def_readonly(
"sub_cost_data", &CostStackData::sub_cost_data);
92#if ALIGATOR_EIGENPY_HAS_MAP_SUPPORT
93 eigenpy::GenericMapVisitor<CostStackData::DataMap, true>::expose(
"CostMap");
CostAbstractTpl< Scalar > CostAbstract
ManifoldAbstractTpl< Scalar > Manifold
CostDataAbstractTpl< Scalar > CostData