Skip to content

Commit 06da172

Browse files
Added pybind wrapper for bool futures
1 parent 8bb1f2c commit 06da172

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

franky/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
JointPositions,
5454
CartesianVelocities,
5555
CartesianPose,
56+
BoolFuture,
5657
CommandException,
5758
ControlException,
5859
IncompatibleVersionException,

python/python.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -1018,6 +1018,15 @@ PYBIND11_MODULE(_franky, m) {
10181018
.def_static("forward_kinematics", &Robot::forwardKinematics, "q"_a)
10191019
.def_static("inverseKinematics", &Robot::inverseKinematics, "target"_a, "q0"_a);
10201020

1021+
py::class_<std::future<bool>>(m, "BoolFuture")
1022+
.def("wait", [](const std::future<bool> &future, std::optional<double> timeout) {
1023+
if (timeout.has_value())
1024+
return future.wait_for(std::chrono::duration<double>(timeout.value())) == std::future_status::ready;
1025+
future.wait();
1026+
return true;
1027+
}, "timeout"_a = std::nullopt)
1028+
.def("get", &std::future<bool>::get);
1029+
10211030
py::register_exception<franka::Exception>(m, "Exception");
10221031
py::register_exception<franka::CommandException>(m, "CommandException");
10231032
py::register_exception<franka::ControlException>(m, "ControlException");

0 commit comments

Comments
 (0)