Factor out Python property handling

... to allow for reuse in custom Python wrappers
This commit is contained in:
Robert Haschke 2025-08-07 11:11:11 +02:00
parent 0cc398797f
commit 5ec63045e8
3 changed files with 15 additions and 9 deletions

View File

@ -27,6 +27,7 @@ catkin_package(
${PROJECT_NAME}
${PROJECT_NAME}_stages
${PROJECT_NAME}_stage_plugins
${PROJECT_NAME}_python_tools
INCLUDE_DIRS
include
CATKIN_DEPENDS

View File

@ -1,22 +1,26 @@
set(INCLUDES ${PROJECT_SOURCE_DIR}/include/moveit/python/task_constructor)
add_library(${PROJECT_NAME}_python_tools SHARED
${INCLUDES}/properties.h
src/properties.cpp
)
target_link_libraries(${PROJECT_NAME}_python_tools PUBLIC ${PROJECT_NAME} pybind11::pybind11)
# catkin_lint cannot detect target declarations in functions, here in pybind11_add_module
#catkin_lint: ignore undefined_target
# moveit.task_constructor
set(INCLUDES ${PROJECT_SOURCE_DIR}/include/moveit/python/task_constructor)
pybind11_add_module(pymoveit_mtc
${INCLUDES}/properties.h
src/properties.cpp
src/solvers.cpp
src/core.cpp
src/stages.cpp
src/module.cpp
)
target_include_directories(pymoveit_mtc PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>)
target_link_libraries(pymoveit_mtc PUBLIC ${PROJECT_NAME} ${PROJECT_NAME}_stages ${TOOLS_LIB_NAME})
target_link_libraries(pymoveit_mtc PUBLIC ${PROJECT_NAME} ${PROJECT_NAME}_stages ${PROJECT_NAME}_python_tools)
set_target_properties(pymoveit_mtc PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CATKIN_DEVEL_PREFIX}/${CATKIN_GLOBAL_PYTHON_DESTINATION})
# install python libs
# install libs
install(TARGETS ${PROJECT_NAME}_python_tools
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION})
install(TARGETS pymoveit_mtc
LIBRARY DESTINATION ${CATKIN_GLOBAL_PYTHON_DESTINATION}
)
LIBRARY DESTINATION ${CATKIN_GLOBAL_PYTHON_DESTINATION})

View File

@ -155,6 +155,7 @@ bool PropertyConverterBase::insert(const std::type_index& type_index, const std:
return REGISTRY_SINGLETON.insert(type_index, ros_msg_name, to, from);
}
__attribute__((visibility("default"))) // export this symbol as visible in the shared library
void export_properties(py::module& m) {
// clang-format off
py::classh<Property>(m, "Property", "Holds an arbitrarily typed value and a default value")