Skip to content

Commit 250c871

Browse files
committed
python-nb : Start work on math module
1 parent 534d819 commit 250c871

File tree

4 files changed

+50
-4
lines changed

4 files changed

+50
-4
lines changed

python-nb/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ find_package(Python REQUIRED COMPONENTS Interpreter Development)
22
find_package(nanobind CONFIG REQUIRED)
33

44
set(PYTHON_LIB_NAME_V2 coal_pywrap_v2)
5-
set(coal_pywrap_v2_SOURCES module.cc)
5+
set(coal_pywrap_v2_SOURCES math.cc module.cc)
66

77
nanobind_add_module(${PYTHON_LIB_NAME_V2} NB_STATIC LTO NB_SUPPRESS_WARNINGS ${coal_pywrap_v2_SOURCES})
88
target_link_libraries(

python-nb/fwd.h

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#include <nanobind/nanobind.h>
2+
3+
namespace nb = nanobind;

python-nb/math.cc

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/// Copyright 2025 INRIA
2+
#include "coal/math/transform.h"
3+
4+
#include "fwd.h"
5+
#include <nanobind/eigen/dense.h>
6+
#include <nanobind/operators.h>
7+
8+
using namespace coal;
9+
10+
void exposeMaths(nb::module_ &m) {
11+
nb::module_::import_("nanoeigenpy");
12+
13+
nb::class_<Transform3s>(m, "Transform3s")
14+
.def(nb::init<>())
15+
.def("getQuatRotation", &Transform3s::getQuatRotation,
16+
nb::rv_policy::automatic_reference)
17+
.def("getTranslation", &Transform3s::getTranslation,
18+
nb::rv_policy::automatic_reference)
19+
.def("isIdentity", &Transform3s::isIdentity)
20+
.def("setIdentity", &Transform3s::setIdentity)
21+
22+
.def("setRandom", &Transform3s::setRandom)
23+
.def_static("Random", &Transform3s::Random)
24+
25+
.def(nb::self * nb::self)
26+
.def(nb::self *= nb::self)
27+
.def(nb::self == nb::self)
28+
.def(nb::self != nb::self);
29+
}

python-nb/module.cc

+17-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
/// Copyright 2025 INRIA
2-
#include <nanobind/nanobind.h>
2+
#include "fwd.h"
33
#include "coal/config.hh"
44

5-
namespace nb = nanobind;
65
using namespace nb::literals;
76

87
inline constexpr bool checkVersionAtLeast(int major, int minor, int patch) {
@@ -44,4 +43,19 @@ void exposeVersion(nb::module_ &m) {
4443
"by the input arguments.");
4544
}
4645

47-
NB_MODULE(COAL_PYTHON_LIBNAME, m) { exposeVersion(m); }
46+
void exposeMaths(nb::module_ &m);
47+
48+
void exposeCollisionGeometries(nb::module_ &m);
49+
50+
void exposeGJK(nb::module_ &m);
51+
52+
#ifdef COAL_HAS_OCTOMAP
53+
void exposeOctree(nb::module_ &m);
54+
#endif
55+
56+
void exposeBroadPhase(nb::module_ &m);
57+
58+
NB_MODULE(COAL_PYTHON_LIBNAME, m) {
59+
exposeVersion(m);
60+
exposeMaths(m);
61+
}

0 commit comments

Comments
 (0)