Skip to content

Commit 0fa3383

Browse files
committed
pybind mrpt_core: fix Clock wrapper
1 parent f271730 commit 0fa3383

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

modules/mrpt_core/python_bindings/mrpt_core_py.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
*/
1414

1515
// pybind11
16+
#include <pybind11/chrono.h>
17+
#include <pybind11/functional.h>
1618
#include <pybind11/pybind11.h>
19+
#include <pybind11/stl.h>
1720

1821
// MRPT headers
1922
#include <mrpt/core/Clock.h>
@@ -28,9 +31,7 @@
2831
#include <mrpt/core/reverse_bytes.h>
2932

3033
#include <cstdint>
31-
#include <future>
3234
#include <string>
33-
#include <thread>
3435

3536
namespace py = pybind11;
3637

@@ -86,10 +87,16 @@ PYBIND11_MODULE(mrpt_core_py, m)
8687
// ------------------ Clock ------------------
8788
py::class_<mrpt::Clock>(m, "Clock")
8889
.def_static(
89-
"now", []() { return mrpt::Clock::nowDouble(); }, "Current time in seconds (double)")
90+
"nowDouble", []() { return mrpt::Clock::nowDouble(); },
91+
"Current time in seconds (double)")
9092
.def_static(
91-
"now_time_point", []() { return mrpt::Clock::now(); },
92-
"Current time as std::chrono::time_point");
93+
"now", []() { return mrpt::Clock::now(); }, "Current time as mrpt::Clock::time_point")
94+
.def_static(
95+
"toDouble", [](const mrpt::Clock::time_point& tp) { return mrpt::Clock::toDouble(tp); },
96+
py::arg("time_point"), "Convert mrpt::Clock::time_point to double seconds")
97+
.def_static(
98+
"fromDouble", [](double t) { return mrpt::Clock::fromDouble(t); }, py::arg("seconds"),
99+
"Convert double seconds to mrpt::Clock::time_point");
93100

94101
// ------------------ WorkerThreadsPool ------------------
95102
py::class_<mrpt::WorkerThreadsPool>(m, "WorkerThreadsPool")

0 commit comments

Comments
 (0)