Jetson-nano ros-melodic环境安装构建

  • Post author:
  • Post category:其他


Jetson-nano ros-melodic环境安装构建

  1. 安装ros-melodic 环境

    1) 系统准备

    使用ssh 登陆Jetson-nano device,而后执行以下命令进行部署

    rosCar@ubuntu:~$ uname -m && cat /etc/*release #查看系统信息

    aarch64

    DISTRIB_ID=Ubuntu

    DISTRIB_RELEASE=18.04

    DISTRIB_CODENAME=bionic

    DISTRIB_DESCRIPTION=“Ubuntu 18.04.6 LTS”



R32 (release), REVISION: 7.2, GCID: 30192233, BOARD: t210ref, EABI: aarch64, DATE: Wed Apr 20 21:34:48 UTC 2022

NAME=“Ubuntu”

VERSION=“18.04.6 LTS (Bionic Beaver)”

ID=ubuntu

ID_LIKE=debian

PRETTY_NAME=“Ubuntu 18.04.6 LTS”

VERSION_ID=“18.04”

HOME_URL=“https://www.ubuntu.com/”

SUPPORT_URL=“https://help.ubuntu.com/”

BUG_REPORT_URL=“https://bugs.launchpad.net/ubuntu/”

PRIVACY_POLICY_URL=“https://www.ubuntu.com/legal/terms-and-policies/privacy-policy”

VERSION_CODENAME=bionic

UBUNTU_CODENAME=bionic

rosCar@ubuntu:~$ sudo apt update #更新系统源

[sudo] password for rosCar:

Hit:1 http://ports.ubuntu.com/ubuntu-ports bionic InRelease

Hit:2 https://repo.download.nvidia.cn/jetson/common r32.7 InRelease

……

Building dependency tree

Reading state information… Done

205 packages can be upgraded. Run ‘apt list –upgradable’ to see them.

rosCar@ubuntu:~$ sudo apt upgrade #更新系统软件

Reading package lists… Done

Building dependency tree

……

Processing triggers for ca-certificates (20211016~18.04.1) …

Updating certificates in /etc/ssl/certs…

0 added, 0 removed; done.

Running hooks in /etc/ca-certificates/update.d…

done.

rosCar@ubuntu:~$ sudo sh -c ‘echo “deb http://packages.ros.org/ros/ubuntu

KaTeX parse error: Expected ‘EOF’, got ‘#’ at position 68: …s-latest.list’ #̲加入ros源 rosCar@u…

sudo apt install curl #安装curl 工具,密钥用

……

Reading package lists… Done

Building dependency tree

Unpacking curl (7.58.0-2ubuntu3.21) …

Setting up curl (7.58.0-2ubuntu3.21) …

Processing triggers for man-db (2.8.3-2ubuntu0.1) …

rosCar@ubuntu:~$ curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add – #密钥更新

OK

rosCar@ubuntu:~$ sudo apt update #更新系统源

Hit:1 http://ports.ubuntu.com/ubuntu-ports bionic InRelease

Hit:2 http://ports.ubuntu.com/ubuntu-ports bionic-updates InRelease

……Reading state information… Done

All packages are up to date.

2) 安装ros-melodic 配置ros环境

rosCar@ubuntu:~$ sudo apt install ros-melodic-desktop-full #安装ros

Reading package lists… Done

Building dependency tree

Reading state information… Done

……

Setting up ros-melodic-visualization-tutorials (0.10.5-1bionic.20221026.001532) …

Setting up ros-melodic-desktop (1.4.1-0bionic.20221026.002105) …

Setting up ros-melodic-desktop-full (1.4.1-0bionic.20221026.002149) …

Processing triggers for libc-bin (2.27-3ubuntu1.6) … #安装完成

rosCar@ubuntu:~$ echo “source /opt/ros/melodic/setup.bash” >> ~/.bashrc #进行系统环境配置

rosCar@ubuntu:~$ source ~/.bashrc #使能系统环境

rosCar@ubuntu:~$ sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool #安装ros依赖软件

Reading package lists… Done

Building dependency tree

Reading state information… Done

Processing triggers for man-db (2.8.3-2ubuntu0.1) …

Processing triggers for libc-bin (2.27-3ubuntu1.6) …

rosCar@ubuntu:~$ sudo rosdep init #ros初始化

Wrote /etc/ros/rosdep/sources.list.d/20-default.list

Recommended: please run

    rosdep update

rosCar@ubuntu:~$ mkdir project #建立组件缓存目录

rosCar@ubuntu:~$ mkdir -p rosCar_ros/src #建立ros工作空间目录

rosCar@ubuntu:~$ cd project/ #进入组件缓存目录

rosCar@ubuntu:~/project$ ls

rosCar@ubuntu:~/project$ git clone https://github.com/ros/rosdistro.git #ros依赖源

Cloning into ‘rosdistro’…

remote: Enumerating objects: 180148, done.

remote: Total 180148 (delta 0), reused 0 (delta 0), pack-reused 180148

Receiving objects: 100% (180148/180148), 116.32 MiB | 4.96 MiB/s, done.

Resolving deltas: 100% (107296/107296), done.

rosCar@ubuntu:~/project$ ls

rosdistro

rosCar@ubuntu:~/project$ sudo vi ./rosdistro/rosdep/sources.list.d/20-default.list #编辑依赖源

编辑成为如下内容:

yaml file:///home/rosCar/project/rosdistro/rosdep/osx-homebrew.yaml osx

yaml file:home/rosCar/project/rosdistro/rosdep/base.yaml

yaml file:///home/rosCar/project/rosdistro/rosdep/python.yaml

yaml file:///home/rosCar/project/rosdistro/rosdep/ruby.yaml

gbpdistro file:///home/rosCar/project/rosdistro/releases/fuerte.yaml fuerte

rosCar@ubuntu:~/project$ sudo vi /etc/ros/rosdep/sources.list.d/20-default.list

编辑为如下内容:

yaml file:///home/rosCar/project/rosdistro/rosdep/osx-homebrew.yaml osx

yaml file:home/rosCar/project/rosdistro/rosdep/base.yaml

yaml file:///home/rosCar/project/rosdistro/rosdep/python.yaml

yaml file:///home/rosCar/project/rosdistro/rosdep/ruby.yaml

gbpdistro file:///home/rosCar/project/rosdistro/releases/fuerte.yaml fuerte

rosCar@ubuntu:~/project$ sudo vi /usr/lib/python2.7/dist-packages/rosdep2/sources_list.py #修改文件DEFAULT_SOURCES_LIST_URL源

#DEFAULT_SOURCES_LIST_URL = ‘https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list’

DEFAULT_SOURCES_LIST_URL = ‘file:///home/rosCar/project/rosdistro/rosdep/sources.list.d/20-default.list’

rosCar@ubuntu:~/project$ sudo vi /usr/lib/python2.7/dist-packages/rosdistro/

init

.py #修改文件DEFAULT_INDEX_URL源

DEFAULT_INDEX_URL = ‘file:///home/rosCar/project/rosdistro/index-v4.yaml’

rosCar@ubuntu:~/project$ sudo vi /usr/lib/python2.7/dist-packages/rosdep2/rep3.py # 修改文件REP3_TARGETS_URL源

REP3_TARGETS_URL = ‘file:///home/rosCar/project/rosdistro/releases/targets.yaml’

rosCar@ubuntu:~/project$ rosdep update

reading in sources list data from /etc/ros/rosdep/sources.list.d

Hit file:///home/rosCar/project/rosdistro/rosdep/osx-homebrew.yaml

Hit file:home/rosCar/project/rosdistro/rosdep/base.yaml

……

Add distro “melodic”

Add distro “noetic”

Add distro “rolling”

updated cache in /home/rosCar/.ros/rosdep/sources.cache

3) 安装libuvc组件

rosCar@ubuntu:~/project$ sudo apt install libsdl-image1.2-dev libsdl-dev #依赖安装

[sudo] password for rosCar:

rosCar@ubuntu:~/project$ git clone https://github.com/libuvc/libuvc

Cloning into ‘libuvc’…

remote: Enumerating objects: 988, done.

rosCar@ubuntu:~/project$ cd libuvc/

rosCar@ubuntu:~/project/libuvc$ ls

cameras cmake doxygen.conf libuvcConfig.cmake LICENSE.txt src

changelog.txt CMakeLists.txt include libuvc.pc.in README.md standard-units.yaml

rosCar@ubuntu:~/project/libuvc$ mkdir build

rosCar@ubuntu:~/project/libuvc$ cd build/

rosCar@ubuntu:~/project/libuvc/build$ cmake …

– The C compiler identification is GNU 7.5.0

– Check for working C compiler: /usr/bin/cc

– Check for working C compiler: /usr/bin/cc – works

……

– Build files have been written to: /home/rosCar/project/libuvc/build

rosCar@ubuntu:~/project/libuvc/build$ make -j4 && sudo make install

Scanning dependencies of target uvc_static

Scanning dependencies of target uvc

[ 9%] Building C object CMakeFiles/uvc_static.dir/src/ctrl.c.o

……

– Installing: /usr/local/lib/pkgconfig/libuvc.pc

– Installing: /usr/local/lib/cmake/libuvc/libuvcConfig.cmake

rosCar@ubuntu:~/project/libuvc/build$ cd …/

4) 安装librealsense(https://github.com/IntelRealSense/librealsense 介绍)

rosCar@ubuntu:~/project$ git clone https://github.com/IntelRealSense/librealsense/releases #获取源码

rosCar@ubuntu:~/project$ sudo apt-get install libudev-dev pkg-config libgtk-3-dev libusb-1.0-0-dev libglfw3-dev libssl-dev #安装依赖

Reading package lists… Done

rosCar@ubuntu:~/project$ cd librealsense-master/

rosCar@ubuntu:~/project/librealsense-master$ sudo cp config/99-realsense-libusb.rules /etc/udev/rules.d/

rosCar@ubuntu:~/project/librealsense-master$ sudo udevadm control –reload-rules && udevadm trigger

rosCar@ubuntu:~/project/librealsense-master$ mkdir release

rosCar@ubuntu:~/project/librealsense-master$ cd release/

rosCar@ubuntu:~/project/librealsense-master/release$ cmake … #构建编译环境

– The CXX compiler identification is GNU 7.5.0

– The C compiler identification is GNU 7.5.0

– Check for working CXX compiler: /usr/bin/c++

……

– Build files have been written to: /home/rosCar/project/librealsense-master/release

rosCar@ubuntu:~/project/librealsense-master/release$ make -j4 && sudo make install #编译安装

Scanning dependencies of target fw

Scanning dependencies of target glfw

……

– Installing: /usr/local/bin/rs-benchmark

– Set runtime path of “/usr/local/bin/rs-benchmark” to “”

– Installing: /usr/local/lib/libfw.a

5) 安装opencv 3.4.2

rosCar@ubuntu:~/project/nano_build_opencv$ sudo ./build_opencv.sh 3.4.2 #使用脚本安装

It appears an existing build exists in /tmp/build_opencv

中途出现的(

.i)(

.dat)文件缺失

$ wget https://raw.githubusercontent.com/opencv/opencv_3rdparty/34e4206aef44d50e6bbcd0ab06354b52e7466d26/boostdesc_bgm.i -O boostdesc_bgm.i

$ wget https://raw.githubusercontent.com/opencv/opencv_3rdparty/34e4206aef44d50e6bbcd0ab06354b52e7466d26/boostdesc_bgm_bi.i -O boostdesc_bgm_bi.i

$ wget https://raw.githubusercontent.com/opencv/opencv_3rdparty/34e4206aef44d50e6bbcd0ab06354b52e7466d26/boostdesc_bgm_hd.i -O boostdesc_bgm_hd.i

$ wget https://raw.githubusercontent.com/opencv/opencv_3rdparty/34e4206aef44d50e6bbcd0ab06354b52e7466d26/boostdesc_binboost_064.i -O boostdesc_binboost_064.i

$ wget https://raw.githubusercontent.com/opencv/opencv_3rdparty/34e4206aef44d50e6bbcd0ab06354b52e7466d26/boostdesc_binboost_128.i -O boostdesc_binboost_128.i

$ wget https://raw.githubusercontent.com/opencv/opencv_3rdparty/34e4206aef44d50e6bbcd0ab06354b52e7466d26/boostdesc_binboost_256.i -O boostdesc_binboost_256.i

$ wget https://raw.githubusercontent.com/opencv/opencv_3rdparty/34e4206aef44d50e6bbcd0ab06354b52e7466d26/boostdesc_lbgm.i -O boostdesc_lbgm.i

$ wget https://raw.githubusercontent.com/opencv/opencv_3rdparty/fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d/vgg_generated_48.i -O vgg_generated_48.i

$ wget https://raw.githubusercontent.com/opencv/opencv_3rdparty/fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d/vgg_generated_64.i -O vgg_generated_64.i

$ wget https://raw.githubusercontent.com/opencv/opencv_3rdparty/fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d/vgg_generated_80.i -O vgg_generated_80.i

$ wget https://raw.githubusercontent.com/opencv/opencv_3rdparty/fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d/vgg_generated_120.i -O vgg_generated_120.i

以上文件放到下列目录下:

./opencv/build/modules/xfeatures2d

$ wget https://raw.githubusercontent.com/opencv/opencv_3rdparty/8afa57abc8229d611c4937165d20e2a2d9fc5a12/face_landmark_model.dat -O face_landmark_model.dat

以上文件放入下列目录

./opencv/build/share/OpenCV/testdata/cv/face

无法发现 (cuda.hpp)文件执行下列命令

$ sudo cp -av ./opencv_contrib/modules/xfeatures2d/include/opencv2/xfeatures2d ./opencv/build/opencv2/

rosCar@ubuntu:/tmp/build_opencv/opencv/build$ sudo make install

[ 1%] Built target gen-pkgconfig

[ 3%] Built target libjasper

[ 8%] Built target IlmImf

[ 14%] Built target libprotobuf

……

– Installing: /usr/local/bin/opencv_interactive-calibration

– Set runtime path of “/usr/local/bin/opencv_interactive-calibration” to “/usr/local/lib:/usr/local/cuda/lib64”

– Installing: /usr/local/bin/opencv_version

– Set runtime path of “/usr/local/bin/opencv_version” to “/usr/local/lib:/usr/local/cuda/lib64”

rosCar@ubuntu:/tmp/build_opencv/opencv/build$

6) 安装ZED

(环境cuda 10.2 , ZED_SDK_Tegra_L4T32.7_v3.7.7.run, zed-ros-wrapper-3.7.x.zip(https://github.com/stereolabs/zed-ros-wrapper/tree/v3.7.x)

https://www.stereolabs.com/developers/release/ 下载

在这里插入图片描述

rosCar@ubuntu:~/project$ sudo chmod a+x ZED_SDK_Tegra_L4T32.7_v3.7.7.run

rosCar@ubuntu:~/project$ ./ZED_SDK_Tegra_L4T32.7_v3.7.7.run

Verifying archive integrity… 100% MD5 checksums are OK. All good.

……

python -m pip install –ignore-installed /tmp/selfgz16121/pyzed-3.7-cp36-cp36m-linux_aarch64.whl

The ZED Python API was installed for ‘python3’, when using conda environement or virtualenv, the ZED Python API may need to be resetup to be available (using ‘python /usr/local/zed/get_python_api.py’)

Please note that installing the ‘libv4l-dev’ apt package at any point on jetson will break the hardware encoding/decoding support

ZED SDK installation complete !

  1. Ros工作空间建立

    1) 建立工作空间,安装包依赖代码

    rosCar@ubuntu:~/rosCar_ros$ rosdep install –from-paths src –ignore-src -r -y #安装包依赖

    ……

    Setting up ros-melodic-yocs-velocity-smoother (0.8.2-0bionic.20221025.211355) …

    #All required rosdeps installed successfully

2) 修改cv_bridge 使用opencv 以及库引用

rosCar@ubuntu:~/rosCar_ros$ vi /opt/ros/melodic/share/cv_bridge/cmake/cv_bridgeConfig.cmake #修改opencv内容

94 if(NOT “include;/usr/include;/usr/include/opencv ” STREQUAL ” “)

95 set(cv_bridge_INCLUDE_DIRS “”)

96 set(_include_dirs “include;/usr/include;/usr/local/include/opencv”)

119 set(libraries “cv_bridge;/usr/local/lib/libopencv_core.so.3.4.2;/usr/local/lib/libope ncv_imgproc.so.3.4.2;/usr/local/lib/libopencv_imgcodecs.so.3.4.2”)

3) 修改image_geometry使用opencv以及库引用

rosCar@ubuntu:~/rosCar_ros$ sudo vi /opt/ros/melodic/share/image_geometry/cmake/image_geometryConfig.cmake #修改 opencv 内容

94 if(NOT “include;/usr/include;/usr/include/opencv ” STREQUAL ” “)

95 set(image_geometry_INCLUDE_DIRS “”)

96 set(_include_dirs “include;/usr/include;/usr/local/include/opencv”)

97 if(NOT ” ” STREQUAL ” “)

119 set(libraries “image_geometry;/usr/local/lib/libopencv_calib3d.so.3.4.2;/usr/local/li b/libopencv_core.so.3.4.2;/usr/local/lib/libopencv_features2d.so.3.4.2;/usr/local/lib /libopencv_flann.so.3.4.2;/usr/local/lib/libopencv_highgui.so.3.4.2;/usr/local/lib/li bopencv_imgcodecs.so.3.4.2;/usr/local/lib/libopencv_imgproc.so.3.4.2;/usr/local/lib/l ibopencv_ml.so.3.4.2;/usr/local/lib/libopencv_objdetect.so.3.4.2;/usr/local/lib/libop encv_photo.so.3.4.2;/usr/local/lib/libopencv_shape.so.3.4.2;/usr/local/lib/libopencv_ stitching.so.3.4.2;/usr/local/lib/libopencv_superres.so.3.4.2;/usr/local/lib/libopenc v_video.so.3.4.2;/usr/local/lib/libopencv_videoio.so.3.4.2;/usr/local/lib/libopencv_v ideostab.so.3.4.2;/usr/local/lib/libopencv_viz.so.3.4.2;/usr/local/lib/libopencv_aruc o.so.3.4.2;/usr/local/lib/libopencv_bgsegm.so.3.4.2;/usr/local/lib/libopencv_bioinspi red.so.3.4.2;/usr/local/lib/libopencv_ccalib.so.3.4.2;/usr/local/lib/libopencv_datase ts.so.3.4.2;/usr/local/lib/libopencv_dpm.so.3.4.2;/usr/local/lib/libopencv_face.so.3. 4.2;/usr/local/lib/libopencv_freetype.so.3.4.2;/usr/local/lib/libopencv_fuzzy.so.3.4. 2;/usr/local/lib/libopencv_hdf.so.3.4.2;/usr/local/lib/libopencv_line_descriptor.so.3 .4.2;/usr/local/lib/libopencv_optflow.so.3.4.2;/usr/local/lib/libopencv_phase_unwrapp ing.so.3.4.2;/usr/local/lib/libopencv_plot.so.3.4.2;/usr/local/lib/libopencv_reg.so.3 .4.2;/usr/local/lib/libopencv_rgbd.so.3.4.2;/usr/local/lib/libopencv_saliency.so.3.4. 2;/usr/local/lib/libopencv_stereo.so.3.4.2;/usr/local/lib/libopencv_structured_light. so.3.4.2;/usr/local/lib/libopencv_surface_matching.so.3.4.2;/usr/local/lib/libopencv_ text.so.3.4.2;/usr/local/lib/libopencv_ximgproc.so.3.4.2;/usr/local/lib/libopencv_xob jdetect.so.3.4.2;/usr/local/lib/libopencv_xphoto.so.3.4.2”)

120 foreach(library ${libraries})

rosCar@ubuntu:~/rosCar_ros$ catkin_make #编译自身ros包(catkin_make -DCATKIN_WHITELIST_PACKAGES=“my_package” 单独包编译)

Base path: /home/rosCar/rosCar_ros

Source space: /home/rosCar/rosCar_ros/src

Build space: /home/rosCar/rosCar_ros/build

Devel space: /home/rosCar/rosCar_ros/devel

等待完成。。。

[100%] Built target teb_local_planner

Scanning dependencies of target test_optim_node

[100%] Building CXX object teb_local_planner-melodic-devel/CMakeFiles/test_optim_node.dir/src/test_optim_node.cpp.o

[100%] Linking CXX executable /home/rosCar/rosCar_ros/devel/lib/teb_local_planner/test_optim_node

[100%] Built target test_optim_node

4) 配置ros包环境

rosCar@ubuntu:~/rosCar_ros$ source /home/rosCar/rosCar_ros/devel/setup.bash

以上操作日志放在《rosCar_ros-melodic_构建_操作日志》文件中。

https://download.csdn.net/download/weixin_41740391/87227225



版权声明:本文为weixin_41740391原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。