Skip to content

Commit

Permalink
Python can interupt task planning
Browse files Browse the repository at this point in the history
  • Loading branch information
samraise authored and devraise committed Jun 17, 2024
1 parent 8fa66a6 commit 21499d6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion core/python/pybind11
Submodule pybind11 updated 292 files
3 changes: 2 additions & 1 deletion core/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ add_library(${PROJECT_NAME}
solvers/pipeline_planner.cpp
solvers/multi_planner.cpp
)
target_link_libraries(${PROJECT_NAME} ${catkin_LIBRARIES} fmt::fmt)
find_package(pybind11 REQUIRED)
target_link_libraries(${PROJECT_NAME} ${catkin_LIBRARIES} fmt::fmt pybind11::module)
target_include_directories(${PROJECT_NAME}
PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
Expand Down
7 changes: 7 additions & 0 deletions core/src/task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@

#include <functional>

#include <pybind11/pybind11.h>

namespace {
std::string rosNormalizeName(const std::string& name) {
std::string n;
Expand Down Expand Up @@ -236,6 +238,8 @@ moveit::core::MoveItErrorCode Task::plan(size_t max_solutions) {
auto impl = pimpl();
init();

pybind11::gil_scoped_release release;

// Print state and return success if there are solutions otherwise the input error_code
const auto success_or = [this](const int32_t error_code) -> int32_t {
if (numSolutions() > 0)
Expand All @@ -258,6 +262,9 @@ moveit::core::MoveItErrorCode Task::plan(size_t max_solutions) {
if (impl->introspection_)
impl->introspection_->publishTaskState();
};

pybind11::gil_scoped_acquire acquire;

return success_or(moveit::core::MoveItErrorCode::PLANNING_FAILED);
}

Expand Down

0 comments on commit 21499d6

Please sign in to comment.