ubuntu20.04安装vins-fusion错误及运行

本人配置 Opencv 4.4 、 ceres-solver-2.0.0 、 eigen-3.3.7

一、错误

1.cere

代码如下(示例):

名为: /usr/local/include/ceres/的错误

在报错的项目的CMakeList里的
set(CMAKE_CXX_FLAGS “-std=c++11”)
改成
set(CMAKE_CXX_STANDARD 14)

本人更改的文件夹有
VINS-Fusion/camera_models
VINS-Fusion/global_fusion
VINS-Fusion/loop_fusion
VINS-Fusion/vins_estimator

2.

代码如下(示例):

error: ‘CV_FONT_HERSHEY_SIMPLEX’ was not declared in this scope

将报错文件上的CV_FONT_HERSHEY_SIMPLEX参数改为cv::FONT_HERSHEY_SIMPLEX

本人更改的文件有:
VINS-Fusion/loop_fusion/src/keyframe.cpp
VINS-Fusion/loop_fusion/src/pose_graph.cpp

3.

代码如下(示例):

error: ‘CV_GRAY2RGB’ was not declared in this scope

在报错头文件里添加

#include 

本人更改的文件有:
VINS-Fusion/vins_estimator/src/featureTracker/feature_tracker.cpp
VINS-Fusion/loop_fusion/src/ThirdParty/DVision/BRIEF.cpp

其他错误参考

二、输出轨迹

1、visualization.cpp(第157行)

        ofstream foutC(VINS_RESULT_PATH, ios::app);
        foutC.setf(ios::fixed, ios::floatfield);
        foutC.precision(0);
        foutC << header.stamp.toSec() * 1e9 << ",";
        foutC.precision(5);
        foutC << estimator.Ps[WINDOW_SIZE].x() << ","
              << estimator.Ps[WINDOW_SIZE].y() << ","
              << estimator.Ps[WINDOW_SIZE].z() << ","
              << tmp_Q.w() << ","
              << tmp_Q.x() << ","
              << tmp_Q.y() << ","
              << tmp_Q.z() << ","
              << estimator.Vs[WINDOW_SIZE].x() << ","
              << estimator.Vs[WINDOW_SIZE].y() << ","
              << estimator.Vs[WINDOW_SIZE].z() << "," << endl;
        foutC.close();

修改为:

        
        ofstream foutC("/home/seal/VINS-output/VINS/unloop_result.txt", ios::app);
        foutC.setf(ios::fixed, ios::floatfield);
        foutC.precision(0);
        foutC << header.stamp.toSec() << " ";
        foutC.precision(5);
        foutC << estimator.Ps[WINDOW_SIZE].x() << " "
              << estimator.Ps[WINDOW_SIZE].y() << " "
              << estimator.Ps[WINDOW_SIZE].z() << " "
              << tmp_Q.x() << " "
              << tmp_Q.y() << " "
              << tmp_Q.z() << " "
              << tmp_Q.w() << endl;
        foutC.close();

2、pose_graph.cpp(20行)

第一步

第一部分(第185行)
if (SAVE_LOOP_PATH)
    {
        ofstream loop_path_file(VINS_RESULT_PATH, ios::app);
        loop_path_file.setf(ios::fixed, ios::floatfield);
        loop_path_file.precision(0);
        loop_path_file << cur_kf->time_stamp * 1e9 << ",";
        loop_path_file.precision(5);
        loop_path_file  << P.x() << ","
              << P.y() << ","
              << P.z() << ","
              << Q.w() << ","
              << Q.x() << ","
              << Q.y() << ","
              << Q.z() << ","
              << endl;
        loop_path_file.close();
    }

修改为:

if (SAVE_LOOP_PATH)
    {
        ofstream loop_path_file(VINS_RESULT_PATH, ios::app);
        
        loop_path_file.setf(ios::fixed, ios::floatfield);
        loop_path_file.precision(0);
        loop_path_file << cur_kf->time_stamp << " ";
        loop_path_file.precision(5);
        loop_path_file  << P.x() << " "
              << P.y() << " "
              << P.z() << " "
              << Q.x() << " "
              << Q.y() << " "
              << Q.z() << " "
              << Q.w() << " "
              << endl;
        loop_path_file.close();
    }
第二部分(第830行)
if (SAVE_LOOP_PATH)
        {
        
            ofstream loop_path_file(VINS_RESULT_PATH, ios::app);
            loop_path_file.setf(ios::fixed, ios::floatfield);
            loop_path_file.precision(0);
            loop_path_file << (*it)->time_stamp * 1e9 << ",";
            loop_path_file.precision(5);
            loop_path_file  << P.x() << ","
                  << P.y() << ","
                  << P.z() << ","
                  << Q.w() << ","
                  << Q.x() << ","
                  << Q.y() << ","
                  << Q.z() << ","
                  << endl;
            loop_path_file.close();
        }

修改为:

if (SAVE_LOOP_PATH)
        {
        
            ofstream loop_path_file("/home/seal/VINS-output/VINS/loop-result.txt", ios::app);
            loop_path_file.setf(ios::fixed, ios::floatfield);
            loop_path_file.precision(0);
            loop_path_file << (*it)->time_stamp << " ";
            loop_path_file.precision(5);
            loop_path_file  << P.x() << " "
                            << P.y() << " "
                            << P.z() << " "
                            << Q.x() << " "
                            << Q.y() << " "
                            << Q.z() << " "
                            << Q.w() << endl;

            loop_path_file.close();
        }

第二步

pose_graph_node.cpp(第458行)

更改名称

VINS_RESULT_PATH = VINS_RESULT_PATH + "/loop_result1.txt";

第三步

更改路径
1、euroc_stereo_config.yaml
output_path: "/home/seal/VINS-output/VINS/"
2、euroc_stereo_imu_config.yaml
output_path: "/home/seal/VINS-output/VINS/"
pose_graph_save_path: "/home/seal/VINS-output/VINS/pose_graph/" 

3、globalOptNode.cpp(第145行)

    std::ofstream foutC("/home/tony-ws1/output/vio_global.csv", ios::app);//这里还是文件输出位置
    foutC.setf(ios::fixed, ios::floatfield);
    foutC.precision(0);
    foutC << pose_msg->header.stamp.toSec() * 1e9 << ",";
    foutC.precision(5);
    foutC << global_t.x() << ","
            << global_t.y() << ","
            << global_t.z() << ","
            << global_q.w() << ","
            << global_q.x() << ","
            << global_q.y() << ","
            << global_q.z() << endl;
    foutC.close(); 

修改为:

    std::ofstream foutC("/home/seal/VINS-output/VINS/vio-global.txt", ios::app);
    foutC.setf(ios::fixed, ios::floatfield);
    foutC.precision(0);
    foutC << pose_msg->header.stamp.toSec() << " ";
    foutC.precision(5);
    foutC << global_t.x() << " "
            << global_t.y() << " "
            << global_t.z() << " "
            << global_q.x() << " "
            << global_q.y() << " "
            << global_q.z() << " "
            << global_q.w() << endl;
    foutC.close(); 

修改完后重新编译

cd ~/vins-fusion
catkin_make

三、euroc数据集运行

source ~/vins-fusion/devel/setup.bash
roslaunch vins vins_rviz.launch
source ~/vins-fusion/devel/setup.bash
rosrun vins vins_node ~/vins-fusion/src/VINS-Fusion/config/euroc/euroc_stereo_imu_config.yaml 

(optional)

source ~/vins-fusion/devel/setup.bash
rosrun loop_fusion loop_fusion_node ~/vins-fusion/src/VINS-Fusion/config/euroc/euroc_stereo_imu_config.yaml 
source ~/vins-fusion/devel/setup.bash
rosbag play ~/vins-fusion/output/V1_02.bag

source ~/vins-fusion-my/devel/setup.bash
roslaunch vins vins_rviz.launch
source ~/vins-fusion-my/devel/setup.bash
rosrun vins vins_node ~/vins-fusion-my/src/VINS-Fusion-im/config/euroc/euroc_stereo_imu_config.yaml

(optional)

source ~/vins-fusion-my/devel/setup.bash
rosrun loop_fusion loop_fusion_node ~/vins-fusion-my/src/VINS-Fusion-im/config/euroc/euroc_stereo_imu_config.yaml
source ~/vins-fusion-my/devel/setup.bash
rosbag play ~/vins-fusion/output/V1_02.bag

四、KITTI数据集运行

source ~/vins-fusion-my/devel/setup.bash
roslaunch vins vins_rviz.launch
source ~/vins-fusion-my/devel/setup.bash
rosrun loop_fusion loop_fusion_node ~vins-fusion-my/src/VINS-Fusion-im/config/kitti_odom/kitti_config04-12.yaml
source ~/vins-fusion-my/devel/setup.bash
rosrun vins kitti_odom_test src/VINS-Fusion-im/config/kitti_odom/kitti_config04-12.yaml /home/seal/vins-fusion/output/KITTI-dataset/sequences/09

使用evo评估

将state_groundtruth_estimate0中的data.csv转化为TUM格式(groundTruth)
evo_traj euroc data.csv --save_as_tum
计算轨迹误差
evo_ape tum result.csv ~/vins-fusion/date/evo/data.tum -va --plot --plot_mode xyz
evo_rpe tum result.csv ~/vins-fusion/date/evo/data.tum -r full -va --plot --plot_mode xyz

D435i运行

1.运行rviz

roslaunch vins vins_rviz.launch

2.数据融合代码

rosrun vins vins_node ~/vins-fusion/src/VINS-Fusion/config/realsense_d435i/realsense_stereo_imu_config.yaml

3.回环(可选)

rosrun loop_fusion loop_fusion_node ~/vins-fusion/src/VINS-Fusion/config/realsense_d435i/realsense_stereo_imu_config.yaml

4.播放rosbag包

rosbag play  ~/vins-fusion/output/date.bag

你可能感兴趣的:(ORB_SLAM,opencv,计算机视觉,c++)