### Build VINS-Fusion using Catkin Source: https://github.com/hkust-aerial-robotics/vins-fusion/blob/master/README.md Steps to clone the VINS-Fusion repository and build it using catkin_make within a ROS workspace. Assumes Ubuntu and ROS are already installed. ```bash cd ~/catkin_ws/src git clone https://github.com/HKUST-Aerial-Robotics/VINS-Fusion.git cd ../ catkin_make source ~/catkin_ws/devel/setup.bash ``` -------------------------------- ### CMake Project Setup and Dependencies Source: https://github.com/hkust-aerial-robotics/vins-fusion/blob/master/camera_models/CMakeLists.txt This snippet sets up the CMake build environment, specifies the minimum required CMake version, names the project, and configures C++ compiler flags for optimization. It also finds and includes necessary external libraries such as catkin, Boost, OpenCV, and Ceres, which are essential for the project's functionality. ```cmake cmake_minimum_required(VERSION 2.8.3) project(camera_models) set(CMAKE_BUILD_TYPE "Release") set(CMAKE_CXX_FLAGS "-std=c++11") set(CMAKE_CXX_FLAGS_RELEASE "-O3 -fPIC") find_package(catkin REQUIRED COMPONENTS roscpp std_msgs ) find_package(Boost REQUIRED COMPONENTS filesystem program_options system) include_directories(${Boost_INCLUDE_DIRS}) find_package(OpenCV REQUIRED) # set(EIGEN_INCLUDE_DIR "/usr/local/include/eigen3") find_package(Ceres REQUIRED) include_directories(${CERES_INCLUDE_DIRS}) ``` -------------------------------- ### Build VINS-Fusion Docker Image Source: https://github.com/hkust-aerial-robotics/vins-fusion/blob/master/README.md Builds the VINS-Fusion Docker image. This command navigates to the Docker directory and executes the make build command. Ensure ROS and Docker are installed and the user is in the 'docker' group. ```bash cd ~/catkin_ws/src/VINS-Fusion/docker make build ``` -------------------------------- ### CMake Include Directories Setup Source: https://github.com/hkust-aerial-robotics/vins-fusion/blob/master/global_fusion/CMakeLists.txt Specifies the directories from which header files will be included. This includes ROS catkin include directories, Ceres solver include directories, and the include directory for the GeographicLib library located in a ThirdParty subdirectory. ```cmake include_directories( ${catkin_INCLUDE_DIRS} ${CERES_INCLUDE_DIRS} ./ThirdParty/GeographicLib/include/ ) ``` -------------------------------- ### CMake Project Setup and Build Flags Source: https://github.com/hkust-aerial-robotics/vins-fusion/blob/master/global_fusion/CMakeLists.txt Configures the CMake build system for the VINS-Fusion project. It sets the minimum required CMake version, project name, build type to 'Release', and C++ compiler flags including C++11 standard support and optimization levels. ```cmake cmake_minimum_required(VERSION 2.8.3) project(global_fusion) set(CMAKE_BUILD_TYPE "Release") set(CMAKE_CXX_FLAGS "-std=c++11") set(CMAKE_CXX_FLAGS_RELEASE "-O3 -Wall -g") ``` -------------------------------- ### Run VINS-Fusion on Car Demonstration Source: https://github.com/hkust-aerial-robotics/vins-fusion/blob/master/README.md Launches VINS-Fusion for a car demonstration, including VIO odometry, optional visual loop closure, rviz, and playing a bag file. The commands specify configuration files for VINS and loop fusion. ```bash roslaunch vins vins_rviz.launch rosrun vins vins_node ~/catkin_ws/src/VINS-Fusion/config/vi_car/vi_car.yaml (optional) rosrun loop_fusion loop_fusion_node ~/catkin_ws/src/VINS-Fusion/config/vi_car/vi_car.yaml rosbag play YOUR_DATASET_FOLDER/car.bag ``` -------------------------------- ### Run KITTI Odometry (Stereo) Source: https://github.com/hkust-aerial-robotics/vins-fusion/blob/master/README.md Launches VINS-Fusion for KITTI Odometry with stereo data. Requires VINS-Fusion and rviz to be running, and optionally enables loop closure. The command specifies the configuration file and dataset folder. ```bash roslaunch vins vins_rviz.launch (optional) rosrun loop_fusion loop_fusion_node ~/catkin_ws/src/VINS-Fusion/config/kitti_odom/kitti_config00-02.yaml rosrun vins kitti_odom_test ~/catkin_ws/src/VINS-Fusion/config/kitti_odom/kitti_config00-02.yaml YOUR_DATASET_FOLDER/sequences/00/ ``` -------------------------------- ### Run KITTI GPS Fusion (Stereo + GPS) Source: https://github.com/hkust-aerial-robotics/vins-fusion/blob/master/README.md Launches VINS-Fusion for KITTI GPS Fusion with stereo and GPS data. This involves running VINS, global fusion, and rviz. The command specifies the configuration file and the synchronized dataset folder. ```bash roslaunch vins vins_rviz.launch rosrun vins kitti_gps_test ~/catkin_ws/src/VINS-Fusion/config/kitti_raw/kitti_10_03_config.yaml YOUR_DATASET_FOLDER/2011_10_03_drive_0027_sync/ rosrun global_fusion global_fusion_node ``` -------------------------------- ### CMake Configuration and Package Finding Source: https://github.com/hkust-aerial-robotics/vins-fusion/blob/master/vins_estimator/CMakeLists.txt Initializes CMake version, project name, build type, and compiler flags. It then finds required ROS packages, OpenCV, Ceres, and Eigen libraries, including their include directories for compilation. ```cmake cmake_minimum_required(VERSION 2.8.3) project(vins) set(CMAKE_BUILD_TYPE "Release") set(CMAKE_CXX_FLAGS "-std=c++11") #-DEIGEN_USE_MKL_ALL") set(CMAKE_CXX_FLAGS_RELEASE "-O3 -Wall -g") find_package(catkin REQUIRED COMPONENTS roscpp std_msgs geometry_msgs nav_msgs tf cv_bridge camera_models image_transport) find_package(OpenCV REQUIRED) # message(WARNING "OpenCV_VERSION: ${OpenCV_VERSION}") find_package(Ceres REQUIRED) include_directories(${catkin_INCLUDE_DIRS} ${CERES_INCLUDE_DIRS}) set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) find_package(Eigen3) include_directories( ${catkin_INCLUDE_DIRS} ${EIGEN3_INCLUDE_DIR} ) catkin_package() ``` -------------------------------- ### CMake Executable Target: Calibrations Source: https://github.com/hkust-aerial-robotics/vins-fusion/blob/master/camera_models/CMakeLists.txt This snippet defines the 'Calibrations' executable target and lists all the source files required to build it. These source files cover various aspects of camera calibration, model implementation, and sparse graph transformations. ```cmake add_executable(Calibrations src/intrinsic_calib.cc src/chessboard/Chessboard.cc src/calib/CameraCalibration.cc src/camera_models/Camera.cc src/camera_models/CameraFactory.cc src/camera_models/CostFunctionFactory.cc src/camera_models/PinholeCamera.cc src/camera_models/PinholeFullCamera.cc src/camera_models/CataCamera.cc src/camera_models/EquidistantCamera.cc src/camera_models/ScaramuzzaCamera.cc src/sparse_graph/Transform.cc src/gpl/gpl.cc src/gpl/EigenQuaternionParameterization.cc) ``` -------------------------------- ### Run VINS-Fusion (Stereo Cameras + IMU) on EuRoC Dataset Source: https://github.com/hkust-aerial-robotics/vins-fusion/blob/master/README.md Launches RViz, the VINS-Fusion node with stereo cameras and IMU configuration, and optionally the loop fusion node. It then plays the specified ROS bag file from the EuRoC dataset. ```bash roslaunch vins vins_rviz.launch rosrun vins vins_node ~/catkin_ws/src/VINS-Fusion/config/euroc/euroc_stereo_imu_config.yaml (optional) rosrun loop_fusion loop_fusion_node ~/catkin_ws/src/VINS-Fusion/config/euroc/euroc_stereo_imu_config.yaml rosbag play YOUR_DATASET_FOLDER/MH_01_easy.bag ``` -------------------------------- ### CMake Linking Libraries Source: https://github.com/hkust-aerial-robotics/vins-fusion/blob/master/camera_models/CMakeLists.txt This crucial snippet specifies the libraries that the 'Calibrations' executable and the 'camera_models' library should be linked against. It includes Boost libraries, OpenCV libraries, and Ceres solver libraries, ensuring all necessary functionalities are available at runtime. ```cmake target_link_libraries(Calibrations ${Boost_LIBRARIES} ${OpenCV_LIBS} ${CERES_LIBRARIES}) target_link_libraries(camera_models ${Boost_LIBRARIES} ${OpenCV_LIBS} ${CERES_LIBRARIES}) ``` -------------------------------- ### CMake Package and Library Definition Source: https://github.com/hkust-aerial-robotics/vins-fusion/blob/master/camera_models/CMakeLists.txt This section defines how the 'camera_models' library should be packaged and configured within the catkin build system. It specifies the include directories, the library name, and the catkin dependencies required for this module. ```cmake catkin_package( INCLUDE_DIRS include LIBRARIES camera_models CATKIN_DEPENDS roscpp std_msgs # DEPENDS system_lib ) include_directories( ${catkin_INCLUDE_DIRS} ) include_directories("include") ``` -------------------------------- ### Run VINS-Fusion (Monocular Camera + IMU) on EuRoC Dataset Source: https://github.com/hkust-aerial-robotics/vins-fusion/blob/master/README.md Launches RViz, the VINS-Fusion node with monocular camera and IMU configuration, and optionally the loop fusion node. It then plays the specified ROS bag file from the EuRoC dataset. ```bash roslaunch vins vins_rviz.launch rosrun vins vins_node ~/catkin_ws/src/VINS-Fusion/config/euroc/euroc_mono_imu_config.yaml (optional) rosrun loop_fusion loop_fusion_node ~/catkin_ws/src/VINS-Fusion/config/euroc/euroc_mono_imu_config.yaml rosbag play YOUR_DATASET_FOLDER/MH_01_easy.bag ``` -------------------------------- ### Create kitti_odom_test Executable Source: https://github.com/hkust-aerial-robotics/vins-fusion/blob/master/vins_estimator/CMakeLists.txt Creates an executable named 'kitti_odom_test' from 'src/KITTIOdomTest.cpp' and links it with 'vins_lib'. This is likely for testing odometry functionality with KITTI dataset. ```cmake add_executable(kitti_odom_test src/KITTIOdomTest.cpp) target_link_libraries(kitti_odom_test vins_lib) ``` -------------------------------- ### Define loop_fusion_node Executable and Link Libraries Source: https://github.com/hkust-aerial-robotics/vins-fusion/blob/master/loop_fusion/CMakeLists.txt Defines the main executable 'loop_fusion_node' with a comprehensive list of its source files, including those for the core logic, keyframes, utility functions, and third-party libraries like DBoW and DUtils. It then links the executable with required libraries such as catkin, OpenCV, and Ceres. ```cmake catkin_package() add_executable(loop_fusion_node src/pose_graph_node.cpp src/pose_graph.cpp src/keyframe.cpp src/utility/CameraPoseVisualization.cpp src/ThirdParty/DBoW/BowVector.cpp src/ThirdParty/DBoW/FBrief.cpp src/ThirdParty/DBoW/FeatureVector.cpp src/ThirdParty/DBoW/QueryResults.cpp src/ThirdParty/DBoW/ScoringObject.cpp src/ThirdParty/DUtils/Random.cpp src/ThirdParty/DUtils/Timestamp.cpp src/ThirdParty/DVision/BRIEF.cpp src/ThirdParty/VocabularyBinary.cpp ) target_link_libraries(loop_fusion_node ${catkin_LIBRARIES} ${OpenCV_LIBS} ${CERES_LIBRARIES}) ``` -------------------------------- ### Run VINS-Fusion (Stereo Cameras Only) on EuRoC Dataset Source: https://github.com/hkust-aerial-robotics/vins-fusion/blob/master/README.md Launches RViz, the VINS-Fusion node with stereo cameras only configuration, and optionally the loop fusion node. It then plays the specified ROS bag file from the EuRoC dataset. ```bash roslaunch vins vins_rviz.launch rosrun vins vins_node ~/catkin_ws/src/VINS-Fusion/config/euroc/euroc_stereo_config.yaml (optional) rosrun loop_fusion loop_fusion_node ~/catkin_ws/src/VINS-Fusion/config/euroc/euroc_stereo_config.yaml rosbag play YOUR_DATASET_FOLDER/MH_01_easy.bag ``` -------------------------------- ### Create kitti_gps_test Executable Source: https://github.com/hkust-aerial-robotics/vins-fusion/blob/master/vins_estimator/CMakeLists.txt Creates an executable named 'kitti_gps_test' from 'src/KITTIGPSTest.cpp' and links it with 'vins_lib'. This is likely for testing GPS integration with KITTI dataset. ```cmake add_executable(kitti_gps_test src/KITTIGPSTest.cpp) target_link_libraries(kitti_gps_test vins_lib) ``` -------------------------------- ### CMake Build Configuration and Dependencies Source: https://github.com/hkust-aerial-robotics/vins-fusion/blob/master/loop_fusion/CMakeLists.txt Configures the CMake build environment, sets the build type to 'Release' with optimization flags, and finds essential packages including ROS components, OpenCV, Ceres, and Eigen. It also sets include directories for these dependencies. ```cmake cmake_minimum_required(VERSION 2.8.3) project(loop_fusion) set(CMAKE_BUILD_TYPE "Release") set(CMAKE_CXX_FLAGS "-std=c++11") #-DEIGEN_USE_MKL_ALL") set(CMAKE_CXX_FLAGS_RELEASE "-O3 -Wall -g") find_package(catkin REQUIRED COMPONENTS roscpp std_msgs nav_msgs camera_models cv_bridge roslib ) find_package(OpenCV) find_package(Ceres REQUIRED) set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) find_package(Eigen3) include_directories(${catkin_INCLUDE_DIRS} ${CERES_INCLUDE_DIRS} ${EIGEN3_INCLUDE_DIR}) ``` -------------------------------- ### Set Project Version Information (CMake) Source: https://github.com/hkust-aerial-robotics/vins-fusion/blob/master/global_fusion/ThirdParty/GeographicLib/CMakeLists.txt Defines major, minor, and patch versions for the project using CMake's set command. It constructs the full version string based on these components. ```cmake set (PROJECT_VERSION_MAJOR 1) set (PROJECT_VERSION_MINOR 49) set (PROJECT_VERSION_PATCH 0) set (PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}") if (PROJECT_VERSION_PATCH GREATER 0) set (PROJECT_VERSION "${PROJECT_VERSION}.${PROJECT_VERSION_PATCH}") endif () ``` -------------------------------- ### Create vins_node Executable Source: https://github.com/hkust-aerial-robotics/vins-fusion/blob/master/vins_estimator/CMakeLists.txt Creates an executable named 'vins_node' from the 'src/rosNodeTest.cpp' file and links it with the 'vins_lib'. This is likely the main ROS node for VINS-Fusion. ```cmake add_executable(vins_node src/rosNodeTest.cpp) target_link_libraries(vins_node vins_lib) ``` -------------------------------- ### Add Geographic Library (CMake) Source: https://github.com/hkust-aerial-robotics/vins-fusion/blob/master/global_fusion/ThirdParty/GeographicLib/CMakeLists.txt Adds the libGeographic library to the project using CMake. It specifies the source files for the library, including LocalCartesian.cpp, Geocentric.cpp, and Math.cpp, and includes header files from the ./include/ directory. ```cmake set (LIBNAME Geographic) include_directories( ./include/ ) add_library(libGeographiccc src/LocalCartesian.cpp src/Geocentric.cpp src/Math.cpp) ``` -------------------------------- ### Compile vins_lib Library Source: https://github.com/hkust-aerial-robotics/vins-fusion/blob/master/vins_estimator/CMakeLists.txt Compiles the main VINS-Fusion library ('vins_lib') from various C++ source files. It links against catkin libraries, OpenCV, and Ceres libraries. ```cmake add_library(vins_lib src/estimator/parameters.cpp src/estimator/estimator.cpp src/estimator/feature_manager.cpp src/factor/pose_local_parameterization.cpp src/factor/projectionTwoFrameOneCamFactor.cpp src/factor/projectionTwoFrameTwoCamFactor.cpp src/factor/projectionOneFrameTwoCamFactor.cpp src/factor/marginalization_factor.cpp src/utility/utility.cpp src/utility/visualization.cpp src/utility/CameraPoseVisualization.cpp src/initial/solve_5pts.cpp src/initial/initial_aligment.cpp src/initial/initial_sfm.cpp src/initial/initial_ex_rotation.cpp src/featureTracker/feature_tracker.cpp) target_link_libraries(vins_lib ${catkin_LIBRARIES} ${OpenCV_LIBS} ${CERES_LIBRARIES}) ``` -------------------------------- ### Run VINS-Fusion using Docker Script Source: https://github.com/hkust-aerial-robotics/vins-fusion/blob/master/README.md Executes VINS-Fusion using the run.sh script within the Docker environment. The script supports various configurations for Euroc and KITTI datasets, with options for loop fusion and GPS fusion. ```bash # Euroc Monocualr camera + IMU ./run.sh ~/catkin_ws/src/VINS-Fusion/config/euroc/euroc_mono_imu_config.yaml # Euroc Stereo cameras + IMU with loop fusion ./run.sh -l ~/catkin_ws/src/VINS-Fusion/config/euroc/euroc_mono_imu_config.yaml # KITTI Odometry (Stereo) ./run.sh -k ~/catkin_ws/src/VINS-Fusion/config/kitti_odom/kitti_config00-02.yaml YOUR_DATASET_FOLDER/sequences/00/ # KITTI Odometry (Stereo) with loop fusion ./run.sh -kl ~/catkin_ws/src/VINS-Fusion/config/kitti_odom/kitti_config00-02.yaml YOUR_DATASET_FOLDER/sequences/00/ # KITTI GPS Fusion (Stereo + GPS) ./run.sh -kg ~/catkin_ws/src/VINS-Fusion/config/kitti_raw/kitti_10_03_config.yaml YOUR_DATASET_FOLDER/2011_10_03_drive_0027_sync/ ``` -------------------------------- ### CMake Executable Target and Linking Source: https://github.com/hkust-aerial-robotics/vins-fusion/blob/master/global_fusion/CMakeLists.txt Defines the main executable 'global_fusion_node' by specifying its source files. It then links this executable against the required libraries, including catkin libraries, Ceres libraries, and the GeographicLib library. ```cmake add_executable(global_fusion_node src/globalOptNode.cpp src/globalOpt.cpp) target_link_libraries(global_fusion_node ${catkin_LIBRARIES} ${CERES_LIBRARIES} libGeographiccc) ``` -------------------------------- ### CMake Library Target: camera_models Source: https://github.com/hkust-aerial-robotics/vins-fusion/blob/master/camera_models/CMakeLists.txt This snippet defines the 'camera_models' library target and lists the source files that constitute this library. It includes implementations for various camera models and related utility functions. ```cmake add_library(camera_models src/chessboard/Chessboard.cc src/calib/CameraCalibration.cc src/camera_models/Camera.cc src/camera_models/CameraFactory.cc src/camera_models/CostFunctionFactory.cc src/camera_models/PinholeCamera.cc src/camera_models/PinholeFullCamera.cc src/camera_models/CataCamera.cc src/camera_models/EquidistantCamera.cc src/camera_models/ScaramuzzaCamera.cc src/sparse_graph/Transform.cc src/gpl/gpl.cc src/gpl/EigenQuaternionParameterization.cc) ``` -------------------------------- ### CMake Dependency Declaration (ROS and Ceres) Source: https://github.com/hkust-aerial-robotics/vins-fusion/blob/master/global_fusion/CMakeLists.txt Finds and includes necessary packages for the project. It requires the 'catkin' package with components 'roscpp', 'rospy', and 'std_msgs', and also requires the 'Ceres' solver library. ```cmake find_package(catkin REQUIRED COMPONENTS roscpp rospy std_msgs ) find_package(Ceres REQUIRED) ``` -------------------------------- ### CMake Third Party Subdirectory Inclusion Source: https://github.com/hkust-aerial-robotics/vins-fusion/blob/master/global_fusion/CMakeLists.txt Includes the GeographicLib library, which is expected to be present in the './ThirdParty/GeographicLib/' subdirectory. This allows CMake to process the build configuration for GeographicLib. ```cmake add_subdirectory(./ThirdParty/GeographicLib/) ``` -------------------------------- ### Camera Undistortion Interface (C++) Source: https://github.com/hkust-aerial-robotics/vins-fusion/blob/master/camera_models/readme.md Provides the general interface for camera models used in undistortion. Key functions include lifting points from the image plane to projective space (liftProjective) and projecting 3D points to the image plane (spaceToPlane). ```cpp class Camera { public: virtual ~Camera() {}; // Lift points from the image plane to the projective space. virtual void liftProjective(const Eigen::Vector2d& pfinance, Eigen::Vector3d& p3D) const = 0; // Projects 3D points to the image plane (Pi function). virtual void spaceToPlane(const Eigen::Vector3d& p3D, Eigen::Vector2d& pfinance) const = 0; protected: Camera(); }; ``` -------------------------------- ### Configure GeographicLib Precision (CMake) Source: https://github.com/hkust-aerial-robotics/vins-fusion/blob/master/global_fusion/ThirdParty/GeographicLib/CMakeLists.txt Sets the default precision for the GeographicLib library using CMake's CACHE STRING type. Users can choose precision from 1 (float) to 5 (variable). ```cmake cmake_minimum_required (VERSION 2.8.4) set (GEOGRAPHICLIB_PRECISION 2 CACHE STRING "Precision: 1 = float, 2 = double, 3 = extended, 4 = quadruple, 5 = variable") set_property (CACHE GEOGRAPHICLIB_PRECISION PROPERTY STRINGS 1 2 3 4 5) ``` -------------------------------- ### Calibrate Cameras with VINS-Fusion Source: https://github.com/hkust-aerial-robotics/vins-fusion/blob/master/README.md Calibrates cameras using the VINS-Fusion camera calibration tool. It supports multiple camera models and requires specifying calibration parameters such as width, height, square size, and input data directory. ```bash cd ~/catkin_ws/src/VINS-Fusion/camera_models/camera_calib_example/ rosrun camera_models Calibrations -w 12 -h 8 -s 80 -i calibrationdata --camera-model pinhole ``` -------------------------------- ### CMake Catkin Package Declaration Source: https://github.com/hkust-aerial-robotics/vins-fusion/blob/master/global_fusion/CMakeLists.txt Declares the current package as a catkin package, which is essential for ROS package management and build integration. ```cmake catkin_package() ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.