diff --git a/franky/__init__.py b/franky/__init__.py index d8be2e80..87d691b7 100644 --- a/franky/__init__.py +++ b/franky/__init__.py @@ -53,6 +53,7 @@ JointPositions, CartesianVelocities, CartesianPose, + BoolFuture, CommandException, ControlException, IncompatibleVersionException, diff --git a/python/python.cpp b/python/python.cpp index 8b411fec..8ddfd3d4 100644 --- a/python/python.cpp +++ b/python/python.cpp @@ -1018,6 +1018,15 @@ PYBIND11_MODULE(_franky, m) { .def_static("forward_kinematics", &Robot::forwardKinematics, "q"_a) .def_static("inverseKinematics", &Robot::inverseKinematics, "target"_a, "q0"_a); + py::class_>(m, "BoolFuture") + .def("wait", [](const std::future &future, std::optional timeout) { + if (timeout.has_value()) + return future.wait_for(std::chrono::duration(timeout.value())) == std::future_status::ready; + future.wait(); + return true; + }, "timeout"_a = std::nullopt) + .def("get", &std::future::get); + py::register_exception(m, "Exception"); py::register_exception(m, "CommandException"); py::register_exception(m, "ControlException");