Skip to content

Commit

Permalink
std::pair ref not exposed
Browse files Browse the repository at this point in the history
  • Loading branch information
ManifoldFR committed Sep 17, 2024
1 parent d84c65b commit ac60bd1
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions bindings/python/src/modelling/expose-cost-stack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

#include "aligator/modelling/costs/sum-of-costs.hpp"

#include <eigenpy/std-map.hpp>
#include <eigenpy/std-pair.hpp>
#include <eigenpy/variant.hpp>

namespace aligator {
namespace python {
Expand All @@ -21,6 +21,7 @@ void exposeCostStack() {
using CostItem = CostStack::CostItem;
using CostMap = CostStack::CostMap;
eigenpy::StdPairConverter<CostItem>::registration();
eigenpy::VariantConverter<CostKey>::registration();

bp::class_<CostStack, bp::bases<CostAbstract>>(
"CostStack", "A weighted sum of other cost functions.", bp::no_init)
Expand All @@ -33,15 +34,18 @@ void exposeCostStack() {
// "Components of this cost stack.")
.def(
"addCost",
+[](CostStack &self, const PolyCost &cost, const Scalar weight)
-> CostItem & { return self.addCost(cost, weight); },
+[](CostStack &self, const PolyCost &cost, const Scalar weight) {
// return
self.addCost(cost, weight);
},
("self"_a, "cost", "weight"_a = 1.),
bp::return_internal_reference<>())
.def(
"addCost",
+[](CostStack &self, CostKey key, const PolyCost &cost,
const Scalar weight) -> CostItem & {
return self.addCost(key, cost, weight);
const Scalar weight) {
// return
self.addCost(key, cost, weight);
},
("self"_a, "key", "cost", "weight"_a = 1.),
bp::return_internal_reference<>())
Expand Down

0 comments on commit ac60bd1

Please sign in to comment.