Skip to content

Commit 511f83d

Browse files
committed
drop vendored pybind11 and use the stock one
1 parent 335d27a commit 511f83d

1 file changed

Lines changed: 196 additions & 22 deletions

File tree

patch/ros-lyrical-moveit-task-constructor-core.patch

Lines changed: 196 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -237,38 +237,20 @@ index 1c0553c..39bfa92 100644
237237
++called;
238238
return true;
239239
diff --git a/python/bindings/CMakeLists.txt b/python/bindings/CMakeLists.txt
240+
index 26c86ac..22bf5e1 100644
240241
--- a/python/bindings/CMakeLists.txt
241242
+++ b/python/bindings/CMakeLists.txt
242-
@@ -2,8 +2,15 @@
243-
add_library(${PROJECT_NAME}_python_tools SHARED
244-
${INCLUDES}/properties.h
245-
src/properties.cpp
243+
@@ -17,6 +17,10 @@ pybind11_add_module(pymoveit_mtc
246244
)
247-
+# Force our vendored (smart_holder) pybind11 to be found before any pybind11
248-
+# pulled in transitively via py_binding_tools, which links against the plain
249-
+# upstream pybind11 package. Mixing the two copies in one translation unit
250-
+# causes duplicate-definition errors, since smart_holder.h only exists in
251-
+# the vendored fork.
252-
+target_include_directories(${PROJECT_NAME}_python_tools BEFORE PUBLIC
253-
+ ${CMAKE_CURRENT_SOURCE_DIR}/../pybind11/include)
254-
target_link_libraries(${PROJECT_NAME}_python_tools PUBLIC ${PROJECT_NAME}
255-
pybind11::pybind11 py_binding_tools::py_binding_tools)
256-
# Use minimum-size optimization for pybind11 bindings
257-
target_link_libraries(${PROJECT_NAME}_python_tools PUBLIC pybind11::opt_size)
258-
@@ -15,7 +15,13 @@
259-
src/stages.cpp
260-
src/module.cpp
261-
)
262-
+target_include_directories(pymoveit_mtc BEFORE PUBLIC
263-
+ ${CMAKE_CURRENT_SOURCE_DIR}/../pybind11/include)
264245
target_include_directories(pymoveit_mtc PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>)
265246
target_link_libraries(pymoveit_mtc PUBLIC ${PROJECT_NAME} ${PROJECT_NAME}_stages ${PROJECT_NAME}_python_tools)
266247
+# CMake's C++20 module dependency scanner misparses pybind11::module-typed
267248
+# locals in headers pulled in transitively (py_binding_tools) as module
268249
+# control-lines; this target doesn't use C++20 modules, so just disable it.
269250
+set_target_properties(pymoveit_mtc PROPERTIES CXX_SCAN_FOR_MODULES OFF)
270-
251+
271252
# install libs
253+
install(TARGETS ${PROJECT_NAME}_python_tools
272254
diff --git a/python/bindings/src/properties.cpp b/python/bindings/src/properties.cpp
273255
--- a/python/bindings/src/properties.cpp
274256
+++ b/python/bindings/src/properties.cpp
@@ -293,3 +275,195 @@ diff --git a/python/bindings/src/solvers.cpp b/python/bindings/src/solvers.cpp
293275
.property<moveit_msgs::msg::WorkspaceParameters>(
294276
"workspace_parameters",
295277
":moveit_msgs:`WorkspaceParameters`: Specifies workspace box to be used for Cartesian sampling")
278+
diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt
279+
index 181e1a4..fcb7315 100644
280+
--- a/python/CMakeLists.txt
281+
+++ b/python/CMakeLists.txt
282+
@@ -1,28 +1,12 @@
283+
-# We rely on pybind11's smart_holder branch imported pybind11 via git submodule
284+
-
285+
+# Use the pybind11 provided by the environment (with upstream smart_holder support since 3.0),
286+
+# rather than vendoring our own fork, so we share a single pybind11 with py_binding_tools.
287+
find_package(ament_cmake_python REQUIRED)
288+
find_package(Python3 COMPONENTS Interpreter Development)
289+
-# pybind11 must use the ROS python version
290+
-set(PYBIND11_PYTHON_VERSION ${PYTHON_VERSION})
291+
+find_package(pybind11 REQUIRED)
292+
293+
# Use minimum-size optimization for pybind11 bindings
294+
add_compile_options("-Os")
295+
296+
-# configure pybind11 install for use by downstream packages in install space
297+
-set(PYBIND11_INSTALL ON CACHE INTERNAL "Install pybind11")
298+
-set(CMAKE_INSTALL_INCLUDEDIR include/moveit/python)
299+
-set(PYBIND11_CMAKECONFIG_INSTALL_DIR share/${PROJECT_NAME}/cmake
300+
- CACHE INTERNAL "install path for pybind11 cmake files")
301+
-
302+
-# source pybind11 folder, which exposes its targets and installs them
303+
-if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/pybind11/CMakeLists.txt")
304+
- message("Missing content of submodule pybind11: Use 'git clone --recurse-submodule' in future.\n"
305+
- "Checking out content automatically")
306+
- execute_process(COMMAND git submodule init WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
307+
- execute_process(COMMAND git submodule update WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
308+
-endif()
309+
-add_subdirectory(pybind11)
310+
-
311+
# C++ wrapper code
312+
add_subdirectory(bindings)
313+
314+
diff --git a/CMakeLists.txt b/CMakeLists.txt
315+
index 1b8d21a..1d9f5d7 100644
316+
--- a/CMakeLists.txt
317+
+++ b/CMakeLists.txt
318+
@@ -12,6 +12,8 @@ find_package(moveit_core REQUIRED)
319+
find_package(moveit_ros_planning REQUIRED)
320+
find_package(moveit_ros_planning_interface REQUIRED)
321+
find_package(moveit_task_constructor_msgs REQUIRED)
322+
+find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
323+
+find_package(pybind11 REQUIRED)
324+
find_package(py_binding_tools REQUIRED)
325+
find_package(rclcpp REQUIRED)
326+
find_package(rviz_marker_tools REQUIRED)
327+
diff --git a/include/moveit/python/task_constructor/properties.h b/include/moveit/python/task_constructor/properties.h
328+
index 46c0e97..70bf30e 100644
329+
--- a/include/moveit/python/task_constructor/properties.h
330+
+++ b/include/moveit/python/task_constructor/properties.h
331+
@@ -1,14 +1,10 @@
332+
#pragma once
333+
334+
-#include <pybind11/smart_holder.h>
335+
#include <py_binding_tools/ros_msg_typecasters.h>
336+
#include <moveit/task_constructor/properties.h>
337+
#include <boost/any.hpp>
338+
#include <typeindex>
339+
340+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(moveit::task_constructor::Property)
341+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(moveit::task_constructor::PropertyMap)
342+
-
343+
namespace moveit {
344+
namespace python {
345+
346+
diff --git a/python/bindings/src/core.h b/python/bindings/src/core.h
347+
index 7ab1437..b9bdc2c 100644
348+
--- a/python/bindings/src/core.h
349+
+++ b/python/bindings/src/core.h
350+
@@ -34,12 +34,12 @@
351+
352+
#pragma once
353+
354+
+#include <pybind11/pybind11.h>
355+
#include <moveit/task_constructor/stage.h>
356+
#include <moveit/task_constructor/container.h>
357+
#include <moveit/task_constructor/cost_queue.h>
358+
#include <moveit/task_constructor/cost_terms.h>
359+
#include <moveit/utils/moveit_error_code.hpp>
360+
-#include <pybind11/smart_holder.h>
361+
362+
/** Trampoline classes to allow inheritance in Python (overriding virtual functions) */
363+
364+
@@ -109,36 +109,3 @@ public:
365+
} // namespace task_constructor
366+
} // namespace moveit
367+
368+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(moveit::task_constructor::solvers::PlannerInterface)
369+
-
370+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(moveit::task_constructor::SolutionBase)
371+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(moveit::task_constructor::SubTrajectory)
372+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(ordered<moveit::task_constructor::SolutionBaseConstPtr>)
373+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(moveit::task_constructor::InterfaceState)
374+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(moveit::core::MoveItErrorCode)
375+
-
376+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(moveit::task_constructor::CostTerm)
377+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(moveit::task_constructor::TrajectoryCostTerm)
378+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(moveit::task_constructor::cost::PathLength)
379+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(moveit::task_constructor::cost::DistanceToReference)
380+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(moveit::task_constructor::cost::TrajectoryDuration)
381+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(moveit::task_constructor::cost::LinkMotion)
382+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(moveit::task_constructor::cost::LinkRotation)
383+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(moveit::task_constructor::cost::Clearance)
384+
-
385+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(moveit::task_constructor::Stage)
386+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(moveit::task_constructor::PropagatingEitherWay)
387+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(moveit::task_constructor::PropagatingForward)
388+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(moveit::task_constructor::PropagatingBackward)
389+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(moveit::task_constructor::Generator)
390+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(moveit::task_constructor::MonitoringGenerator)
391+
-
392+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(moveit::task_constructor::ContainerBase)
393+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(moveit::task_constructor::SerialContainer)
394+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(moveit::task_constructor::ParallelContainerBase)
395+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(moveit::task_constructor::Alternatives)
396+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(moveit::task_constructor::Fallbacks)
397+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(moveit::task_constructor::Merger)
398+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(moveit::task_constructor::WrapperBase)
399+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(moveit::task_constructor::Task)
400+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(moveit::task_constructor::Introspection)
401+
diff --git a/python/bindings/src/module.cpp b/python/bindings/src/module.cpp
402+
index a797711..cd66917 100644
403+
--- a/python/bindings/src/module.cpp
404+
+++ b/python/bindings/src/module.cpp
405+
@@ -32,7 +32,7 @@
406+
* POSSIBILITY OF SUCH DAMAGE.
407+
*********************************************************************/
408+
409+
-#include <pybind11/smart_holder.h>
410+
+#include <pybind11/pybind11.h>
411+
412+
namespace moveit {
413+
namespace python {
414+
diff --git a/python/bindings/src/solvers.cpp b/python/bindings/src/solvers.cpp
415+
index 7c6a12f..eebfa2e 100644
416+
--- a/python/bindings/src/solvers.cpp
417+
+++ b/python/bindings/src/solvers.cpp
418+
@@ -46,12 +46,6 @@ using namespace py::literals;
419+
using namespace moveit::task_constructor;
420+
using namespace moveit::task_constructor::solvers;
421+
422+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(PlannerInterface)
423+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(PipelinePlanner)
424+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(JointInterpolationPlanner)
425+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(CartesianPath)
426+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(MultiPlanner)
427+
-
428+
namespace moveit {
429+
namespace python {
430+
431+
diff --git a/python/bindings/src/stages.cpp b/python/bindings/src/stages.cpp
432+
index 1dead16..f51308f 100644
433+
--- a/python/bindings/src/stages.cpp
434+
+++ b/python/bindings/src/stages.cpp
435+
@@ -48,26 +48,6 @@ using namespace py::literals;
436+
using namespace moveit::task_constructor;
437+
using namespace moveit::task_constructor::stages;
438+
439+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(ModifyPlanningScene)
440+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(CurrentState)
441+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(FixedState)
442+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(ComputeIK)
443+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(MoveTo)
444+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(MoveRelative)
445+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(Connect)
446+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(FixCollisionObjects)
447+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(GenerateGraspPose)
448+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(GeneratePlacePose)
449+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(GenerateRandomPose)
450+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(GeneratePose)
451+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(Pick)
452+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(Place)
453+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(SimpleGraspBase)
454+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(SimpleGrasp)
455+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(SimpleUnGrasp)
456+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(PassThrough)
457+
-PYBIND11_SMART_HOLDER_TYPE_CASTERS(LimitSolutions)
458+
-
459+
namespace moveit {
460+
namespace python {
461+
462+
@@ -369,7 +349,6 @@ void export_stages(pybind11::module& m) {
463+
)")
464+
.def(py::init<const std::string&>(), "name"_a = std::string("Generate Place Pose"));
465+
466+
-
467+
properties::class_<GenerateGraspPose, MonitoringGenerator>(m, "GenerateGraspPose", R"(
468+
GenerateGraspPose stage derives from monitoring generator and can
469+
be used to generate poses for grasping. Set the desired attributes

0 commit comments

Comments
 (0)