RainerKuemmerle / g2o

g2o: A General Framework for Graph Optimization
3.1k stars 1.11k forks source link

RuntimeError: logger with name 'g2o' already exists #732

Closed shrimo closed 1 year ago

shrimo commented 1 year ago

Hello I'm trying to run the example sba_demo.py, the following error occurs:

Performing full BA: Traceback (most recent call last): File "/g2o-pymem/python/examples/sba_demo.py", line 139, in <module> main() File "/home/cds/github/g2o-pymem/python/examples/sba_demo.py", line 120, in main optimizer.optimize(10) RuntimeError: logger with name 'g2o' already exists

https://github.com/RainerKuemmerle/g2o/blob/pymem/python/examples/sba_demo.py#L120

sba_demo2.py - works without errors

Building a framework on Fedora Linux 38 for Python 3.10

cmake -DBUILD_SHARED_LIBS=ON -DG2O_USE_OPENGL=OFF -DG2O_BUILD_EXAMPLES=OFF -DG2O_BUILD_APPS=OFF -DG2O_BUILD_PYTHON=ON -DPYBIND11_INSTALL=ON -DCMAKE_POSITION_INDEPENDENT_CODE=ON ../

I would be very grateful for any advice on this matter.

RainerKuemmerle commented 1 year ago

Thanks. I added a workaround for the logger singleton. The "simple" singleton uses a static variable which is local to each library. Hence, we ended up adding multiple loggers.

shrimo commented 1 year ago

Thanks. I added a workaround for the logger singleton. The "simple" singleton uses a static variable which is local to each library. Hence, we ended up adding multiple loggers.

I rebuilt the framework - everything works. Thank you for your answer and fix code.