Jetson AGX ORIN配置运行vins-fusion-gpu(Zed/D435)

1.配置Jetpack

通过配置jetpack可以完成对cuda,cudann,TensorRT等基本环境的配置

官网教程Getting Started with Jetson AGX Orin Developer Kit
https://developer.nvidia.com/embedded/learn/get-started-jetson-agx-orin-devkit

sudo apt upgrade
sudo apt update
sudo apt dist-upgrade #!!!不要更新硬件
sudo reboot
sudo apt install nvidia-jetpack

sudo apt dist-upgrade这句,可以执行or不执行,我执行的很慢然后强制中断后,Jetson就开不了机了,后来是找厂家重新刷机才解决的…

为什么要刷机?因为jetson与普通ubuntu重装系统的方法不一样,他通过刷机让Jetson安装上Ubuntu20.04系统和各类自带的组件,刷机教程:https://blog.csdn.net/weixin_53776054/article/details/128552701

2.配置ROS & mavros

Jetson AGX ORIN的出厂设置为Ubuntu20,因此需要配置相应的Neotic的ros版本

1)配置基本ros环境

  • 配置ROS软件源
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu focal main" > /etc/apt/sources.list.d/ros-latest.list'
  • 添加ROS秘钥
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
  • 安装ROS
sudo apt update
sudo apt install ros-noetic-desktop
  • 配置ROS的运行环境
echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc
source ~/.bashrc

2)创建ros工作空间

  • 创建ROS工作空间
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws
catkin_make
  • 设置ROS环境
source ~/catkin_ws/devel/setup.bash

3)配置mavros

sudo apt-get install ros-noetic-mavros ros-noetic-mavros-extras ros-noetic-control-toolbox
cd /opt/ros/kinetic/lib/mavros
sudo ./install_geographiclib_datasets.sh

报错FCU: DeviceError:serial:open: Permission denied解决方法参考
给设备串口添加用户组权限即可sudo chmod 777 /dev/ttyACM0

3.配置VINS-FUSION-GPU

vins-fusion-gpu链接:https://github.com/pjrambo/VINS-Fusion-gpu

官方vins-fusion-gpu已经在ubuntu18和opencv3.4上进行了测试,迁移到ubuntu20和opencv4需要进行一定修改

卸载原来的ceres命令,cd到build文件夹

sudo make uninstall

1)安装Ceres

注意下载Ceres1.14.0版本 ,Ceres2.1.0亲测失败

  • 安装依赖
sudo apt-get install cmake
sudo apt-get install libgoogle-glog-dev libgflags-dev
sudo apt-get install libatlas-base-dev
sudo apt-get install libeigen3-dev
sudo apt-get install libsuitesparse-dev
  • 源码编译安装Ceres
#下载安装包
wget ceres-solver.org/ceres-solver-1.14.0.tar.gz
#解压安装包
tar -xvf ceres-solver-1.14.0.tar.gz

cd ceres-solver-1.14.0
mkdir build
cd build
cmake ..
sudo make 
sudo make test
sudo make install

2)安装Vins-Fusion-gpu

网上有关资料很少,可以参考ubuntu20配置普通版本的vins

  • 下载源码
cd ~/catkin_ws/src
git clone https://github.com/pjrambo/VINS-Fusion-gpu
  • 添加头文件
在camera_model包中的头文件Chessboard.h中添加
#include 
#include 
在CameraCalibration.h中添加
#include 
#include 
  • 修改opencv3的写法到opencv4

【这里建议用vscode批量修改,vscode请下载arm64.deb版本】

在文件中搜索CV_FONT_HERSHEY_SIMPLEX并替换成cv::FONT_HERSHEY_SIMPLEX

在文件中搜索CV_BGR2GRAY并替换成cv::COLOR_BGR2GRAY

在文件中搜索CV_GRAY2BGR并替换成cv::COLOR_GRAY2BGR

在文件中搜索CV_RGB2GRAY并替换成cv::COLOR_RGB2GRAY

在文件中搜索CV_GRAY2RGB并替换成cv::COLOR_GRAY2RGB

在文件中搜索CV_LOAD_IMAGE_GRAYSCALE并替换成cv::IMREAD_GRAYSCALE

在文件中搜索CV_FONT_HERSHEY_SIMPLEX并替换成cv::FONT_HERSHEY_SIMPLEX

  • 编译
cd catkin_ws
cakin_make

4.D435i相机配置

需要先配置realsense的SDK,再配置reslsense-ros

  • 配置realsense SDK

【方法一】失败

#注册服务器的公钥
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key F6E65AC044F831AC80A06380C8B3A55A6F3EFCDE
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-key F6E65AC044F831AC80A06380C8B3A55A6F3EFCDE
#将服务器添加到存储库列表
sudo add-apt-repository "deb https://librealsense.intel.com/Debian/apt-repo $(lsb_release -cs) main" -u
#安装库(如果升级包,请参阅下面的部分)
sudo apt-get install librealsense2-dkms
sudo apt-get install librealsense2-utils
#可选择安装开发人员和调试包
sudo apt-get install librealsense2-dev
sudo apt-get install librealsense2-dbg

【方法二】成功

#1)下载源码
git clone -b v2.51.1 https://github.com/IntelRealSense/librealsense.git 
#2)安装依赖包
sudo apt-get install libudev-dev pkg-config libgtk-3-dev
sudo apt-get install libusb-1.0-0-dev pkg-config
sudo apt-get install libglfw3-dev
sudo apt-get install libssl-dev
#3)安装权限脚本
cd librealsense
sudo cp config/99-realsense-libusb.rules /etc/udev/rules.d/
sudo udevadm control --reload-rules && udevadm trigger 
#4)编译
mkdir build
cd build
cmake ../ -DBUILD_EXAMPLES=true
make
sudo make install
#5)使用
realsense-viewer
  • 配置realsense-ros

源码配置,记得切换到ros1分支
https://github.com/IntelRealSense/realsense-ros/tree/ros1-legacy

直接apt-get安装

sudo apt-get install ros-$ROS_DISTRO-realsense2-camera
sudo apt-get install ros-$ROS_DISTRO-realsense2-description
tju@tju-desktop:~$ rospack find realsense2_camera
/opt/ros/noetic/share/realsense2_camera

5.vins运行测试

仿真测试参考:https://www.yuque.com/xtdrone/manual_cn/vio
实际测试参考:https://blog.csdn.net/qq_42800654/article/details/109393646

报错outofmemoryerror解决方法

数据集测试

roslaunch vins vins_rviz.launch
rosrun vins vins_node ~/catkin_ws/src/VINS_Lite_GPU/config/euroc/euroc_stereo_imu_config.yaml
rosbag play ~/Downloads/MH_01_easy.bag

d435i相机测试

roslaunch realsense2_camera rs_camera_vins.launch  initial_reset:=true 
rosrun vins vins_node ~/catkin_ws/src/VINS_Lite_GPU/config/realsense_d435i/realsense_stereo_imu_config.yaml

查看位姿

rostopic echo /vins_estimator/odometry
rosbag record /camera/imu /camera/infra1/image_rect_raw /camera/infra2/image_rect_raw

6.Zed相机配置

  • 查看jetpack版本,我的jetpack版本为5.1.1
sudo apt-cache show nvidia-jetpack
  • 查看cuda版本,我的cuda版本为11.4
dpkg -l | grep cuda
  • 下载相应版本SDK

SDK:https://www.stereolabs.com/developers/release/对应版本的ZED-SDK【ZED SDK for JetPack 5.1 (L4T 35.2)4.0 (Jetson Xavier, Orin AGX/NX 16GB, CUDA 11.4)】

  • 安装测试
#安装
chomd +x xxxx.run
./xxxx.run

#测试
./ZED_Explore

学习资料:https://www.stereolabs.com/docs/get-started-with-zed/

你可能感兴趣的:(ubuntu,linux,运维)