赞
踩
我们使用阿木实验室的板载电脑allspark2(arm Orin-NX架构)+Pixhawk6C实机飞行测试ego-planner,文章尾部附arm QGC安装教程 && arm机载电脑与Pixhawk6c组合下提高飞控imu频率的方法。
【鸣谢】感谢阿木实验室支持
【重要】先释放所有性能,这样编译会更快,可以在系统右上角选择0:MAXN,如下图所示,编译时候8个核都拉满了。
sudo apt-get update
sudo apt-get install python3-pip
sudo pip3 install -U jetson-stats
jetson_release
如果CUDA已经安装,检查一下版本是否对应。
sudo apt-get install cuda-11-4
sudo apt-get install libcudnn8
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 vim /usr/local/cuda/include/cuda_gl_interop.h
注释cuda_gl_interop.h 62~68行的下列部分,保留有颜色部分
//#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
可以安装在Home文件夹下
cd ~/Home
git clone http://github.com/ZJU-FAST-Lab/Fast-Drone-250
如果git很慢,可以自行科学下载该程序包
以下步骤在~/Download文件夹下执行即可,如果Opencv遇到编译问题,提示在该文件夹下无法编译,可以将其整体移动至Home文件夹即可解决。
cd ~/Downloads
sudo apt-get purge libopencv*
sudo apt autoremove
sudo apt-get update
【此方法可能会误删一些ROS rqt之类的文件,建议后面鱼香ROS重新补充安装一下】
cd ~/Downloads/opencv-3.4.18 mkdir build && cd build cmake -D CMAKE_BUILD_TYPE=RELEASE \ -D CMAKE_INSTALL_PREFIX=/usr/local \ -D WITH_CUDA=ON \ -D CUDA_ARCH_BIN=7.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 -j8 sudo make install
到此编译成功,然后如果不出意外,可以查到OpenCV with CUDA
jetson_release
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 # 检查 Eigen 版本,判断是否安装成功
cd ~/Fast-Drone-250
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
// 进入glog文件夹打开终端
sudo chmod +x ./autogen.sh ./configure
./autogen.sh && ./configure && make && sudo make install
sudo apt-get install liblapack-dev libsuitesparse-dev libcxsparse3 libgflags-dev libgoogle-glog-dev libgtest-dev
// 进入ceres文件夹打开终端
mkdir build
cd build
cmake ..
sudo make -j4
sudo make install
sudo apt-get install ros-noetic-ddynamic-reconfigure
wget http://fishros.com/install -O fishros && . fishros
系统资源:安装中需要更换系统资源就换,不需要就不换
根据自己需求选择具体的版本,记得一定是(ROS1)桌面版,选择安装完整的ROS
cd /opt/ros/noetic/share/cv_bridge/cmake
sudo gedit cv_bridgeConfig.cmake
修改line 94-118,直接复制覆盖!
#if(NOT "include;/usr/include/opencv4 " STREQUAL " ") # set(cv_bridge_INCLUDE_DIRS "") # set(_include_dirs "include;/usr/include/opencv4") set(libraries "cv_bridge;/usr/local/lib/libopencv_core.so.3.4.18;/usr/local/lib/libopencv_imgproc.so.3.4.18;/usr/local/lib/libopencv_imgcodecs.so.3.4.18") if(NOT "https://github.com/ros-perception/vision_opencv/issues " STREQUAL " ") set(_report "Check the issue tracker 'https://github.com/ros-perception/vision_opencv/issues' and consider creating a ticket if the problem has not been reported yet.") elseif(NOT "http://www.ros.org/wiki/cv_bridge " STREQUAL " ") set(_report "Check the website 'http://www.ros.org/wiki/cv_bridge' for information and consider reporting the problem.") else() set(_report "Report the problem to the maintainer 'Vincent Rabaud <vincent.rabaud@gmail.com>' and request to fix the problem.") endif() foreach(idir ${_include_dirs}) if(IS_ABSOLUTE ${idir} AND IS_DIRECTORY ${idir}) set(include ${idir}) elseif("${idir} " STREQUAL "include ") get_filename_component(include "${cv_bridge_DIR}/../../../include" ABSOLUTE) if(NOT IS_DIRECTORY ${include}) message(FATAL_ERROR "Project 'cv_bridge' specifies '${idir}' as an include dir, which is not found. It does not exist in '${include}'. ${_report}") endif() else() message(FATAL_ERROR "Project 'cv_bridge' specifies '${idir}' as an include dir, which is not found. It does neither exist as an absolute directory nor in '\${prefix}/${idir}'. ${_report}") endif() _list_append_unique(cv_bridge_INCLUDE_DIRS ${include}) endforeach() #endif()
sudo apt-get install ros-noetic-mavros
cd /opt/ros/noetic/lib/mavros
sudo ./install_geographiclib_datasets.sh
roscd mavros
cd launch
sudo gedit px4.launch
cd ~/Fast-Drone-250/src/realflight_modules
mkdir -p vins_gpu/src
cd vins_gpu/src
git clone https://github.com/pjrambo/VINS-Fusion-gpu.git
//如果git很慢,建议自行下载安装包解压到vins_gpu/src目录
需要更改vins_estimator/CMakeLists.txt和 loop_fusion/CMakeLists.txt文件,大概20行左右。需要把OpenCV路径改成你自己的路径
#include(/home/amov/opencv-3.4.18/build/OpenCVConfig.cmake)
include(/usr/local/share/OpenCV/OpenCVConfig.cmake)
#message(WARNING "OpenCV_VERSION: ${OpenCV_VERSION}")
改成下面这样:
还需要将四个功能包camera_models、global_fusion、loop_fusion、vins_estimator中catkin_include ros自带的opencv链接去掉,即在四个cmakelist中的catkin_package( )后面加入去除你的系统之前本身含有的旧的 OpenCV库的参数
,我的系统之前安装的是OpenCV4.2.0
list(REMOVE_ITEM catkin_LIBRARIES "/usr/lib/aarch64-linux-gnu/libopencv_core.so.4.2.0")
list(REMOVE_ITEM catkin_LIBRARIES "/usr/lib/aarch64-linux-gnu/libopencv_imgproc.so.4.2.0")
list(REMOVE_ITEM catkin_LIBRARIES "/usr/lib/aarch64-linux-gnu/libopencv_imgcodecs.so.4.2.0")
如下图:
然后将VINS-Fusion/vins_estimator/launch/fast_drone_250.launch文件复制到vins_gpu对应的目录里面
line 8-9
set(ENABLE_CUDA false)
修改为
set(ENABLE_CUDA true)
下面这个需要根据你的CUDA的版本去选参数,我是11.4,详情见https://arnon.dk/matching-sm-architectures-arch-and-gencode-for-various-nvidia-cards/
set(CUDA_NVCC_FLAGS
# -gencode arch=compute_xx,code=sm_xx;
-gencode arch=compute_87,code=sm_87;
)
如下图所示
然后delete VINS-FUSION and 开始编译
cd ~/Fast-Drone-250
catkin_make
编译时候请释放所有性能,可以在系统右上角选择0:MAXN,如下图所示,编译的时候8个核都拉满了。
【重要】请检查自己的~/.bashrc文件,关闭其他的连接方式,比如我这边无人机需要注释之前做动捕实验的参数。
sudo gedit ~/.bashrc
一切没问题后,source一下,进行仿真实验,如果不能规划路径,可能是因为你localsensing文件里面的cmakelists
里面的参数没有改对,gencode arch=compute_87,code=sm_87;
后面的数字需要对应你的CUDA版本
source devel/setup.bash
roslaunch ego_planner single_run_in_sim.launch
在Rviz内按下键盘G键,再单击鼠标左键以点选无人机目标点
如果没有含有realsense驱动,可以按照以下命令安装:
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
realsense-viewer
sudo apt install terminator
sudo apt install openssh-server
sudo apt install ros-noetic-plotjuggler
sudo apt install ros-noetic-plotjuggler-ros
sudo apt install net-tools
ifconfig
ls /dev/tty*
,确认飞控的串口连接正常。/dev/ttyACM0
,串口连接的方式对应的为/dev/ttyTHS0
,sudo chmod 777 /dev/ttyTHS0
,为飞控使用附加权限后才能执行px4.launch文件roslaunch mavros px4.launch
rostopic hz /mavros/imu/data_raw
基础的hz频率一定为60hz,下一步VINS外参标定的话,需要飞控imu频率在200hz左右,所以就需要用提高频率的方法。
【重要】ARM开发板无法使用以下神秘代码去提高频率,X86是可以的~
rosrun mavros mavcmd long 511 105 5000 0 0 0 0 0 & sleep 1;
rosrun mavros mavcmd long 511 31 5000 0 0 0 0 0 & sleep 1;
但是ARM板子可以用以下方法来提高频率:
在飞控的sd卡的根目录下创建/etc/extras.txt
,写入
mavlink stream -d /dev/ttyS3 -s ATTITUDE_QUATERNION -r 200
mavlink stream -d /dev/ttyS3 -s HIGHRES_IMU -r 200
为什么是S3,因为飞控输出的串口TELEM2对应的接口为S1/2/3中间的一个,输出的接口为ttyS3,在机载电脑的串口识别的为ttyTHS0
sh shfiles/rspx4.sh
rostopic echo /vins_fusion/imu_propagate
拿起飞机沿着场地尽量缓慢地行走,场地内光照变化不要太大,灯光不要太暗,不要使用会频闪的光源,尽量多放些杂物来增加VINS用于匹配的特征点,把 vins_output/extrinsic_parameter.txt 里的内容替换到 fast-drone-250.yaml 的
body_T_cam0 和 body_T_cam1
重复上述操作直到走几圈后VINS的里程计数据偏差收敛到满意值(一般在0.3米内)
sh shfiles/rspx4.sh
roslaunch ego_planner single_run_in_exp.launch
roslaunch ego_planner rviz.launch
自动起飞
roslaunch ego-planner single_run_in_exp.launch
sh shfiles/record.sh
roslaunch ego_planner rviz.launch
按下G键加鼠标左键点选目标点使无人机飞行
【未完待续,图片没加完】
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。