Jetson TK1与ROS调教手记

前言

近期入手了一块NVIDIA TK1开发板,想用这块开发板结合ROS做机器人开发,在此处记录下一些折腾记录,方便日后查询。

Flash TK1

这一部分可以参考JetPack 2.0 – NVIDIA Jetson Development Pack – Jetson TK1这篇文章。

通过JetPack安装

首先在Ubuntu Host上下载最新的JetPack TK1最新的安装文件:JetPack-<VERSION>.run,其中<VERSION>对应的是相应的版本,比如截止本文写作时,最新版为:L4T-2.1-linux-x64,因此安装文件的文件名即为:JetPack-L4T-2.1-linux-x64.run。

下载地址:https://developer.nvidia.com/embedded/jetpack

假设该文件所在位置为Home目录,打开Terminal,改变文件权限:

$ chmod +x JetPack-L4T-2.1-linux-x64.run

在运行该安装文件前,最好检查一下Ubuntu Host的IP地址,最好设为: 192.168.1.101,因为笔者在安装过程中发现,如果不设置为这个地址,后续传输文件就容易卡住甚至出错,具体原因还在探寻中。检查IP地址的方法很简单,在Terminal中输入ifconfig命令即可:

ip_set_ifconfig

然后以管理员身份运行此文件,注意,一定要以管理员身份运行,不然后面可能会提示权限错误。

$ sudo ./JetPack-L4T-2.1-linux-x64.run

下面是安装过程的一些截图:

首先是安装包选择界面,一般默认即可。检查下是否选择上了CUDA Toolkit和OpenCV for Tegra,这两个包一定要装。

jetpack_component_manager

下面是安装确认界面,确认无误后,点击“Next”即可。

post_installation

根据提示,设置TK1为Force USB Recovery Mode。

tk1_recovery_mode

打开另一个Terminal,输入lsusb命令,检查TK1是否进入Force USB Recovery Mode。看到打印出来Nvidia Corp.信息即可。

tk1_recovery_mode_2

然后在Post Installation窗口按下Enter键即进入安装,安装过程根据网络状况不同时间不一。

tk1_recovery_mode_3

手动安装(不推荐)

JetPack安装过程中可能会出错,这时可以采用手动安装。

安装CUDA

$ cd cuda-l4t  // 理論上 Jetpack 會把 CUDA 檔案放在這,請自行確認
# Install the CUDA repo metadata that you downloaded manually for L4T
$ sudo dpkg -i cuda-repo-l4t-r21.3-6-5-local_6.5-50_armhf.deb
$ sudo apt-get install cuda-toolkit-6-5

检查CUDA是否安装成功:

$ nvcc -V   // 正常會跳出版本資訊
cuda_check

安装OpenCV4Tegra

安装OpenCV4Tegra前要先安装CUDA。

$ cd OpenCV4Tegra  // 理論上 Jetpack 會把檔案放在這,請自行確認
$ sudo dpkg -i libopencv4tegra-repo_l4t-r21_2.4.10.1_armhf.deb
$ sudo apt-get update
$ sudo apt-get install libopencv4tegra libopencv4tegra-dev

检查是否安装成功:

$ sudo apt–get install libopencv4tegra–python // 要先安裝程式,連結 python

在Terminal中输入:

$ python
>>> import cv2             // 呼叫 library,如果出現 ERROR ,代表 … 革命尚未成功 …
>>> print cv2.__version__  // Check 一下版本,OpenCV4Tegra再 JetPack 21 為2.4.12.2
opencv4tegra_check

After Flash Setup

这一部分主要参考了以下这篇博客:

After LT4 21.3 Flash Setup – NVIDIA Jetson TK1

以及以下git中的代码:

https://github.com/jetsonhacks/postFlash

首先安装git:

$ sudo apt-get update
$ sudo apt-get install git

查看Jetson TK1 L4T版本:

head -n 1 /etc/nv_tegra_release
tk1_L4T_version

配置postFlash脚本:

$ git clone https://github.com/jetsonhacks/postFlash.git
$ cd postFlash
$ ./configureSystem.sh

这个脚本主要帮我们完成了一下一些事:

  • Chromium is installed as a browser. Firefox has issues downloading .zip files, so Chromium is a good alternative. Two other applications are also installed, aptitude and git.
  • USB 3.0 is enabled. The default is USB 2.0, /boot/extlinux/extlinux.conf must be modified to enable USB 3.0.
  • Two scripts are installed in /usr/local/bin. To conserve power, by default the Jetson suspends power to the USB ports when they are not in use. In a desktop environment, this can lead to issues with devices such as cameras and webcams. The first script disables USB autosuspend.
  • Also to conserve power, the Jetson manipulates the CPU cores and GPU clock speeds. The second script sets everything up for maximum performance.

安装Grinch Kernel

这一部分主要参考了以下这篇博客:

Install Grinch Kernel for L4T 21.3 on NVIDIA Jetson TK1

以及以下git中的代码:

https://github.com/jetsonhacks/installGrinch

关于Grinch是什么,为什么Nvidia没有默认安装Grinch:

Many people, especially those coming from desktop platforms, wonder why the Jetson lacks initial support for a wide variety of external peripherals when removed from the box. The reason is that the Jetson is an embedded development kit, which means its main initial intent was to help developers build devices that include the Tegra K1 chip. If you think about it from that perspective, it wouldn’t make much sense to have extra drivers and cruft installed that a device doesn’t use. For example, if you were building a phone, it doesn’t make sense to have drivers for 20 different wireless cards that the phone doesn’t contain.

However, the Jetson is also powerful enough to be a general purpose desktop computer. Desktop computer users have certain expectations, including being able to add devices and drivers, or have support for common devices available. Fortunately the Jetson community, led by user Santyago built a new Linux kernel named Grinch which includes a lot of the features to which most desktop users are accustomed.

安装方式如下:

$ git clone https://github.com/jetsonhacks/installGrinch.git
$ cd installGrinch
$ ./installGrinch.sh

安装ROS indigo

这一部分主要参考了以下几篇文章:

Nvidia Jetson TK1 ROS wiki

Ubuntu ARM install of ROS Indigo

Robot Operating System (ROS) on NVIDIA Jetson TK1

$ git clone https://github.com/jetsonhacks/installROS.git
$ cd installROS

复制一份installROS.sh,并命名为installROSModified.sh。打开installROSModified.sh,将source.list改为国内源,这样安装的时候,速度可以快一些。比如笔者就将源改为了易科机器人实验室(ExBot Robotics Lab)的源:

change_source_list

设置RVIZ。至于安装脚本为什么没有默认设置RVIZ,我们可以参考官方wiki上的说明:

It is not recommended to run rviz on most ARM-based CPUs. They're generally too slow, and the version of OpenGL that is provided by the software (mesa) libraries it not new enough to start rviz.

'IF' you have a powerful board with a GPU and vendor-supplied OpenGL libraries, it might be possible to run rviz. The IFC6410 and the NVidia Jetson TK1 are two such boards where rviz will run, although neither is fast enough for graphics-heavy tasks such as displaying pointclouds.

Note that rviz will segfault if you have the GTK_IM_MODULE environment variable set, so it's best to unset it in your~/.bashrc:

unset GTK_IM_MODULE

根据官方wiki,设置RVIZ的方式很简单,我们只需在installROSModified.sh文件中加入如图所示的代码即可:

using_rviz

最后,在Terminal中运行installROSModified.sh脚本:

$ ./installROSModified.h

等待一段时间,ROS Indigo就应该安装好了,检查是否安装成功也很简单,重新打开一个Terminal,运行roscore即可,如果输入下图类似内容,即说明安装成功。

roscore

安装ros-prereq.sh(Optional)

ros-prereq.sh脚本能帮我们安装一些常用的ROS工具包,包括navigation和mapping工具包等,在Terminal中直接运行如下代码即可:

./ros-prereq.sh

ros-prereq.sh下载地址:链接: https://pan.baidu.com/s/1boYHvYn 密码: tswv
之前忘记上传了,感谢2楼提醒。

Hacking for OpenCV

这一部分主要参考了以下几篇文章:

ROS, OpenCV and OpenCV4Tegra on the NVIDIA Jetson TK1

http://myzharbot.robot-home.it/blog/software/ros-nvidia-jetson-tx1-jetson-tk1-opencv-ultimate-guide/

需要修改的文件如下:

  • /opt/ros/<ros-version>/lib/pkgconfig/cv_bridge.pc
  • /opt/ros/<ros-version>/lib/pkgconfig/image_geometry.pc
  • /opt/ros/<ros-version>/share/cv_bridge/cmake/cv_bridgeConfig.cmake
  • /opt/ros/<ros-version>/share/image_geometry/cmake/image_geometryConfig.cmake

先备份:

$ sudo cp /opt/ros/indigo/lib/pkgconfig/cv_bridge.pc /opt/ros/indigo/lib/pkgconfig/cv_bridge.pc-bak
$ sudo cp /opt/ros/indigo/lib/pkgconfig/image_geometry.pc /opt/ros/indigo/lib/pkgconfig/image_geometry.pc-bak
$ sudo cp /opt/ros/indigo/share/cv_bridge/cmake/cv_bridgeConfig.cmake /opt/ros/indigo/share/cv_bridge/cmake/cv_bridgeConfig.cmake-bak
$ sudo cp /opt/ros/indigo/share/image_geometry/cmake/image_geometryConfig.cmake /opt/ros/indigo/share/image_geometry/cmake/image_geometryConfig.cmake-bak

对以上每个文件做如下修改:

  • remove each instance /usr/lib/arm-linux-gnueabihf/libopencv_ocl.so.2.4.8;
  • replace each instance of /usr/lib/arm-linux-gnueabihf/ with /usr/lib
  • replace each instance of 2.4.8 with 2.4.12 (or the current version of OpenCV in opencv4tegra package)
$ sudo gedit /opt/ros/indigo/lib/pkgconfig/cv_bridge.pc &
$ sudo gedit /opt/ros/indigo/lib/pkgconfig/image_geometry.pc &
$ sudo gedit /opt/ros/indigo/share/cv_bridge/cmake/cv_bridgeConfig.cmake &
$ sudo gedit /opt/ros/indigo/share/image_geometry/cmake/image_geometryConfig.cmake &

安装Kinect Driver

ROS中默认没有安装Kinect的库,如果我们需要使用Kinect,就需要安装库,安装方法如下:

TIP: Notice that the command below that starts with “tar xvjf” mentions “x64”. If you are using a 86-bit processor change this to “x86” and do the same things for the following line starting with “cd”. View a complete list of options.

$ mkdir ~/kinectdriver 
$ cd ~/kinectdriver 
$ git clone https://github.com/avin2/SensorKinect.git
$ cd SensorKinect/Bin/
$ tar xvjf SensorKinect093-Bin-Linux-x64-v5.1.2.1.tar.bz2
$ cd Sensor-Bin-Linux-x64-v5.1.2.1/
$ sudo ./install.sh

总结

不定期更新,未完待续……

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 201,552评论 5 474
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 84,666评论 2 377
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 148,519评论 0 334
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,180评论 1 272
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,205评论 5 363
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,344评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,781评论 3 393
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,449评论 0 256
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,635评论 1 295
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,467评论 2 317
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,515评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,217评论 3 318
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,775评论 3 303
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,851评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,084评论 1 258
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 42,637评论 2 348
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,204评论 2 341

推荐阅读更多精彩内容