Merge branch 'python_singleton' of github.com:introlab/rtabmap into gtest

This commit is contained in:
matlabbe
2026-05-26 20:52:31 -07:00
12 changed files with 48 additions and 52 deletions
+12 -4
View File
@@ -21,16 +21,24 @@ class gil_scoped_release;
namespace rtabmap {
/**
* Create a single PythonInterface on main thread at
* global scope before any Python classes.
* Process-wide singleton owning the embedded Python interpreter.
* Call PythonInterface::instance() from the main thread (typically near
* the top of main()) before any Python-using class is constructed.
*/
class RTABMAP_CORE_EXPORT PythonInterface
{
public:
PythonInterface();
virtual ~PythonInterface();
// Pass a caller tag (e.g. class name) so the main-thread assertion
// can report who triggered the first construction.
static PythonInterface & instance(const std::string & caller = "");
PythonInterface(const PythonInterface &) = delete;
PythonInterface & operator=(const PythonInterface &) = delete;
private:
explicit PythonInterface(const std::string & caller);
~PythonInterface();
pybind11::scoped_interpreter* guard_;
pybind11::gil_scoped_release* release_;
};
-6
View File
@@ -50,7 +50,6 @@ class Memory;
class BayesFilter;
class Signature;
class Optimizer;
class PythonInterface;
/**
* @class Rtabmap
@@ -1040,11 +1039,6 @@ private:
Transform _pathTransformToGoal;
int _pathStuckCount;
float _pathStuckDistance;
#ifdef RTABMAP_PYTHON
PythonInterface * _python;
#endif
};
} // namespace rtabmap