系统相关
首页 > 系统相关> > ubuntu16.04运行Open VINS

ubuntu16.04运行Open VINS

作者:互联网

####仅作为笔记
ubuntu16.04

  1. 安装ROS
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
sudo apt-get update
sudo apt-get install ros-kinetic-desktop-full
sudo apt-get install python-catkin-tools
echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
source ~/.bashrc
  1. OpenCV3.4.6
git clone --branch 3.4.6 https://github.com/opencv/opencv/
git clone --branch 3.4.6 https://github.com/opencv/opencv_contrib/
mkdir opencv/build/
cd opencv/build/
cmake -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules ..
make -j4
sudo make install
  1. 安装OpenVINS
mkdir -p ~/workspace/catkin_ws_ov/src/
cd ~/workspace/catkin_ws_ov/src/
git clone https://github.com/rpng/open_vins/
cd ..
catkin build
  1. 安装评估环境
sudo apt-get install python-matplotlib python-numpy python2.7-dev python-psutil
catkin build -DDISABLE_MATPLOTLIB=OFF # build with viz (default)
catkin build -DDISABLE_MATPLOTLIB=ON # build without viz
  1. 测试
#数据集下载:https://docs.openvins.com/gs-datasets.html
#在下载链接提供launch文件的例子
在launch文件中需要修改的有:
<arg name="bag"         default="/home/patrick/datasets/eth/V1_01_easy.bag" />
<arg name="path_est"    default="/tmp/traj_estimate.txt" />
<arg name="path_time"   default="/tmp/traj_timing.txt" />
#都是路径问题

如果使用自己的相机,并且使用rosbag录制的数据集:

<launch>

    <!-- mono or stereo and what ros bag to play -->
    <arg name="max_cameras" default="2" />
    <arg name="use_stereo"  default="true" />
    <arg name="bag_start"   default="0" /> <!-- v1-2: 0, mh1: 40, mh2: 35, mh3-5: 20 -->
    <arg name="bag"         default="/home/ubuntu/realsense/whitewall.bag" />

    <!-- imu starting thresholds -->
    <arg name="init_window_time"  default="0.75" />
    <arg name="init_imu_thresh"   default="0" />

    <!-- saving trajectory path and timing information -->
    <arg name="dosave"      default="false" />
    <arg name="dotime"      default="false" />
    <arg name="path_est"    default="/home/ubuntu/realsense/traj_estimate.txt" />
    <arg name="path_time"   default="/home/ubuntu/realsense/traj_timing.txt" />


    <!-- MASTER NODE! -->
    <node name="run_subscribe_msckf" pkg="ov_msckf" type="run_subscribe_msckf" output="screen" clear_params="true" required="true">

        <!-- bag topics -->
        <param name="topic_imu"      type="string" value="/camera/imu" />
        <param name="topic_camera0"  type="string" value="/camera/fisheye1/image_raw" />
        <param name="topic_camera1"  type="string" value="/camera/fisheye2/image_raw" />

        <!-- world/filter parameters -->
        <param name="use_fej"                type="bool"   value="true" />
        <param name="use_imuavg"             type="bool"   value="true" />
        <param name="use_rk4int"             type="bool"   value="true" />
        <param name="use_stereo"             type="bool"   value="$(arg use_stereo)" />
        <param name="calib_cam_extrinsics"   type="bool"   value="true" />
        <param name="calib_cam_intrinsics"   type="bool"   value="true" />
        <param name="calib_cam_timeoffset"   type="bool"   value="true" />
        <param name="calib_camimu_dt"        type="double" value="0.0" />
        <param name="max_clones"             type="int"    value="11" />
        <param name="max_slam"               type="int"    value="75" />
        <param name="max_slam_in_update"     type="int"    value="25" /> <!-- 25 seems to work well -->
        <param name="max_msckf_in_update"    type="int"    value="999" />
        <param name="max_cameras"            type="int"    value="$(arg max_cameras)" />
        <param name="dt_slam_delay"          type="double" value="3" />
        <param name="init_window_time"       type="double" value="$(arg init_window_time)" />
        <param name="init_imu_thresh"        type="double" value="$(arg init_imu_thresh)" />
        <rosparam param="gravity">[0.0,0.0,9.79]</rosparam>
        <param name="feat_rep_msckf"         type="string" value="GLOBAL_3D" />
        <param name="feat_rep_slam"          type="string" value="ANCHORED_FULL_INVERSE_DEPTH" />
        <param name="feat_rep_aruco"         type="string" value="ANCHORED_FULL_INVERSE_DEPTH" />

        <!-- timing statistics recording -->
        <param name="record_timing_information"   type="bool"   value="$(arg dotime)" />
        <param name="record_timing_filepath"      type="string" value="$(arg path_time)" />

        <!-- tracker/extractor properties -->
        <param name="use_klt"            type="bool"   value="true" />
        <param name="num_pts"            type="int"    value="150" />
        <param name="fast_threshold"     type="int"    value="15" />
        <param name="grid_x"             type="int"    value="5" />
        <param name="grid_y"             type="int"    value="3" />
        <param name="min_px_dist"        type="int"    value="10" />
        <param name="knn_ratio"          type="double" value="0.70" />
        <param name="downsample_cameras" type="bool"   value="false" />

        <!-- aruco tag/mapping properties -->
        <param name="use_aruco"        type="bool"   value="false" />
        <param name="num_aruco"        type="int"    value="1024" />
        <param name="downsize_aruco"   type="bool"   value="true" />

        <!-- sensor noise values / update -->
        <param name="up_msckf_sigma_px"            type="double"   value="1" />
        <param name="up_msckf_chi2_multipler"      type="double"   value="1" />
        <param name="up_slam_sigma_px"             type="double"   value="1" />
        <param name="up_slam_chi2_multipler"       type="double"   value="1" />
        <param name="up_aruco_sigma_px"            type="double"   value="1" />
        <param name="up_aruco_chi2_multipler"      type="double"   value="1" />
        <param name="gyroscope_noise_density"      type="double"   value="2.1708707285582919e-03" />
        <param name="gyroscope_random_walk"        type="double"   value="3.3310892418430371e-05" />
        <param name="accelerometer_noise_density"  type="double"   value="1.8821062378332139e-02" />
        <param name="accelerometer_random_walk"    type="double"   value="4.7642541871083607e-04" />

        <!-- camera intrinsics -->
        <rosparam param="cam0_wh">[848, 800]</rosparam>
        <rosparam param="cam1_wh">[848, 800]</rosparam>
        <param name="cam0_is_fisheye" type="bool" value="true" />
        <param name="cam1_is_fisheye" type="bool" value="true" />
        <rosparam param="cam0_k">[286.9511328506641, 286.5417880620762, 423.9106424074819, 394.48792893961905]</rosparam>
        <rosparam param="cam0_d">[0.0009142158585712033, 0.05393235583078715, -0.06370985330963085, 0.016282796056288063]</rosparam>
        <rosparam param="cam1_k">[286.8653055921684, 286.4203090917762, 418.9288595645989, 399.2454060401281]</rosparam>
        <rosparam param="cam1_d">[0.006524437649180689, 0.027957476236585614, -0.02749575475474867, 0.001296949984931970]</rosparam>

        <!-- camera extrinsics -->
        <rosparam param="T_C0toI">
            [
            -0.99990013, -0.0054273,   0.01304901,  0.0007662,
            0.00551683, -0.99996143,  0.00683448,  0.00023907,
            0.01301141,  0.00690579,  0.9998915,   0.0038333,
            0.0, 0.0, 0.0, 1.0
            ]
        </rosparam>
        <rosparam param="T_C1toI">
            [
            -0.99990467, -0.00663728,  0.01210738, -0.06398971,
            0.00670205, -0.99996341,  0.00531653,  0.00016392,
            0.01207165,  0.00539717,  0.99991257,  0.00419339,
            0.0, 0.0, 0.0, 1.0
            ]
        </rosparam>
    </node>
    
    <!-- play the dataset -->
    <node pkg="rosbag" type="play" name="rosbag" args="-d 1 -s $(arg bag_start) $(arg bag)" required="true"/>

    <!-- record the trajectory if enabled -->
    <group if="$(arg dosave)">
        <node name="recorder_estimate" pkg="ov_eval" type="pose_to_file" output="screen" required="true">
            <param name="topic"      type="str" value="/ov_msckf/poseimu" />
            <param name="topic_type" type="str" value="PoseWithCovarianceStamped" />
            <param name="output"     type="str" value="$(arg path_est)" />
        </node>
    </group>
    <node type="rviz" name="rviz" pkg="rviz" args="-d $(find ov_msckf)/launch/display.rviz" />

</launch>

如果使用自己的相机,使用相机实时数据传输:

<launch>
    <!-- mono or stereo and what ros bag to play -->
    <arg name="max_cameras" default="2" />          #最大相机数目,单目:1,双目:2
    <arg name="use_stereo"  default="true" />       #是否使用双目相机

    <!-- imu starting thresholds -->
    <arg name="init_window_time"  default="0.75" />     
    <arg name="init_imu_thresh"   default="0" />

    <!-- saving trajectory path and timing information -->
    <arg name="dosave"      default="false" />           #是否保存轨迹
    <arg name="dotime"      default="false" />           #是否保存时间信息
    <arg name="path_est"    default="/home/ubuntu/catkin_ws/src/ov_raspi/traj_estimate.txt" />  #保存路径
    <arg name="path_time"   default="/home/ubuntu/catkin_ws/src/ov_raspi/traj_timing.txt" />


    <!-- MASTER NODE! -->
    <node name="run_subscribe_msckf" pkg="ov_msckf" type="run_subscribe_msckf" output="screen" clear_params="true" required="true">

        <!-- bag topics -->
        <param name="topic_imu"      type="string" value="/camera/imu" />      #修改成自己的imu topic
        <param name="topic_camera0"  type="string" value="/camera/fisheye1/image_raw" />   #修改成自己的双目topic
        <param name="topic_camera1"  type="string" value="/camera/fisheye2/image_raw" />

        <!-- world/filter parameters -->
        <param name="use_fej"                type="bool"   value="true" />
        <param name="use_imuavg"             type="bool"   value="true" />
        <param name="use_rk4int"             type="bool"   value="true" />
        <param name="use_stereo"             type="bool"   value="$(arg use_stereo)" />
        <param name="calib_cam_extrinsics"   type="bool"   value="true" />
        <param name="calib_cam_intrinsics"   type="bool"   value="true" />
        <param name="calib_cam_timeoffset"   type="bool"   value="true" />
        <param name="calib_camimu_dt"        type="double" value="0.0" />
        <param name="max_clones"             type="int"    value="11" />
        <param name="max_slam"               type="int"    value="25" />
        <param name="max_slam_in_update"     type="int"    value="25" /> <!-- 25 seems to work well -->
        <param name="max_msckf_in_update"    type="int"    value="50" />
        <param name="max_cameras"            type="int"    value="$(arg max_cameras)" />
        <param name="dt_slam_delay"          type="double" value="3" />
        <param name="init_window_time"       type="double" value="$(arg init_window_time)" />
        <param name="init_imu_thresh"        type="double" value="$(arg init_imu_thresh)" />
        <rosparam param="gravity">[0.0,0.0,9.81]</rosparam>
        <param name="feat_rep_msckf"         type="string" value="GLOBAL_3D" />
        <param name="feat_rep_slam"          type="string" value="ANCHORED_FULL_INVERSE_DEPTH" />
        <param name="feat_rep_aruco"         type="string" value="ANCHORED_FULL_INVERSE_DEPTH" />

        <!-- timing statistics recording -->
        <param name="record_timing_information"   type="bool"   value="$(arg dotime)" />
        <param name="record_timing_filepath"      type="string" value="$(arg path_time)" />

        <!-- tracker/extractor properties -->
        <param name="use_klt"            type="bool"   value="true" />
        <param name="num_pts"            type="int"    value="150" />
        <param name="fast_threshold"     type="int"    value="15" />
        <param name="grid_x"             type="int"    value="5" />
        <param name="grid_y"             type="int"    value="3" />
        <param name="min_px_dist"        type="int"    value="10" />
        <param name="knn_ratio"          type="double" value="0.70" />
        <param name="downsample_cameras" type="bool"   value="false" />

        <!-- aruco tag/mapping properties -->
        <param name="use_aruco"        type="bool"   value="false" />
        <param name="num_aruco"        type="int"    value="1024" />
        <param name="downsize_aruco"   type="bool"   value="true" />

        <!-- sensor noise values / update -->
        <param name="up_msckf_sigma_px"            type="double"   value="1" />
        <param name="up_msckf_chi2_multipler"      type="double"   value="1" />
        <param name="up_slam_sigma_px"             type="double"   value="1" />
        <param name="up_slam_chi2_multipler"       type="double"   value="1" />
        <param name="up_aruco_sigma_px"            type="double"   value="1" />
        <param name="up_aruco_chi2_multipler"      type="double"   value="1" />
        <param name="gyroscope_noise_density"      type="double"   value="2.1708707285582919e-03" />  #修改成自己的imu校准数据
        <param name="gyroscope_random_walk"        type="double"   value="3.3310892418430371e-05" />
        <param name="accelerometer_noise_density"  type="double"   value="1.8821062378332139e-02" />
        <param name="accelerometer_random_walk"    type="double"   value="4.7642541871083607e-04" />

        <!-- camera intrinsics -->    #相机内参自己提供,推荐Kalibr camera-imu联合校准,以下信息基本都会有
        <rosparam param="cam0_wh">[848, 800]</rosparam>
        <rosparam param="cam1_wh">[848, 800]</rosparam>
        <param name="cam0_is_fisheye" type="bool" value="true" />
        <param name="cam1_is_fisheye" type="bool" value="true" />
        <rosparam param="cam0_k">[286.9511328506641, 286.5417880620762, 423.9106424074819, 394.48792893961905]</rosparam>
        <rosparam param="cam0_d">[0.0009142158585712033, 0.05393235583078715, -0.06370985330963085, 0.016282796056288063]</rosparam>
        <rosparam param="cam1_k">[286.8653055921684, 286.4203090917762, 418.9288595645989, 399.2454060401281]</rosparam>
        <rosparam param="cam1_d">[0.006524437649180689, 0.027957476236585614, -0.02749575475474867, 0.001296949984931970]</rosparam>

        <!-- camera extrinsics -->
        <rosparam param="T_C0toI">
            [
            -0.99990013, -0.0054273,   0.01304901,  0.0007662,
            0.00551683, -0.99996143,  0.00683448,  0.00023907,
            0.01301141,  0.00690579,  0.9998915,   0.0038333,
            0.0, 0.0, 0.0, 1.0
            ]
        </rosparam>
        <rosparam param="T_C1toI">
            [
            -0.99990467, -0.00663728,  0.01210738, -0.06398971,
            0.00670205, -0.99996341,  0.00531653,  0.00016392,
            0.01207165,  0.00539717,  0.99991257,  0.00419339,
            0.0, 0.0, 0.0, 1.0
            ]
        </rosparam>
    </node>

    <!-- record the trajectory if enabled -->
    <group if="$(arg dosave)">
        <node name="recorder_estimate" pkg="ov_eval" type="pose_to_file" output="screen" required="true">
            <param name="topic"      type="str" value="/ov_msckf/poseimu" />
            <param name="topic_type" type="str" value="PoseWithCovarianceStamped" />
            <param name="output"     type="str" value="$(arg path_est)" />
        </node>
    </group>
    <node type="rviz" name="rviz" pkg="rviz" args="-d $(find ov_msckf)/launch/display.rviz" />

</launch>
  1. 测试结果
    在这里插入图片描述在这里插入图片描述

标签:ubuntu16.04,catkin,0.0,sudo,apt,opencv,build,VINS,Open
来源: https://blog.csdn.net/wyy13273181006/article/details/108789138