stella-cv / stella_vslam_ros

ROS package for stella_vslam
https://stella-cv.rtfd.io/en/latest/
Other
117 stars 77 forks source link

std::bad_alloc error when running ros1 node #164

Closed saratrajput closed 12 months ago

saratrajput commented 12 months ago

Describe the bug

When I run the following command:

rosrun stella_vslam_ros run_slam -v /home/sp/lib/stella_vslam_examples/build/o_vocab.fbow -c /home/sp/lib/stella_vslam/example/aist/equirectangular.yaml --map-db-out map.msg

I get the following error:

[*** LOG ERROR #0001 ***] [2023-09-14 18:57:15] [] {std::bad_alloc}
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc
*** Aborted at 1694685435 (unix time) try "date -d @1694685435" if you are using GNU date ***
PC: @     0x7ff3582c400b gsignal
*** SIGABRT (@0x3e90025845d) received by PID 2458717 (TID 0x7ff345ed3a00) from PID 2458717; stack trace: ***
    @     0x7ff358d50631 (unknown)
    @     0x7ff3591b2420 (unknown)
    @     0x7ff3582c400b gsignal
    @     0x7ff3582a3859 abort
    @     0x7ff35852e8d1 (unknown)
    @     0x7ff35853a37c (unknown)
    @     0x7ff35853a3e7 std::terminate()
    @     0x7ff35853a699 __cxa_throw
    @     0x7ff35852e4e2 (unknown)
    @     0x7ff3588cf590 fmt::v6::basic_memory_buffer<>::grow()
    @     0x563d3e8717df fmt::v5::internal::basic_buffer<>::append<>()
    @     0x563d3e8a0263 spdlog::details::full_formatter::format()
    @     0x563d3e87678e spdlog::pattern_formatter::format()
    @     0x7ff354803a80 spdlog::sinks::ansicolor_sink<>::log()
    @     0x563d3e874fbc spdlog::logger::sink_it_()
    @     0x7ff3547d39fa spdlog::logger::log_it_()
    @     0x7ff3588e7278 stella_vslam::system::print_info()
    @     0x7ff3588eae0e stella_vslam::system::system()
    @     0x563d3e86f065 main
    @     0x7ff3582a5083 __libc_start_main
    @     0x563d3e87154e _start
Aborted (core dumped)

To Reproduce

I followed the installation steps at: https://stella-cv.readthedocs.io/en/latest/ros_package.html#installation

config file:

# Equirectangular model for RICOH THETA S

Camera:
  name: "RICOH THETA S 960"
  setup: "monocular"
  model: "equirectangular"

  fps: 30.0
  cols: 1920
  rows: 960

  color_order: "RGB"

Preprocessing:
  min_size: 800
  mask_rectangles:
    - [0.0, 1.0, 0.0, 0.1]
    - [0.0, 1.0, 0.84, 1.0]
    - [0.0, 0.2, 0.7, 1.0]
    - [0.8, 1.0, 0.7, 1.0]

Feature:
  name: "default ORB feature extraction setting"
  scale_factor: 1.2
  num_levels: 8
  ini_fast_threshold: 20
  min_fast_threshold: 7

Mapping:
  backend: "g2o"
  baseline_dist_thr_ratio: 0.02
  redundant_obs_ratio_thr: 0.95
  num_covisibilities_for_landmark_generation: 20
  num_covisibilities_for_landmark_fusion: 20

Tracking:
  backend: "g2o"

LoopDetector:
  backend: "g2o"
  enabled: true
  reject_by_graph_distance: true
  min_distance_on_graph: 50

System:
  map_format: "msgpack"

Expected behavior

I expected the ROS node to work the same as the stella_vslam example. I followed the installation steps at https://stella-cv.readthedocs.io/en/latest/installation.html and it works fine.

Screenshots or videos

NA

Environment

Additional context

Output of catkin_make

catkin_make -j32 -DUSE_STACK_TRACE_LOGGER=ON
Base path: /home/sp/catkin_ws
Source space: /home/sp/catkin_ws/src
Build space: /home/sp/catkin_ws/build
Devel space: /home/sp/catkin_ws/devel
Install space: /home/sp/catkin_ws/install
####
#### Running command: "cmake /home/sp/catkin_ws/src -DUSE_STACK_TRACE_LOGGER=ON -DCATKIN_DEVEL_PREFIX=/home/sp/catkin_ws/devel -DCMAKE_INSTALL_PREFIX=/home/sp/catkin_ws/install -G Unix Makefiles" in "/home/sp/catkin_ws/build"
####
-- The C compiler identification is GNU 9.4.0
-- The CXX compiler identification is GNU 9.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Using CATKIN_DEVEL_PREFIX: /home/sp/catkin_ws/devel
-- Using CMAKE_PREFIX_PATH: /home/sp/catkin_ws/devel;/opt/ros/noetic
-- This workspace overlays: /home/sp/catkin_ws/devel;/opt/ros/noetic
-- Found PythonInterp: /usr/bin/python3 (found suitable version "3.8.10", minimum required is "3") 
-- Using PYTHON_EXECUTABLE: /usr/bin/python3
-- Using Debian Python package layout
-- Found PY_em: /usr/lib/python3/dist-packages/em.py  
-- Using empy: /usr/lib/python3/dist-packages/em.py
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /home/sp/catkin_ws/build/test_results
-- Forcing gtest/gmock from source, though one was otherwise available.
-- Found gtest sources under '/usr/src/googletest': gtests will be built
-- Found gmock sources under '/usr/src/googletest': gmock will be built
CMake Deprecation Warning at /usr/src/googletest/CMakeLists.txt:4 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

CMake Deprecation Warning at /usr/src/googletest/googlemock/CMakeLists.txt:45 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

CMake Deprecation Warning at /usr/src/googletest/googletest/CMakeLists.txt:56 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

-- Found PythonInterp: /usr/bin/python3 (found version "3.8.10") 
-- Found Threads: TRUE  
-- Using Python nosetests: /usr/bin/nosetests3
-- catkin 0.8.10
-- BUILD_SHARED_LIBS is on
-- BUILD_SHARED_LIBS is on
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- ~~  traversing 1 packages in topological order:
-- ~~  - stella_vslam_ros
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- +++ processing catkin package: 'stella_vslam_ros'
-- ==> add_subdirectory(stella_vslam_ros)
CMake Deprecation Warning at stella_vslam_ros/CMakeLists.txt:8 (cmake_policy):
  The OLD behavior for policy CMP0074 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.

-- Build type: Release
-- Address/Memory sanitizer: DISABLED
-- Stack trace logger: ENABLED
-- No preference for use of exported glog CMake configuration set, and no hints for include/library directories provided. Defaulting to preferring an installed/exported glog CMake configuration if available.
-- Failed to find installed glog CMake configuration, searching for glog build directories exported with CMake.
-- Failed to find an installed/exported CMake configuration for glog, will perform search for installed glog components.
-- Found Glog: /usr/include  
-- Google Perftools: DISABLED
-- Architecture-aware optimization (-march=native): DISABLED
-- Performing Test COMPILER_SUPPORTS_CXX17
-- Performing Test COMPILER_SUPPORTS_CXX17 - Success
-- Performing Test COMPILER_SUPPORTS_CXX14
-- Performing Test COMPILER_SUPPORTS_CXX14 - Success
-- Performing Test COMPILER_SUPPORTS_CXX11
-- Performing Test COMPILER_SUPPORTS_CXX11 - Success
-- Performing Test COMPILER_SUPPORTS_CXX0X
-- Performing Test COMPILER_SUPPORTS_CXX0X - Success
-- C++11 support: OK (-std=c++17)
-- Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy
-- Found OpenMP_C: -fopenmp (found version "4.5") 
-- Found OpenMP_CXX: -fopenmp (found version "4.5") 
-- Found OpenMP: TRUE (found version "4.5")  
-- Found OpenCV: /usr/local (found version "4.5.5") 
CMake Warning (dev) at /home/sp/.local/lib/python3.8/site-packages/cmake/data/share/cmake-3.26/Modules/FindOpenGL.cmake:315 (message):
  Policy CMP0072 is not set: FindOpenGL prefers GLVND by default when
  available.  Run "cmake --help-policy CMP0072" for policy details.  Use the
  cmake_policy command to set the policy and suppress this warning.

  FindOpenGL found both a legacy GL library:

    OPENGL_gl_LIBRARY: /usr/lib/x86_64-linux-gnu/libGL.so

  and GLVND libraries for OpenGL and GLX:

    OPENGL_opengl_LIBRARY: /usr/lib/x86_64-linux-gnu/libOpenGL.so
    OPENGL_glx_LIBRARY: /usr/lib/x86_64-linux-gnu/libGLX.so

  OpenGL_GL_PREFERENCE has not been set to "GLVND" or "LEGACY", so for
  compatibility with CMake 3.10 and below the legacy GL library will be used.
Call Stack (most recent call first):
  /home/sp/.local/lib/python3.8/site-packages/cmake/data/share/cmake-3.26/Modules/CMakeFindDependencyMacro.cmake:76 (find_package)
  /opt/ros/noetic/lib/cmake/g2o/g2oConfig.cmake:4 (find_dependency)
  /home/sp/.local/lib/python3.8/site-packages/cmake/data/share/cmake-3.26/Modules/CMakeFindDependencyMacro.cmake:76 (find_package)
  /usr/local/lib/cmake/stella_vslam/stella_vslamConfig.cmake:7 (find_dependency)
  stella_vslam_ros/CMakeLists.txt:135 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Found OpenGL: /usr/lib/x86_64-linux-gnu/libOpenGL.so   
-- Found OpenCV: /home/sp/opencv/build (found suitable version "3.4.4", minimum required is "3.0") 
-- Use OpenCV 3.4.4
-- Viewer for examples: PangolinViewer
-- Viewer for examples: SocketPublisher
-- Viewer for examples: pangolin viewer
-- Viewer for examples: socket publisher
-- Configuring done (3.8s)
-- Generating done (0.0s)
-- Build files have been written to: /home/sp/catkin_ws/build
####
#### Running command: "make -j32" in "/home/sp/catkin_ws/build"
####
[  0%] Built target tf_generate_messages_py
[  0%] Built target roscpp_generate_messages_cpp
[  0%] Built target roscpp_generate_messages_eus
[  0%] Built target roscpp_generate_messages_lisp
[  0%] Built target roscpp_generate_messages_nodejs
[  0%] Built target roscpp_generate_messages_py
[  0%] Built target rosgraph_msgs_generate_messages_cpp
[  0%] Built target rosgraph_msgs_generate_messages_eus
[  0%] Built target rosgraph_msgs_generate_messages_nodejs
[  0%] Built target rosgraph_msgs_generate_messages_lisp
[  0%] Built target rosgraph_msgs_generate_messages_py
[  0%] Built target std_msgs_generate_messages_cpp
[  0%] Built target std_msgs_generate_messages_eus
[  0%] Built target std_msgs_generate_messages_lisp
[  0%] Built target std_msgs_generate_messages_nodejs
[  0%] Built target std_msgs_generate_messages_py
[  0%] Built target sensor_msgs_generate_messages_cpp
[  0%] Built target sensor_msgs_generate_messages_eus
[  0%] Built target sensor_msgs_generate_messages_lisp
[  0%] Built target sensor_msgs_generate_messages_nodejs
[  0%] Built target sensor_msgs_generate_messages_py
[  0%] Built target geometry_msgs_generate_messages_cpp
[  0%] Built target geometry_msgs_generate_messages_eus
[  0%] Built target geometry_msgs_generate_messages_lisp
[  0%] Built target geometry_msgs_generate_messages_nodejs
[  0%] Built target nav_msgs_generate_messages_cpp
[  0%] Built target geometry_msgs_generate_messages_py
[  0%] Built target nav_msgs_generate_messages_eus
[  0%] Built target nav_msgs_generate_messages_lisp
[  0%] Built target nav_msgs_generate_messages_nodejs
[  0%] Built target nav_msgs_generate_messages_py
[  0%] Built target actionlib_msgs_generate_messages_cpp
[  0%] Built target actionlib_msgs_generate_messages_nodejs
[  0%] Built target actionlib_msgs_generate_messages_eus
[  0%] Built target actionlib_msgs_generate_messages_py
[  0%] Built target actionlib_msgs_generate_messages_lisp
[  0%] Built target tf2_msgs_generate_messages_cpp
[  0%] Built target tf2_msgs_generate_messages_eus
[  0%] Built target tf2_msgs_generate_messages_py
[  0%] Built target tf2_msgs_generate_messages_nodejs
[  0%] Built target tf2_msgs_generate_messages_lisp
[  0%] Built target actionlib_generate_messages_cpp
[  0%] Built target actionlib_generate_messages_eus
[  0%] Built target actionlib_generate_messages_lisp
[  0%] Built target actionlib_generate_messages_nodejs
[  0%] Built target actionlib_generate_messages_py
[  0%] Built target pcl_ros_gencfg
[  0%] Built target dynamic_reconfigure_generate_messages_eus
[  0%] Built target dynamic_reconfigure_generate_messages_cpp
[  0%] Built target dynamic_reconfigure_generate_messages_lisp
[  0%] Built target dynamic_reconfigure_generate_messages_nodejs
[  0%] Built target dynamic_reconfigure_generate_messages_py
[  0%] Built target dynamic_reconfigure_gencfg
[  0%] Built target nodelet_generate_messages_cpp
[  0%] Built target nodelet_generate_messages_eus
[  0%] Built target nodelet_generate_messages_lisp
[  0%] Built target nodelet_generate_messages_nodejs
[  0%] Built target nodelet_generate_messages_py
[  0%] Built target bond_generate_messages_nodejs
[  0%] Built target bond_generate_messages_lisp
[  0%] Built target bond_generate_messages_cpp
[  0%] Built target bond_generate_messages_eus
[  0%] Built target bond_generate_messages_py
[  0%] Built target nodelet_topic_tools_gencfg
[  0%] Built target pcl_msgs_generate_messages_eus
[  0%] Built target pcl_msgs_generate_messages_lisp
[  0%] Built target std_srvs_generate_messages_cpp
[  0%] Built target pcl_msgs_generate_messages_nodejs
[  0%] Built target pcl_msgs_generate_messages_py
[  0%] Built target pcl_msgs_generate_messages_cpp
[  0%] Built target std_srvs_generate_messages_eus
[  0%] Built target std_srvs_generate_messages_lisp
[  0%] Built target std_srvs_generate_messages_nodejs
[  0%] Built target std_srvs_generate_messages_py
[  0%] Built target topic_tools_generate_messages_eus
[  0%] Built target topic_tools_generate_messages_cpp
[  0%] Built target topic_tools_generate_messages_lisp
[  0%] Built target topic_tools_generate_messages_nodejs
[  0%] Built target topic_tools_generate_messages_py
[  0%] Built target tf_generate_messages_eus
[  0%] Built target tf_generate_messages_lisp
[  0%] Built target tf_generate_messages_cpp
[  0%] Built target tf_generate_messages_nodejs
[ 33%] Building CXX object stella_vslam_ros/src/CMakeFiles/run_slam.dir/stella_vslam_ros.cc.o
[ 66%] Building CXX object stella_vslam_ros/src/CMakeFiles/run_slam.dir/run_slam.cc.o
[100%] Linking CXX executable /home/sp/catkin_ws/devel/lib/stella_vslam_ros/run_slam
/usr/bin/ld: warning: libopencv_core.so.405, needed by /usr/local/lib/libpangolin_viewer.so, may conflict with libopencv_core.so.4.2
/usr/bin/ld: warning: libopencv_imgcodecs.so.405, needed by /usr/local/lib/libsocket_publisher.so, may conflict with libopencv_imgcodecs.so.4.2
[100%] Built target run_slam
ymd-stella commented 12 months ago

The installation procedure seems to be wrong, please reinstall the OS or use docker.

naiveHobo commented 12 months ago

I'm having the same exact issue. The installation was followed exactly as mentioned in the documentation.

saratrajput commented 12 months ago

@naiveHobo For me, the issue is caused due to multiple OpenCV installations. I haven't been able to solve the local installation problem, but the docker method works as suggested.

ymd-stella commented 12 months ago

@naiveHobo Is spdlog installed on your system? I have updated ros branch to work even if spdlog is installed on your system.

naiveHobo commented 12 months ago

@ymd-stella that was the issue! Thanks for the help!