Jetson TX2 NX(Ubuntu 18.04) + ROS melodic + turtlebot功能包 + realsense d455 + ORB-SLAM2

Jetson TX2 NX(Ubuntu 18.04) + ROS melodic + turtlebot功能包 + realsense d455 + ORB-SLAM2

1. 安装ROS melodic

更换中科大源

$ sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.ustc.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'

设置key

$ sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654

更新软件源

sudo apt-get update

安装ROS桌面完整版

sudo apt-get install ros-melodic-desktop-full

初始化并更新

sudo apt-get install python3-pip 
sudo pip3 install rosdepc
sudo rosdepc init
rosdepc update

在sudo pip3 install rosdepc时遇到错误

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-Xe8VLqC7-1684312007284)(C:\Users\chenl\AppData\Roaming\Typora\typora-user-images\image-20230510182544491.png)]

或为pip、pip3版本太旧导致的问题,升级即可。

2. 在Ubuntu18.04 下安装turtlebot功能包

安装依赖

$ sudo apt-get install ros-melodic-kobuki-*
$ sudo apt-get install ros-melodic-ecl-streams
$ sudo apt-get install libusb-dev
$ sudo apt-get install libspnav-dev
$ sudo apt-get install ros-melodic-joystick-drivers
$ sudo apt-get install bluetooth
$ sudo apt-get install libbluetooth-dev
$ sudo apt-get install libcwiid-dev
$ sudo apt-get install ros-melodic-bfl

新建工作目录,准备相关包

$ mkdir -p ~/turtlebot_ws/src 
$ cd ~/turtlebot_ws/src 

$ git clone https://github.com/turtlebot/turtlebot_simulator
$ git clone https://github.com/turtlebot/turtlebot.git
$ git clone https://github.com/turtlebot/turtlebot_apps.git
$ git clone https://github.com/udacity/robot_pose_ekf
$ git clone https://github.com/ros-perception/depthimage_to_laserscan.git 
$ git clone https://github.com/yujinrobot/kobuki_msgs.git
$ git clone https://github.com/yujinrobot/kobuki_desktop.git
$ cd kobuki_desktop/
$ rm -r kobuki_qtestsuite
$ cd ~/turtlebot_ws/src 
$ git clone https://ghproxy.com/https://github.com/toeklk/orocos-bayesian-filtering.git
$ git clone https://ghproxy.com/https://github.com/turtlebot/turtlebot_msgs.git
$ git clone https://ghproxy.com/https://github.com/ros-drivers/joystick_drivers.git

若连接失败,在网站前加上

http://ghproxy.com/

复制依赖库到工作空间下

$ mkdir -p ~/repos/
$ cd ~/repos/
$ git clone https://ghproxy.com/https://github.com/yujinrobot/kobuki.git
$ cp -r kobuki/* ~/turtlebot_ws/src/
$ git clone https://ghproxy.com/https://github.com/yujinrobot/yujin_ocs.git
$ cp -r yujin_ocs/yocs_cmd_vel_mux/ yujin_ocs/yocs_controllers ~/turtlebot_ws/src/

编译工作空间

$ cd ~/turtlebot_ws
$ catkin_make

编译时遇到错误,找不到opencv

由于turtlebot功能包默认使用opencv版本为3.2.0,但是Jetson TX2 的opencv版本为4.1。

Jetson在刷入系统和SDK manager时只能选择4.1版本的opencv。因为安装ROS melodic时附带3.2 版本的opencv,所以我还尝试过刷系统时不刷入SDK,但是装完ROS发现opencv版本还是4.1,于是放弃挣扎。

解决方法:建立软连接

$ cd usr/local/include
$ sudo ln -s opencv4/ opencv  

再重新catkin_make,通过。

添加工作空间到bashrc文件

$ echo "source ~/turtlebot_ws/devel/setup.bash" >> ~/.bashrc
$ source ~/.bashrc

测试

$ roslaunch turtlebot_bringup minimal.launch

3. 安装Realsense SDK 和 realsense-ros

3.1 安装realsense SDK

安装依赖
$ 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

遇到错误:安装libgtk-3-dev,未满足的依赖项。

直接忽略,不要管,并不会影响后续包的安装,我把依赖项降级了,降级了两层依赖之后无法开机了,只能重新刷机,浪费了很多时间。

进入github网站下载源码

网址:https://github.com/IntelRealSense/librealsense/

$ mkdir build && cd build
$ cmake
$ make -j4
$ sudo make install
测试
$ realsense-viewer

3.2 安装ddynamic_reconfigure

$ sudo apt-get install ros-melodic-ddynamic-reconfigure

3.3 安装realsense-ros

创建工作空间

$ mkdir -p ~/catkin_ws/src
$ cd ~/catkin_ws/src/

从github上下载realsense-ros并编译,访问github中realsense-ros,并查找历史版本

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-kpl895el-1684312007285)(C:\Users\chenl\AppData\Roaming\Typora\typora-user-images\image-20230517155442347.png)]

下载后放到src/文件夹中

初始化工作空间并编译安装(依据官网教程)

$ catkin_init_workspace
$ cd ~/catkin_ws
$ catkin_make clean
$ catkin_make -DCATKIN_ENABLE_TESTING=False -DCMAKE_BUILD_TYPE=Release
$ catkin_make install

添加工作路径到~/.bashrc

$ echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc
$ source ~/.bashrc

测试使用

$ roslaunch realsense2_camera rs_camera.launch

可以打开rostopic查看发布的话题

Jetson TX2 NX(Ubuntu 18.04) + ROS melodic + turtlebot功能包 + realsense d455 + ORB-SLAM2_第1张图片

4. 安装ORB-SLAM2

4.1 安装Pangolin0.6版本

安装依赖项

sudo apt-get install libglew-dev libboost-dev libboost-thread-dev libboost-filesystem-dev
sudo apt-get install ffmpeg libavcodec-dev libavutil-dev libavformat-dev libswscale-dev libpng-dev

编译并配置

cd Pangolin 
mkdir build && cd build
cmake -DCPP11_NO_BOOST=1 ..
make
sudo make install

4.2 安装Eigen

选择版本3.10.2,在网页上直接能搜索下载

cd eigen3
mkdir build
cd build
cmake ..
make
sudo make install

移动头文件

sudo cp -r /usr/local/include/eigen3/Eigen /usr/local/include

4.3 安装ORB-SLAM2

直接把ORB-SLAM2源码放在catkin_ws/src目录下

cd ORB_SLAM2
chmod +x build.sh build_ros.sh
./build.sh
./build_ros.sh

编译时如果遇到错误

error: ’usleep’ was not declared in this scope

在对应文件上加上

#include 

由于使用的是opencv4.1.1而非opencv3.2.0

遇到版本不兼容的问题

错误1:找不到opencv,OpenCV > 2.4.3 not found
Jetson TX2 NX(Ubuntu 18.04) + ROS melodic + turtlebot功能包 + realsense d455 + ORB-SLAM2_第2张图片

解决:修改cmakelist.txt, 将 opencv 3.0 改为 opencv 4.1

错误2:#include

解决:在对应位置替换为

#include
#include 

错误3:CV_LOAD_IMAGE_UNCHANGED

解决:对应处替换为

cv::IMREAD_UNCHANGED

错误4:undefined reference to symbol '_ZN5boost6system15system_categoryEv

解决:在cmakelists.txt中添加

set(LIBS
${OpenCV_LIBS}
${EIGEN3_LIBS}
${Pangolin_LIBRARIES}
${PROJECT_SOURCE_DIR}/../../../Thirdparty/DBoW2/lib/libDBoW2.so
${PROJECT_SOURCE_DIR}/../../../Thirdparty/g2o/lib/libg2o.so
${PROJECT_SOURCE_DIR}/../../../lib/libORB_SLAM2.so
-lboost_system
)

注意修改orb-slam2发布的ros话题,使用d455运行双目例子时,漂移严重且跟踪失败,注意关闭结构光,可在realsense-viewer处关闭

靠回忆敲的过程,可能有遗漏和缺失,本文大部分参考:

ROS https://blog.csdn.net/qq_45779334/article/details/119576218?spm=1001.2014.3001.5506

turtlebot https://www.ncnynl.com/archives/201903/2884.html

realsense d455 https://blog.csdn.net/qq_40186909/article/details/113104595?spm=1001.2014.3001.5506

ORB-SLAM2 https://blog.csdn.net/zardforever123/article/details/127138151?spm=1001.2014.3001.5506

opencv 4 ORB-SLAM2 编译问题 https://blog.csdn.net/K4762/article/details/105270600?ops_request_misc=&request_id=&biz_id=102&utm_term=opencv4%20%E5%AE%89%E8%A3%85orb-slam&utm_medium=distribute.pc_search_result.none-task-blog-2allsobaiduweb~default-1-105270600.nonecase&spm=1018.2226.3001.4187

你可能感兴趣的:(ubuntu)