enum_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 
7 
8 
9 
10 
11 using namespace std;
12 
13 namespace py = pybind11;
14 
15 PYBIND11_MODULE(enum_py, m_) {
16  m_.doc() = "pybind11 wrapper of enum_py";
17 
18  py::enum_<Color>(m_, "Color", py::arithmetic())
19  .value("Red", Color::Red)
20  .value("Green", Color::Green)
21  .value("Blue", Color::Blue);
22 
23 
24  py::class_<Pet, std::shared_ptr<Pet>> pet(m_, "Pet");
25  pet
26  .def(py::init<const string&, Pet::Kind>(), py::arg("name"), py::arg("type"))
27  .def("setColor",[](Pet* self, const Color& color){ self->setColor(color);}, py::arg("color"))
28  .def("getColor",[](Pet* self){return self->getColor();})
29  .def_readwrite("name", &Pet::name)
30  .def_readwrite("type", &Pet::type);
31 
32  py::enum_<Pet::Kind>(pet, "Kind", py::arithmetic())
33  .value("Dog", Pet::Kind::Dog)
34  .value("Cat", Pet::Kind::Cat);
35 
36  pybind11::module m_gtsam = m_.def_submodule("gtsam", "gtsam submodule");
37  py::enum_<gtsam::VerbosityLM>(m_gtsam, "VerbosityLM", py::arithmetic())
38  .value("SILENT", gtsam::VerbosityLM::SILENT)
39  .value("SUMMARY", gtsam::VerbosityLM::SUMMARY)
40  .value("TERMINATION", gtsam::VerbosityLM::TERMINATION)
41  .value("LAMBDA", gtsam::VerbosityLM::LAMBDA)
42  .value("TRYLAMBDA", gtsam::VerbosityLM::TRYLAMBDA)
43  .value("TRYCONFIG", gtsam::VerbosityLM::TRYCONFIG)
44  .value("DAMPED", gtsam::VerbosityLM::DAMPED)
45  .value("TRYDELTA", gtsam::VerbosityLM::TRYDELTA);
46 
47 
48  py::class_<gtsam::MCU, std::shared_ptr<gtsam::MCU>> mcu(m_gtsam, "MCU");
49  mcu
50  .def(py::init<>());
51 
52  py::enum_<gtsam::MCU::Avengers>(mcu, "Avengers", py::arithmetic())
53  .value("CaptainAmerica", gtsam::MCU::Avengers::CaptainAmerica)
54  .value("IronMan", gtsam::MCU::Avengers::IronMan)
55  .value("Hulk", gtsam::MCU::Avengers::Hulk)
56  .value("Hawkeye", gtsam::MCU::Avengers::Hawkeye)
57  .value("Thor", gtsam::MCU::Avengers::Thor);
58 
59 
60  py::enum_<gtsam::MCU::GotG>(mcu, "GotG", py::arithmetic())
61  .value("Starlord", gtsam::MCU::GotG::Starlord)
62  .value("Gamorra", gtsam::MCU::GotG::Gamorra)
63  .value("Rocket", gtsam::MCU::GotG::Rocket)
64  .value("Drax", gtsam::MCU::GotG::Drax)
65  .value("Groot", gtsam::MCU::GotG::Groot);
66 
67 
68  py::class_<gtsam::Optimizer<gtsam::GaussNewtonParams>, std::shared_ptr<gtsam::Optimizer<gtsam::GaussNewtonParams>>> optimizergaussnewtonparams(m_gtsam, "OptimizerGaussNewtonParams");
69  optimizergaussnewtonparams
70  .def(py::init<const Optimizer<gtsam::GaussNewtonParams>::Verbosity&>(), py::arg("verbosity"))
71  .def("setVerbosity",[](gtsam::Optimizer<gtsam::GaussNewtonParams>* self, const Optimizer<gtsam::GaussNewtonParams>::Verbosity value){ self->setVerbosity(value);}, py::arg("value"))
72  .def("getVerbosity",[](gtsam::Optimizer<gtsam::GaussNewtonParams>* self){return self->getVerbosity();})
73  .def("getVerbosity",[](gtsam::Optimizer<gtsam::GaussNewtonParams>* self){return self->getVerbosity();});
74 
75  py::enum_<gtsam::Optimizer<gtsam::GaussNewtonParams>::Verbosity>(optimizergaussnewtonparams, "Verbosity", py::arithmetic())
76  .value("SILENT", gtsam::Optimizer<gtsam::GaussNewtonParams>::Verbosity::SILENT)
77  .value("SUMMARY", gtsam::Optimizer<gtsam::GaussNewtonParams>::Verbosity::SUMMARY)
78  .value("VERBOSE", gtsam::Optimizer<gtsam::GaussNewtonParams>::Verbosity::VERBOSE);
79 
80 
81 
82 #include "python/specializations.h"
83 
84 }
85 
utilities.h
Contains generic global functions designed particularly for the matlab interface.
gtsam.examples.DogLegOptimizerExample.type
type
Definition: DogLegOptimizerExample.py:111
name
static char name[]
Definition: rgamma.c:72
module
module_ module
Definition: pybind11.h:1367
arg
EIGEN_DEVICE_FUNC const EIGEN_STRONG_INLINE ArgReturnType arg() const
Definition: ArrayCwiseUnaryOps.h:66
init
detail::initimpl::constructor< Args... > init()
Binds an existing constructor taking arguments Args...
Definition: pybind11.h:2006
pybind11.h
module_::def_submodule
module_ def_submodule(const char *name, const char *doc=nullptr)
Definition: pybind11.h:1259
Color
Vector4f Color
Definition: gpuhelper.h:19
std
Definition: BFloat16.h:88
pybind11
Definition: wrap/pybind11/pybind11/__init__.py:1
PYBIND11_MODULE
PYBIND11_MODULE(enum_py, m_)
Definition: enum_pybind.cpp:15
eigen.h
operators.h
stl_bind.h
test_callbacks.value
value
Definition: test_callbacks.py:160


gtsam
Author(s):
autogenerated on Sun Dec 22 2024 04:11:30