EventAccumulator编译运行调试记录

本文最后更新于 2024年2月20日 上午

本文主要分享了自己在编译运行论文《Research on Event Accumulator Settings for Event-Based SLAM》的源代码时的调试记录,下面简称为EventAccumulator。

针对基于事件的SLAM的事件累加器设置的研究

这是论文“Research on Event Accumulator Settings for Event-Based SLAM”的源代码。更多详情,请参见论文:

1
K. Xiao, G. Wang, Y. Chen, Y. Xie, H. Li and S. Li, "Research on Event Accumulator Settings for Event-Based SLAM," 2022 6th International Conference on Robotics, Control and Automation (ICRCA), 2022, pp. 50-56, doi: 10.1109/ICRCA55033.2022.9828933.

ArXiv 预印本 arXiv:2112.00427(2022)

1. 先决条件

1
2
3
4
5
6
7
8
9
10
11
12
# 查看版本
# gcc
gcc -v # 7.5.0
# cmake
cmake --version # 3.17.2
# Eigen
gedit /usr/include/eigen3/Eigen/src/Core/util/Macros.h # 3.3.0
# Opencv
pkg-config --modversion opencv # 3.4.5
pkg-config --cflags opencv # 得到opencv的安装路径
# -> -I/usr/local/include/opencv -I/usr/local/include
pkg-config --cflags opencv4 # 附加:得到opencv4的安装路径

dv_rosVINS-Fusion

dv_ros

  • Boost: 1.73
  • Eigen: 3.3.0/3.4.0
  • OpenCV:3.4.5
  1. 安装iniVation dv-runtime

    • apt-get方法。不建议,使用sudo apt-get install dv-runtime-dev安装的(最新)的dv-runtime的需要OpenCV >= 4.2.0、gcc >= 10.0等。尤其是当gcc >= 10.0,编译dv_ros时会报错rebind(因为gcc的版本太高)。矛盾的是,当降低gcc版本到7,编译dv_rosdv-runtime又会报错要求gcc >= 10.0。

      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      # Bionic (18.04 LTS) on the x86_64, x86, arm64 and armhf architectures.
      sudo add-apt-repository ppa:ubuntu-toolchain-r/test
      sudo add-apt-repository ppa:inivation-ppa/inivation-bionic
      sudo apt-get update
      sudo apt-get install dv-gui

      # Focal (20.04 LTS) and Jammy (22.04 LTS) on the x86_64, arm64 and armhf architectures.
      sudo add-apt-repository ppa:inivation-ppa/inivation
      sudo apt-get update
      sudo apt-get install dv-gui

      安装以下附加软件包:

      1
      2
      #! 需要升级libopencv3.2
      sudo apt-get install dv-runtime-dev

      在 ARM 上,你可能需要使用以下环境变量来启动 dv 运行时:

      UNW_ARM_UNWIND_METHOD=4

    • 源码安装方法。建议。

      对于源代码安装,您可以按照这里的步骤操作。需要高版本的 fmt (> = 7.0.3)库和 Boost (> = 1.73)库。

      1. 卸载dv-runtime-dev

        1
        2
        3
        4
        # 卸载dv-runtime-dev
        apt list --installed | grep -i dv-runtime-dev # 模糊搜索
        sudo apt remove dv-runtime-dev # 卸载软件
        sudo apt-get purge dv-runtime-dev # 清除配置
      2. 下载dv-runtime-1.2.5

      3. 编译。

        1
        2
        3
        4
        5
        cd dv-runtime-1.2.5
        mkdir build && cd build
        cmake -DCMAKE_INSTALL_PREFIX=/usr ..
        make -j8
        sudo make install

        报错:

        1. /dv-runtime-1.2.5/modules/calibration/calibration.cpp:50:63: error: ‘class cv::FileNode’ has no member named ‘string’; did you mean ‘isString’?

          1
          2
          3
          # dv-runtime-1.2.5/CmakeList.txt
          # 使用OpenCV 3.1.0 报错,使用OpenCV 3.4.5 编译成功。
          set(OpenCV_DIR /usr/local/opencv/opencv345/share/OpenCV) # 新增
  2. 克隆依赖库。

    1
    2
    3
    4
    5
    6
    cd yourfolder
    mkdir -p catkin_ws/src
    cd catkin_ws
    catkin config --init --mkdirs --extend /opt/ros/melodic --merge-devel --cmake-args -DCMAKE_BUILD_TYPE=Release
    cd src
    catkin_init_workspace

    下载CeleX5-ROSrpg_dvs_ros解压到./catkin_ws/src目录下。

  3. 克隆dv_ros。

    下载dv_ros-56f339403f5b1b2dbf702eee1286f5e87db46eba.zip解压到./catkin_ws/src目录下。(可选)重命名为dv_ros

  4. (可选)指定项目编译使用的OpenCV版本。

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    # CmakeList.txt
    set(OpenCV_DIR /usr/local/opencv/opencv345/share/OpenCV) # 新增
    find_package(OpenCV REQUIRED)
    # find_package(cv_bridge) # 如果find_package(OpenCV REQUIRED)报错
    include_directories(${OpenCV_INCLUDE_DIRS}) # 新增
    # 新增
    message(STATUS "opencv version: ${OpenCV_VERSION}")
    message(STATUS "opencv lib: ${OpenCV_LIBS}")
    message(STATUS "opencv include dir: ${OpenCV_INCLUDE_DIRS}")
    message(STATUS "opencv config path: ${openCV_CONFIG_PATH}")
  5. 编译。

    1
    2
    3
    4
    5
    #! 需要升级libopencv3.2
    sudo apt-get install ros-melodic-ddynamic-reconfigure
    catkin build dv_ros
    # 如果编译报错:
    # catkin clean 相当于 rm -r ${build} ${devel}, 但是避免了 rm -r 这种危险的操作!

    报错:

    1. Project ‘cv_bridge‘ specifies ‘/usr/include/opencv‘ as an include dir, which is not found.

      1
      2
      3
      # 安装OpenCV 4.2.0 or newer
      # 然后
      sudo ln -s /usr/include/opencv4 /usr/include/opencv
    2. /usr/lib/x86_64-linux-gnu/cmake/dv-processing/dv-processing-config.cmake:40 (MESSAGE):Cannot find OpenCV 4.2.0 or newer.

      1
      2
      3
      4
      5
      6
      7
      # 安装OpenCV 4.2.0 or newer
      # 然后
      sudo gedit /usr/lib/x86_64-linux-gnu/cmake/dv-processing/dv-processing-config.cmake
      # Line 38
      FIND_PACKAGE(OpenCV REQUIRED)
      # 修改为
      FIND_PACKAGE(OpenCV 4 REQUIRED)

      治标不治本,建议源码安装dv-runtime-1.2.5。

    3. target "dv::dvsdk" but the target was not found.

      1
      2
      3
      4
      5
      6
      7
      # CmakeList.txt
      target_link_libraries(dv_ros_lib
      ${OpenCV_LIBS}
      ${catkin_LIBRARIES}
      # dv::dvsdk
      dv::sdk
      )

      治标不治本,建议源码安装dv-runtime-1.2.5。

    4. /catkin_ws/src/dv_ros/dv_ros/accumulator/accumulator.cc:113:9: error: ‘struct dv::Frame’ has no member named ‘convertTo’
      113 | frame.convertTo(corrected_frame_, CV_8U, scale_factor, shift_factor);

      1
      2
      3
      // dv_ros/dv_ros/accumulator/accumulator.cc
      // frame.convertTo(corrected_frame_, CV_8U, scale_factor, shift_factor);
      frame.image.convertTo(corrected_frame_, CV_8U, scale_factor, shift_factor);

      治标不治本,建议源码安装dv-runtime-1.2.5。

    5. /opt/ros/melodic/include/ros/serialization.h:427:82: error: no class template named ‘rebind’ in ‘class std::allocator<dvs_msgs::Event_<std::allocator > >’
      427 | typedef std::vector<T, typename ContainerAllocator::template rebind::other> VecType;

      卸载使用sudo apt-get install dv-runtime-dev安装的(最新)的dv-runtime,源码安装dv-runtime-1.2.5。

    6. target "libcaer::caer" but the target was not found.

      1. 查看系统中是否已安装的libcaer-dev

        1
        apt list --installed | grep -i libcaer-dev  # 模糊搜索
      2. 卸载之前使用sudo apt install命令安装的libcaer-dev

        1
        2
        sudo apt remove libcaer-dev  # 卸载软件
        sudo apt-get purge libcaer-dev # 清除配置
      3. 源码编译安装libcaer-dev

        1
        2
        3
        4
        5
        6
        7
        8
        sudo apt install libusb-1.0-0-dev libserialport-dev
        cd ~/yourfolder
        git clone https://gitlab.com/inivation/dv/libcaer.git
        cd libcaer
        mkdir build && cd build
        cmake -DENABLE_SERIALDEV=1 -DENABLE_OPENCV=1 ..
        sudo make -j8
        sudo make install
      4. 配置CmakeList.txt

        1
        2
        sudo find / -name libcaer-exports.cmake
        # /usr/local/lib/cmake/libcaer/libcaer-exports.cmake
        1
        2
        3
        # dv_ros-master/CMakeLists.txt
        set(libcaer_DIR "/usr/local/lib/cmake/libcaer/") # 新增
        find_package(libcaer REQUIRED) # 新增

VINS-Fusion

  1. 安装ROS
  2. 安装Eigen-3.3.0
  3. 安装OpenCV-3.2.0
  4. 安装Ceres-Solver-1.14.0

其他依赖包

  1. catkin_simple

    1
    2
    cd yourfolder/catkin_ws/src
    git clone https://github.com/catkin/catkin_simple.git
  2. matplotlib-cpp

    1
    2
    cd yourfolder/catkin_ws/src/CeleX5-ROS/celex5_calibration/third_party
    git clone https://github.com/lava/matplotlib-cpp.git

2. 构建

1
2
3
4
5
cd ~/catkin_ws/src
git clone https://github.com/robin-shaun/event-slam-accumulator-settings.git
cd ../
catkin_make # 或 catkin build
source ~/catkin_ws/devel/setup.bash

报错:

  1. catkin build celex5_calibration. /opt/Qt5.9.9/5.9.9/gcc_64/lib/libQt5Test.so.5:对‘operator delete(void*, unsigned long)@Qt_5’未定义的引用.

    https://github.com/ros-industrial/ros_qtc_plugin/issues/117

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    #  ln [OPTION]... [-T] TARGET LINK_NAME
    # 在指定的目录下,创建一个名为 LINK_NAME 的硬链接或符号链接,指向名为 TARGET 的文件或目录。

    # 有用
    catkin build celex5_calibration # test

    cd /opt/Qt5.9.9/5.9.9/gcc_64/lib
    ll libQt5Test.so.5
    # libQt5Test.so.5 -> libQt5Test.so.5.9.9(都在当前目录)
    cd /usr/lib/x86_64-linux-gnu
    ll libQt5Test.so.5
    # libQt5Test.so.5 -> libQt5Test.so.5.9.5(都在当前目录)
    # 修改/opt/Qt5.9.9/5.9.9/gcc_64/lib/libQt5Test.so.5 -> /opt/Qt5.9.9/5.9.9/gcc_64/lib/libQt5Test.so.5
    cd /opt/Qt5.9.9/5.9.9/gcc_64/lib
    cp libQt5Test.so.5 /yourfloder/backup/lntest
    sudo rm libQt5Test.so.5
    sudo ln -s /usr/lib/x86_64-linux-gnu/libQt5Test.so.5 /opt/Qt5.9.9/5.9.9/gcc_64/lib/libQt5Test.so.5
  2. /opt/Qt5.9.9/5.9.9/gcc_64/lib/libQt5OpenGL.so.5:对‘operator delete(void*, unsigned long)@Qt_5’未定义的引用.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    catkin build celex5_calibration  # test

    cd /opt/Qt5.9.9/5.9.9/gcc_64/lib
    ll libQt5OpenGL.so.5
    # libQt5OpenGL.so.5 -> libQt5OpenGL.so.5.9.9(都在当前目录)
    cd /usr/lib/x86_64-linux-gnu
    ll libQt5OpenGL.so.5
    # libQt5OpenGL.so.5 -> libQt5OpenGL.so.5.9.5(都在当前目录)
    # 修改/opt/Qt5.9.9/5.9.9/gcc_64/lib/libQt5OpenGL.so.5.9.5 -> /opt/Qt5.9.9/5.9.9/gcc_64/lib/libQt5OpenGL.so.5.9.5
    cd /opt/Qt5.9.9/5.9.9/gcc_64/lib
    cp libQt5OpenGL.so.5 /yourfloder/backup/lntest
    sudo rm libQt5OpenGL.so.5
    sudo ln -s /usr/lib/x86_64-linux-gnu/libQt5OpenGL.so.5 /opt/Qt5.9.9/5.9.9/gcc_64/lib/libQt5OpenGL.so.5

3. 演示

我们在事件相机数据集上定量评估了所提出的方法。此演示以dynamic_6dof序列为例。

首先,启动dv_ros。注意,事件累加器依赖于时间戳,因此当您重新开始数据集或davis驱动程序时,您应该重新启动dv_ros。

1
source ./devel/setup.zsh && roslaunch dv_ros davis240.launch

然后,启动VINS-Fusion

1
source ./devel/setup.zsh &&  roslaunch vins vins_rviz.launch
1
source ./devel/setup.zsh &&  rosrun vins vins_node ./src/VINS-Fusion/config/davis/rpg_240_mono_imu_config.yaml

最后,播放rosbag

1
2
3
cd ~/catkin_ws/src/event-slam-accumulator-settings/dataset
rosbag play dynamic_6dof.bag
# rosbag play /media/lll25655/Data/LLL25655/Documents/Dataset/UltimateSLAM/dynamic_6dof.bag

注意,默认的VINS-Fusion频率与事件帧频率相同,为30 Hz。如果您的CPU不够强大,也许您应该在此文件中将其减少到15 Hz,通过取消注释代码。然而,这也会降低性能。

1
2
3
4
5
6
// if(inputImageCnt % 2 == 0)
// {
mBuf.lock();
featureBuf.push(make_pair(t, featureFrame));
mBuf.unlock();
// }

4. 使用您的设备运行

我们已经用DAVIS240和DAVIS346测试了代码。如果您想用您的设备运行,您应该使用rpg_dvs_ros。最重要的事情是校准事件相机和imu。我们建议使用Kalibr和传统的APS和IMU图片,因为APS和DVS的内参和外参几乎相同。

如果您想将基于事件的VINS Fusion与DAVIS346的传统VINS Fusion进行比较,您应该使用这份代码。因为DAVIS346的APS帧有时会改变大小,我们对VINS-Fusion进行了一些修改。

5. 使用ORBSLAM3进行双目视觉SLAM运行

论文中未介绍基于事件帧的双目视觉SLAM。我们使用ORBSLAM3来处理来自dv_ros的事件帧。数据集为双目DAVIS数据集。结果表明,所提出的方法通过计算绝对轨迹误差(RMS,单位:cm),使用odometry 和SLAM评估的Python包,性能优于ESVO

序列 所提出的方法 ESVO
monitor 1.49 3.3
bin 2.66 2.8
box 3.51 5.8
desk 3.14 3.2

事件窗口大小:15000, 事件贡献:0.33

首先根据此处指示,将ORBSLAM3与ROS一起编译。然后您可以使用此脚本运行ORBSLAM3,该脚本订阅事件帧并发布估算的位置(我们对ORBSLAM3进行了小幅修改,以发布估算的位置)。

6. 评估结果

我们修改了rpg_trajectory_evaluation以在终端打印平均位置误差和平均偏航误差。您可以通过以下方式评估论文中展示的结果

1
python analyze_trajectory_single.py ../results/boxes_6dof

7. 致谢

感谢dv_ros和我们使用的所有开源项目。


EventAccumulator编译运行调试记录
http://zeyulong.com/posts/827160f0/
作者
龙泽雨
发布于
2024年2月7日
许可协议