Skip to content

Commit d2c5150

Browse files
committed
Python API: Allow passing a task's introspection object to SolutionBase::toMsg()
which is a prerequisite for correct filling of IDs.
1 parent a924b56 commit d2c5150

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

core/python/bindings/src/core.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ void export_core(pybind11::module& m) {
9595
}
9696
});
9797

98+
py::classh<Introspection>(m, "Introspection", "Introspection class");
99+
98100
py::classh<SolutionBase>(m, "Solution", "Abstract base class for solutions of a stage")
99101
.def_property("cost", &SolutionBase::cost, &SolutionBase::setCost, "float: Cost associated with the solution")
100102
.def_property("comment", &SolutionBase::comment, &SolutionBase::setComment,
@@ -109,12 +111,12 @@ void export_core(pybind11::module& m) {
109111
":visualization_msgs:`Marker`: Markers to visualize important aspects of the trajectory (read-only)")
110112
.def(
111113
"toMsg",
112-
[](const SolutionBase& self) {
114+
[](const SolutionBase& self, moveit::task_constructor::Introspection* introspection) {
113115
moveit_task_constructor_msgs::Solution msg;
114-
self.toMsg(msg);
116+
self.toMsg(msg, introspection);
115117
return msg;
116118
},
117-
"Convert to the ROS message ``Solution``");
119+
"Convert to the ROS message ``Solution``", py::arg("introspection") = nullptr);
118120

119121
py::classh<SubTrajectory, SolutionBase>(m, "SubTrajectory",
120122
"Solution trajectory connecting two InterfaceStates of a stage")
@@ -462,6 +464,8 @@ void export_core(pybind11::module& m) {
462464
.def(
463465
"setCostTerm", [](Task& self, const LambdaCostTerm::SubTrajectoryShortSignature& f) { self.setCostTerm(f); },
464466
"Specify a function to calculate trajectory costs")
467+
.def("introspection", &Task::introspection, py::return_value_policy::reference_internal,
468+
"Access introspection object")
465469
.def("reset", &Task::reset, "Reset task (and all its stages)")
466470
.def("init", py::overload_cast<>(&Task::init), "Initialize the task (and all its stages)")
467471
.def("plan", &Task::plan, "max_solutions"_a = 0, R"(

core/python/bindings/src/core.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,4 @@ PYBIND11_SMART_HOLDER_TYPE_CASTERS(moveit::task_constructor::Fallbacks)
140140
PYBIND11_SMART_HOLDER_TYPE_CASTERS(moveit::task_constructor::Merger)
141141
PYBIND11_SMART_HOLDER_TYPE_CASTERS(moveit::task_constructor::WrapperBase)
142142
PYBIND11_SMART_HOLDER_TYPE_CASTERS(moveit::task_constructor::Task)
143+
PYBIND11_SMART_HOLDER_TYPE_CASTERS(moveit::task_constructor::Introspection)

0 commit comments

Comments
 (0)