Skip to content

Commit

Permalink
Added pybind wrapper for bool futures
Browse files Browse the repository at this point in the history
  • Loading branch information
TimSchneider42 committed Jun 4, 2024
1 parent 8bb1f2c commit 06da172
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions franky/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
JointPositions,
CartesianVelocities,
CartesianPose,
BoolFuture,
CommandException,
ControlException,
IncompatibleVersionException,
Expand Down
9 changes: 9 additions & 0 deletions python/python.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_<std::future<bool>>(m, "BoolFuture")
.def("wait", [](const std::future<bool> &future, std::optional<double> timeout) {
if (timeout.has_value())
return future.wait_for(std::chrono::duration<double>(timeout.value())) == std::future_status::ready;
future.wait();
return true;
}, "timeout"_a = std::nullopt)
.def("get", &std::future<bool>::get);

py::register_exception<franka::Exception>(m, "Exception");
py::register_exception<franka::CommandException>(m, "CommandException");
py::register_exception<franka::ControlException>(m, "ControlException");
Expand Down

0 comments on commit 06da172

Please sign in to comment.