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 
Matrix3f m
module_ module
Definition: pybind11.h:1265
module_ def_submodule(const char *name, const char *doc=nullptr)
Definition: pybind11.h:1175
std::string serialize(const T &input)
serializes to a string
tuple make_tuple()
Definition: cast.h:1209
Vector2 Point2
Definition: Point2.h:32
Eigen::MatrixXd Matrix
Definition: base/Matrix.h:39
Definition: BFloat16.h:88
Eigen::VectorXd Vector
Definition: Vector.h:38
detail::initimpl::pickle_factory< GetState, SetState > pickle(GetState &&g, SetState &&s)
Definition: pybind11.h:1909
PYBIND11_MODULE(geometry_py, m_)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const ArgReturnType arg() const
Array< int, Dynamic, 1 > v
void deserialize(const std::string &serialized, T &output)
deserializes from a string
3D Point
BOOST_CLASS_EXPORT(gtsam::noiseModel::Isotropic)
Vector3 Point3
Definition: Point3.h:38
2D Point
Point2 t(10, 10)


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:34:18