Giter Site home page Giter Site logo

arjunskumar / vins-fusion-gpu-tx2-nano Goto Github PK

View Code? Open in Web Editor NEW
67.0 2.0 19.0 1.44 MB

Installation step of vins-fusion gpu version on Nvidia Jetson TX2 & Nvidia Jetson Nano ( JP 4.2.2)

Home Page: https://arjunskumar.github.io/vins-fusion-gpu-tx2-nano/

Shell 100.00%
vins-fusion tx2-jetpack ros-melodic nvidia-jetson-nano jetson-nano nvidia-jetson-tx2

vins-fusion-gpu-tx2-nano's Introduction

vins-fusion-gpu-tx2-nano

Installation step of vins-fusion gpu version on Nvidia Jetson TX2 and Jetson Nano ( JP 4.2.2)

Prerequisites

Eigen

#  Remove pre-built Eigen

sudo apt-get remove libeigen3-dev 
cd ~/Downloads/
wget -O eigen.zip https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.zip #check version
unzip eigen.zip
mkdir eigen-build && cd eigen-build
cmake ../eigen-3.3.7/ && sudo make install
pkg-config --modversion eigen3 # Check Eigen Version

Eigen-img

Ceres solver

cd ~/Downloads/
sudo apt-get install -y cmake libgoogle-glog-dev libatlas-base-dev libsuitesparse-dev
wget http://ceres-solver.org/ceres-solver-1.14.0.tar.gz
tar zxf ceres-solver-1.14.0.tar.gz
mkdir ceres-bin
mkdir solver && cd ceres-bin
cmake ../ceres-solver-1.14.0 -DEXPORT_BUILD_DIR=ON -DCMAKE_INSTALL_PREFIX="../solver" 

  #good for build without being root privileged and at wanted directory
  
make -j3 # 6 : number of cores
make test
make install
bin/simple_bundle_adjuster ../ceres-solver-1.14.0/data/problem-16-22106-pre.txt # to check version

ceres-solver-img

Opencv

# remove prebuilt opencv
sudo apt-get purge libopencv* python-opencv 
sudo apt-get update
sudo apt-get install -y build-essential pkg-config

## libeigen3-dev # recommend to build from source

sudo apt-get install -y cmake libavcodec-dev libavformat-dev libavutil-dev \
    libglew-dev libgtk2.0-dev libgtk-3-dev libjpeg-dev libpng-dev libpostproc-dev \
    libswscale-dev libtbb-dev libtiff5-dev libv4l-dev libxvidcore-dev \
    libx264-dev qt5-default zlib1g-dev libgl1 libglvnd-dev pkg-config \
    libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev mesa-utils     

sudo apt-get install python2.7-dev python3-dev python-numpy python3-numpy
# To fix OpenGL related compilation problems 

cd /usr/lib/aarch64-linux-gnu/
sudo ln -sf libGL.so.1.0.0 libGL.so
sudo vim /usr/local/cuda/include/cuda_gl_interop.h

# Comment (line #62~68) of cuda_gl_interop.h 

//#if defined(__arm__) || defined(__aarch64__)
//#ifndef GL_VERSION
//#error Please include the appropriate gl headers before including cuda_gl_interop.h
//#endif
//#else
 #include <GL/gl.h>
//#endif
# Then once linking is done, go to Downloads to begin opencv installation
cd ~/Downloads/
wget -O opencv.zip https://github.com/opencv/opencv/archive/3.4.1.zip # check version
unzip opencv.zip
cd opencv-3.4.1/ && mkdir build && cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE \
        -D CMAKE_INSTALL_PREFIX=/usr/local \
        -D WITH_CUDA=ON \
        -D CUDA_ARCH_BIN=6.2 \
        -D CUDA_ARCH_PTX="" \
        -D ENABLE_FAST_MATH=ON \
        -D CUDA_FAST_MATH=ON \
        -D WITH_CUBLAS=ON \
        -D WITH_LIBV4L=ON \
        -D WITH_GSTREAMER=ON \
        -D WITH_GSTREAMER_0_10=OFF \
        -D WITH_QT=ON \
        -D WITH_OPENGL=ON \
        -D CUDA_NVCC_FLAGS="--expt-relaxed-constexpr" \
        -D WITH_TBB=ON \
         ../
make  # running in single core is good to resolve the compilation issues         
sudo make install
cd ../../ && sudo rm -rf opencv-3.4.1 # optional (can save 10GB Disk Space)
pkg-config --modversion opencv # Check opencv Version

opencv-img

ROS-Melodic

cd ~/Downloads/
git clone https://github.com/arjunskumar/vins-fusion-gpu-tx2.git
cd vins-fusion-gpu-tx2/
chmod a+x installROS.sh setupCatkinWorkspace.sh
./installROS.sh 
./setupCatkinWorkspace.sh

CV-Bridge

cd ~/catkin_ws/src && git clone https://github.com/ros-perception/vision_opencv
gedit vision_opencv/cv_bridge/CMakeLists.txt

# Edit OpenCV PATHS in CMakeLists and include cmake file

find_package(OpenCV 3 REQUIRED PATHS /usr/local/share/OpenCV NO_DEFAULT_PATH
  COMPONENTS
    opencv_core
    opencv_imgproc
    opencv_imgcodecs
  CONFIG
)
include(/usr/local/share/OpenCV/OpenCVConfig.cmake) #under catkin_python_setup()

# Save and close CMakeLists
#  Build the package

$ cd .. && catkin_make

Vins-Fusion GPU

cd ~/catkin_ws/src && git clone https://github.com/pjrambo/VINS-Fusion-gpu #GPU

sudo apt-get install ros-melodic-tf
sudo apt-get install ros-melodic-image-transport
sudo apt-get install ros-melodic-rviz

# Edit CMakeLists.txt for loop_fusion and vins_estimator
cd ~/catkin_ws/src/VINS-Fusion-gpu/loop_fusion && gedit CMakeLists.txt

##For loop_fusion : line 19
#find_package(OpenCV)
include(/usr/local/share/OpenCV/OpenCVConfig.cmake)

cd ~/catkin_ws/src/VINS-Fusion-gpu/vins_estimator && gedit CMakeLists.txt

##For vins_estimator : line 20
#find_package(OpenCV REQUIRED)
include(/usr/local/share/OpenCV/OpenCVConfig.cmake)

cd ~/catkin_ws/
source devel/setup.bash
catkin_make

Download car.bag to YOUR_DATASET_FOLDER. Open four terminals, run vins odometry, visual loop closure(optional), rviz and play the bag file respectively. Green path is VIO odometry, red path is odometry under visual loop closure.

roslaunch vins vins_rviz.launch
rosrun vins vins_node ~/catkin_ws/src/VINS-Fusion-gpu/config/vi_car/vi_car.yaml 
rosrun loop_fusion loop_fusion_node ~/catkin_ws/src/VINS-Fusion-gpu/config/vi_car/vi_car.yaml 
rosbag play YOUR_DATASET_FOLDER/car.bag

Jetson Nano

To Add Swap memory of 4GB

sudo fallocate -l 4G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo swapon --show
sudo cp /etc/fstab /etc/fstab.bak
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab 

To lock Jetson Nano at its maximum frequency and power mode by running the following commands:

sudo jetson_clocks
sudo nvpmodel -m 0 

Setup Realsense-d435i on Jetson Nano

# Clone and install RealSense SDK for Cuda

git clone https://github.com/jetsonhacksnano/installLibrealsense.git
cd installLibrealsense
./installLibrealsense.sh -c

# Build  Realsense SDK. Make sure camera is not connected to nano.

./buildLibrealsense.sh  [to built from source]

Realsense-SDK

# Connect the Realsense camera to the Nano
cd /usr/local/bin
./realsense-viewer

Relasense_viewer

Realsense-ROS

git clone https://github.com/JetsonHacksNano/installRealSenseROS.git 
./installRealSenseROS.sh <catkin_ws_name>

# Turns off the USB autosuspend setting on the Nano so that the camera is always available.

./setupNano.sh

Calibration Process

IMU calibration Steps

Calibration Process Overview

Calibration Process

Refer this document for IMU calibration

cd vins-fusion-gpu-tx2
sudo pip3 install pyrealsense2
python3 rs-imu-calibration.py

Calibration output

Camera-IMU calibration

cd catkin_ws/src/
sudo apt-get install libv4l-dev
git clone https://github.com/ethz-asl/kalibr
cd .. && catkin_make

vins-fusion-gpu-tx2-nano's People

Contributors

arjunskumar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

vins-fusion-gpu-tx2-nano's Issues

Time delay of track image

Hello, I compiled all steps successfully, unfortunately, I found the track image had more than a 10-second delay. Does this also happen on your Nano? The usage of all four CPUs reaches above 95%, but GPU is around 50%.

make test failed when compling ceres

I intalled eigen 3.3.7 and compiled ceres 1.14.0 but when I make test it printed the following message:

_99% tests passed, 1 tests failed out of 127

Total Test time (real) = 338.14 sec

The following tests FAILED:
30 - evaluation_callback_test (Failed)
Errors while running CTest
Makefile:85: recipe for target 'test' failed
make: *** [test] Error 8_

Do you know what's wrong? Thanks a lot

catkin_make error in cv_bridge building

When I try to build cv_bridge, I get this error :

desktop:~/catkin_ws$ catkin_make
Base path: /home/deep-drone/catkin_ws
Source space: /home/deep-drone/catkin_ws/src
Build space: /home/deep-drone/catkin_ws/build
Devel space: /home/deep-drone/catkin_ws/devel
Install space: /home/deep-drone/catkin_ws/install

Running command: "cmake /home/deep-drone/catkin_ws/src -DCATKIN_DEVEL_PREFIX=/home/deep-drone/catkin_ws/devel -DCMAKE_INSTALL_PREFIX=/home/deep-drone/catkin_ws/install -G Unix Makefiles" in "/home/deep-drone/catkin_ws/build"

-- Using CATKIN_DEVEL_PREFIX: /home/deep-drone/catkin_ws/devel
-- Using CMAKE_PREFIX_PATH: /opt/ros/melodic
-- This workspace overlays: /opt/ros/melodic
-- Found PythonInterp: /usr/bin/python2 (found suitable version "2.7.17", minimum required is "2")
-- Using PYTHON_EXECUTABLE: /usr/bin/python2
-- Using Debian Python package layout
-- Using empy: /usr/bin/empy
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /home/deep-drone/catkin_ws/build/test_results
-- Found gtest sources under '/usr/src/googletest': gtests will be built
-- Found gmock sources under '/usr/src/googletest': gmock will be built
-- Found PythonInterp: /usr/bin/python2 (found version "2.7.17")
-- Using Python nosetests: /usr/bin/nosetests-2.7
-- catkin 0.7.29
-- BUILD_SHARED_LIBS is on
-- BUILD_SHARED_LIBS is on
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- ~~ traversing 4 packages in topological order:
-- ~~ - opencv_tests
-- ~~ - vision_opencv (metapackage)
-- ~~ - cv_bridge
-- ~~ - image_geometry
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- +++ processing catkin package: 'opencv_tests'
-- ==> add_subdirectory(vision_opencv/opencv_tests)
-- +++ processing catkin metapackage: 'vision_opencv'
-- ==> add_subdirectory(vision_opencv/vision_opencv)
-- +++ processing catkin package: 'cv_bridge'
-- ==> add_subdirectory(vision_opencv/cv_bridge)
-- Found PythonLibs: /usr/lin/x86_64-linux-gnu/libpython2.7.so (found version "2.7.17")
CMake Warning at /usr/share/cmake-3.10/Modules/FindBoost.cmake:1626 (message):
No header defined for python37; skipping header check
Call Stack (most recent call first):
vision_opencv/cv_bridge/CMakeLists.txt:13 (find_package)

-- Boost version: 1.65.1
-- Found the following Boost libraries:
-- python37
-- Found OpenCV: /usr/local (found suitable version "3.4.1", minimum required is "3") found components: opencv_core opencv_imgproc opencv_imgcodecs
-- Found OpenCV: /usr/local (found version "3.4.1") found components: opencv_calib3d opencv_core opencv_cudaarithm opencv_cudabgsegm opencv_cudacodec opencv_cudafeatures2d opencv_cudafilters opencv_cudaimgproc opencv_cudalegacy opencv_cudaobjdetect opencv_cudaoptflow opencv_cudastereo opencv_cudawarping opencv_cudev opencv_dnn opencv_features2d opencv_flann opencv_highgui opencv_imgcodecs opencv_imgproc opencv_ml opencv_objdetect opencv_photo opencv_shape opencv_stitching opencv_superres opencv_video opencv_videoio opencv_videostab
-- Found PythonLibs: /usr/lin/x86_64-linux-gnu/libpython2.7.so (found suitable version "2.7.17", minimum required is "2.7")
-- +++ processing catkin package: 'image_geometry'
-- ==> add_subdirectory(vision_opencv/image_geometry)
-- Found OpenCV: /usr/local (found version "3.4.1")
-- Configuring done
-- Generating done
-- Build files have been written to: /home/deep-drone/catkin_ws/build

Running command: "make -j4 -l4" in "/home/deep-drone/catkin_ws/build"

[ 0%] Built target geometry_msgs_generate_messages_lisp
[ 0%] Built target sensor_msgs_generate_messages_py
[ 0%] Built target sensor_msgs_generate_messages_lisp
[ 0%] Built target sensor_msgs_generate_messages_nodejs
[ 0%] Built target geometry_msgs_generate_messages_eus
[ 0%] Built target std_msgs_generate_messages_py
[ 0%] Built target geometry_msgs_generate_messages_cpp
[ 0%] Built target std_msgs_generate_messages_eus
[ 0%] Built target std_msgs_generate_messages_cpp
[ 0%] Built target geometry_msgs_generate_messages_nodejs
[ 0%] Built target geometry_msgs_generate_messages_py
[ 0%] Built target sensor_msgs_generate_messages_cpp
[ 0%] Built target std_msgs_generate_messages_lisp
[ 0%] Built target std_msgs_generate_messages_nodejs
[ 0%] Built target sensor_msgs_generate_messages_eus
[ 33%] Built target image_geometry
[ 66%] Built target cv_bridge
make[2]: *** No rule to make target '/usr/lin/x86_64-linux-gnu/libpython2.7.so', needed by '/home/deep-drone/catkin_ws/devel/lib/python2.7/dist-packages/cv_bridge/boost/cv_bridge_boost.so'. Stop.
make[2]: *** Waiting for unfinished jobs....
[ 77%] Building CXX object vision_opencv/cv_bridge/src/CMakeFiles/cv_bridge_boost.dir/module_opencv4.cpp.o
[ 88%] Building CXX object vision_opencv/cv_bridge/src/CMakeFiles/cv_bridge_boost.dir/module.cpp.o
In file included from /usr/include/python2.7/numpy/ndarrayobject.h:27:0,
from /home/deep-drone/catkin_ws/src/vision_opencv/cv_bridge/src/module.hpp:26,
from /home/deep-drone/catkin_ws/src/vision_opencv/cv_bridge/src/module_opencv4.cpp:3:
/home/deep-drone/catkin_ws/src/vision_opencv/cv_bridge/src/module.hpp: In function ‘void* do_numpy_import()’:
/usr/include/python2.7/numpy/__multiarray_api.h:1537:144: error: return-statement with no value, in function returning ‘void*’ [-fpermissive]
#define import_array() {if (_import_array() < 0) {PyErr_Print(); PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import"); return NUMPY_IMPORT_ARRAY_RETVAL; } }
^
/usr/include/python2.7/numpy/__multiarray_api.h:1537:144: note: in definition of macro ‘import_array’
#define import_array() {if (_import_array() < 0) {PyErr_Print(); PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import"); return NUMPY_IMPORT_ARRAY_RETVAL; } }
^~~~~~
In file included from /usr/include/python2.7/numpy/ndarrayobject.h:27:0,
from /home/deep-drone/catkin_ws/src/vision_opencv/cv_bridge/src/module.hpp:26,
from /home/deep-drone/catkin_ws/src/vision_opencv/cv_bridge/src/module.cpp:35:
/home/deep-drone/catkin_ws/src/vision_opencv/cv_bridge/src/module.hpp: In function ‘void* do_numpy_import()’:
/usr/include/python2.7/numpy/__multiarray_api.h:1537:144: error: return-statement with no value, in function returning ‘void*’ [-fpermissive]
PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import"); return NUMPY_IMPORT_ARRAY_RETVAL; } }
^
/usr/include/python2.7/numpy/__multiarray_api.h:1537:144: note: in definition of macro ‘import_array’
PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import"); return NUMPY_IMPORT_ARRAY_RETVAL; } }
^~~~~~
vision_opencv/cv_bridge/src/CMakeFiles/cv_bridge_boost.dir/build.make:86: recipe for target 'vision_opencv/cv_bridge/src/CMakeFiles/cv_bridge_boost.dir/module_opencv4.cpp.o' failed
make[2]: *** [vision_opencv/cv_bridge/src/CMakeFiles/cv_bridge_boost.dir/module_opencv4.cpp.o] Error 1
vision_opencv/cv_bridge/src/CMakeFiles/cv_bridge_boost.dir/build.make:62: recipe for target 'vision_opencv/cv_bridge/src/CMakeFiles/cv_bridge_boost.dir/module.cpp.o' failed
make[2]: *** [vision_opencv/cv_bridge/src/CMakeFiles/cv_bridge_boost.dir/module.cpp.o] Error 1
CMakeFiles/Makefile2:1040: recipe for target 'vision_opencv/cv_bridge/src/CMakeFiles/cv_bridge_boost.dir/all' failed
make[1]: *** [vision_opencv/cv_bridge/src/CMakeFiles/cv_bridge_boost.dir/all] Error 2
Makefile:140: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j4 -l4" failed

What should I do to solve this problem?

branch of vision_opencv

another suggestion is to add -b melodic to the git clone of vision_opencv since the current default branch is noetic which causes some compilation issues

eigen link broken in readme

thanks for this great repo. i'm just getting started with it, but so far i see that the link to eigen was broken (moved to gitlab). the following two lines in the readme could be updated to reflect this change:

  • change wget -O eigen.zip http://bitbucket.org/eigen/eigen/get/3.3.7.zip to wget -O eigen.zip https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.zip
  • unzip eigen.zip -d eigen-3.3.7 to unzip eigen.zip

Aborted (camera dumped )

Hi @arjunskumar i followed all your steps when i am running it on D435i i am getting error

nord@enord:~$ rosrun vins vins_node /home/enord/catkin_ws/src/VINS-Fusion-gpu/config/realsense_d435i/realsense_stereo_imu_config.yaml
[ INFO] [1636006477.961505531]: init begins
config_file: /home/enord/catkin_ws/src/VINS-Fusion-gpu/config/realsense_d435i/realsense_stereo_imu_config.yaml
USE_IMU: 1
IMU_TOPIC: /camera/imu
result path /home/enord/output//vio.csv
[ WARN] [1636006478.010063908]: Optimize extrinsic param around initial guess!
camera number 2
[ INFO] [1636006478.021052687]: Unsynchronized sensors, online estimate time offset, initial td: 0
[ INFO] [1636006478.021248912]: ROW: 480 COL: 640
exitrinsic cam 0
-0.00575863 -0.00404633 0.999975
-0.999983 -0.00102246 -0.00576281
0.00104575 -0.999991 -0.00404037
0.0203293 0.00793252 0.00285598
exitrinsic cam 1
-0.00100218 0.000363135 0.999999
-0.999992 -0.00383034 -0.00100078
0.00382998 -0.999993 0.000366971
0.0152858 -0.0524358 0.00869313
set g 0 0 9.805
[ INFO] [1636006478.025506381]: reading paramerter of camera /home/enord/catkin_ws/src/VINS-Fusion-gpu/config/realsense_d435i/left.yaml
OpenCV(3.4.1) Error: Unknown error code -49 (Input file is empty) in cvOpenFileStorage, file /home/enord/opencv-3.4.1/modules/core/src/persistence_c.cpp, line 384
terminate called after throwing an instance of 'cv::Exception'
what(): OpenCV(3.4.1) /home/enord/opencv-3.4.1/modules/core/src/persistence_c.cpp:384: error: (-49) Input file is empty in function cvOpenFileStorage

Aborted (core dumped)

as you already run it on d435i thankuh

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.