geometry_pybind.cpp
Go to the documentation of this file.
1 #include <pybind11/eigen.h>
2 #include <pybind11/stl_bind.h>
3 #include <pybind11/pybind11.h>
4 #include <pybind11/operators.h>
5 #include "gtsam/nonlinear/utilities.h" // for RedirectCout.
6 
9 #include <boost/serialization/export.hpp>
10 
13 
14 
15 using namespace std;
16 
17 namespace py = pybind11;
18 
19 PYBIND11_MODULE(geometry_py, m_) {
20  m_.doc() = "pybind11 wrapper of geometry_py";
21 
22  pybind11::module m_gtsam = m_.def_submodule("gtsam", "gtsam submodule");
23 
24  py::class_<gtsam::Point2, std::shared_ptr<gtsam::Point2>>(m_gtsam, "Point2")
25  .def(py::init<>())
26  .def(py::init<double, double>(), py::arg("x"), py::arg("y"))
27  .def("x",[](gtsam::Point2* self){return self->x();})
28  .def("y",[](gtsam::Point2* self){return self->y();})
29  .def("dim",[](gtsam::Point2* self){return self->dim();})
30  .def("returnChar",[](gtsam::Point2* self){return self->returnChar();})
31  .def("argChar",[](gtsam::Point2* self, char a){ self->argChar(a);}, py::arg("a"))
32  .def("argChar",[](gtsam::Point2* self, std::shared_ptr<char> a){ self->argChar(a);}, py::arg("a"))
33  .def("argChar",[](gtsam::Point2* self, char& a){ self->argChar(a);}, py::arg("a"))
34  .def("argChar",[](gtsam::Point2* self, char* a){ self->argChar(a);}, py::arg("a"))
35  .def("argChar",[](gtsam::Point2* self, const std::shared_ptr<char> a){ self->argChar(a);}, py::arg("a"))
36  .def("argChar",[](gtsam::Point2* self, const char& a){ self->argChar(a);}, py::arg("a"))
37  .def("argChar",[](gtsam::Point2* self, const char* a){ self->argChar(a);}, py::arg("a"))
38  .def("argUChar",[](gtsam::Point2* self, unsigned char a){ self->argUChar(a);}, py::arg("a"))
39  .def("eigenArguments",[](gtsam::Point2* self, const gtsam::Vector& v, const gtsam::Matrix& m){ self->eigenArguments(v, m);}, py::arg("v"), py::arg("m"))
40  .def("vectorConfusion",[](gtsam::Point2* self){return self->vectorConfusion();})
41  .def("serialize", [](gtsam::Point2* self){ return gtsam::serialize(*self); })
42  .def("deserialize", [](gtsam::Point2* self, string serialized){ gtsam::deserialize(serialized, *self); }, py::arg("serialized"))
43  .def(py::pickle(
44  [](const gtsam::Point2 &a){ /* __getstate__: Returns a string that encodes the state of the object */ return py::make_tuple(gtsam::serialize(a)); },
45  [](py::tuple t){ /* __setstate__ */ gtsam::Point2 obj; gtsam::deserialize(t[0].cast<std::string>(), obj); return obj; }));
46 
47  py::class_<gtsam::Point3, std::shared_ptr<gtsam::Point3>>(m_gtsam, "Point3")
48  .def(py::init<double, double, double>(), py::arg("x"), py::arg("y"), py::arg("z"))
49  .def("norm",[](gtsam::Point3* self){return self->norm();})
50  .def("serialize", [](gtsam::Point3* self){ return gtsam::serialize(*self); })
51  .def("deserialize", [](gtsam::Point3* self, string serialized){ gtsam::deserialize(serialized, *self); }, py::arg("serialized"))
52  .def(py::pickle(
53  [](const gtsam::Point3 &a){ /* __getstate__: Returns a string that encodes the state of the object */ return py::make_tuple(gtsam::serialize(a)); },
54  [](py::tuple t){ /* __setstate__ */ gtsam::Point3 obj; gtsam::deserialize(t[0].cast<std::string>(), obj); return obj; }))
55  .def_static("staticFunction",[](){return gtsam::Point3::staticFunction();})
56  .def_static("StaticFunctionRet",[](double z){return gtsam::Point3::StaticFunctionRet(z);}, py::arg("z"));
57 
58 
59 #include "python/specializations.h"
60 
61 }
62 
utilities.h
Contains generic global functions designed particularly for the matlab interface.
BOOST_CLASS_EXPORT
BOOST_CLASS_EXPORT(gtsam::noiseModel::Isotropic)
gtsam::Matrix
Eigen::MatrixXd Matrix
Definition: base/Matrix.h:39
Point3.h
3D Point
gtsam::Vector
Eigen::VectorXd Vector
Definition: Vector.h:38
Point2.h
2D Point
make_tuple
tuple make_tuple()
Definition: cast.h:1248
module
module_ module
Definition: pybind11.h:1282
pickle
detail::initimpl::pickle_factory< GetState, SetState > pickle(GetState &&g, SetState &&s)
Definition: pybind11.h:1939
pybind_wrapper_test_script.z
z
Definition: pybind_wrapper_test_script.py:61
m
Matrix3f m
Definition: AngleAxis_mimic_euler.cpp:1
gtsam::Point2
Vector2 Point2
Definition: Point2.h:32
arg
EIGEN_DEVICE_FUNC const EIGEN_STRONG_INLINE ArgReturnType arg() const
Definition: ArrayCwiseUnaryOps.h:66
pybind11.h
module_::def_submodule
module_ def_submodule(const char *name, const char *doc=nullptr)
Definition: pybind11.h:1192
a
ArrayXXi a
Definition: Array_initializer_list_23_cxx11.cpp:1
std
Definition: BFloat16.h:88
v
Array< int, Dynamic, 1 > v
Definition: Array_initializer_list_vector_cxx11.cpp:1
gtsam::Point3
Vector3 Point3
Definition: Point3.h:38
pybind11
Definition: wrap/pybind11/pybind11/__init__.py:1
eigen.h
align_3::t
Point2 t(10, 10)
operators.h
PYBIND11_MODULE
PYBIND11_MODULE(geometry_py, m_)
Definition: geometry_pybind.cpp:19
stl_bind.h


gtsam
Author(s):
autogenerated on Mon Jul 1 2024 03:01:21