博客專(zhuān)欄

EEPW首頁(yè) > 博客 > NXP iMX8基于Ycoto Project編譯ROS2

NXP iMX8基于Ycoto Project編譯ROS2

發(fā)布人:toradex 時(shí)間:2021-04-23 來(lái)源:工程師 發(fā)布文章

By Toradex秦海

1). 簡(jiǎn)介

基于類(lèi)似NXP iMX8這樣性能強(qiáng)勁的ARM平臺(tái)處理器,越來(lái)越多的工業(yè)智能/機(jī)器人應(yīng)用比如AGV/AMR產(chǎn)品控制器在ARM平臺(tái)上面實(shí)現(xiàn),在這個(gè)過(guò)程中不可避免的就涉及到將機(jī)器人應(yīng)用開(kāi)發(fā)框架移植到ARM平臺(tái)來(lái)運(yùn)行,因此本文就著重示例基于Ycoto Project/Openembedded環(huán)境,將ROSRobot Operating System)編譯集成到嵌入式Linux中運(yùn)行。

ROS是一種為機(jī)器人應(yīng)用設(shè)計(jì)的分布式處理框架,集成了大量相關(guān)庫(kù)和工具,目的是為了提高機(jī)器人應(yīng)用開(kāi)發(fā)時(shí)代碼復(fù)用率, 目前ROS已經(jīng)發(fā)展到ROS2,這里就演示將ROS2最新版本Foxy集成到iMX8 Linux BSP中。

 

本文的演示的平臺(tái)來(lái)自于Toradex Apalis iMX8 ARM嵌入式平臺(tái),這是一個(gè)基于NXP iMX8QM ARM處理器,支持Cortex-A72+A53Coretex-M4架構(gòu)的計(jì)算機(jī)模塊平臺(tái)。

 

 

2). 準(zhǔn)備

a). Apalis iMX8QM 4GB WB IT ARM核心版配合Ioxra 載板,連接調(diào)試串口UART1(載板X22)到開(kāi)發(fā)主機(jī)方便調(diào)試。

 

 

3). Apalis iMX8 Ycoto Linux 集成ROS2編譯環(huán)境配置和部署

a). Apalis iMX8 Ycoto Linux 通過(guò)Ycoto/Openembedded 框架編譯,具體的配置方法請(qǐng)參考這里,首先下載好針對(duì)Apalis iMX8適用的基于Ycoto Dunfeil版本的BSP 5.x.y編譯環(huán)境。

----------------------------------

$ repo init -u https://git.toradex.com/toradex-manifest.git -b dunfell-5.x.y -m tdxref/default.xml

$ repo sync

----------------------------------

 

b). 下載meta-ros meta-python2 layer到上面下載好的ycoto環(huán)境

----------------------------------

$ cd …/oe-core/layers/

### fetch meta-ros layer

$ git clone -b dunfell https://github.com/ros/meta-ros.git

### fetch meta-phthon2 layer

$ git clone -b dunfell https://github.com/YoeDistro/meta-python2.git

----------------------------------

 

c). 配置編譯環(huán)境,添加編譯ROS2 Foxy版本需要的相關(guān)layer,由于目前ycoto 編譯ROS還無(wú)法支持圖形界面相關(guān),因此也要在編譯環(huán)境中將相關(guān)的package排除出去。

./ 添加環(huán)境變量

----------------------------------

### generate init env

$ cd …/oe-core/

$ source export

### add new env

$ export ROS_OE_RELEASE_SERIES="dunfell"

### make new env valid with bitbake

$ export BB_ENV_EXTRAWHITE="$BB_ENV_EXTRAWHITE ROS_OE_RELEASE_SERIES"

----------------------------------

 

./ 修改 build/conf/bblayers.conf 文件

----------------------------------

   ${TOPDIR}/../layers/meta-freescale-distro \

   ${TOPDIR}/../layers/meta-toradex-demos \

   ${TOPDIR}/../layers/meta-qt5 \

+  ${TOPDIR}/../layers/meta-python2 \

+  ${TOPDIR}/../layers/meta-ros/meta-ros2-foxy \

+  ${TOPDIR}/../layers/meta-ros/meta-ros2 \

+  ${TOPDIR}/../layers/meta-ros/meta-ros-common \

+  ${TOPDIR}/../layers/meta-ros/meta-ros-backports-gatesgarth \

   \

   \

   ${TOPDIR}/../layers/meta-toradex-distro \

----------------------------------

 

./ 修改 build/conf/local.conf 文件

----------------------------------

### modify machine setting to apalis imx8

MACHINE ?= "apalis-imx8"

 

### add ros-core only or ros-world packagegroup for all ros2-foxy packages

IMAGE_INSTALL_append = " packagegroup-ros-world"

 

### blacklist below packages which currently not supported in ycoto compilation

### detailed impact package refer to \ /layers/meta-ros/meta-ros2-foxy/conf/ros-distro/include/foxy/ros-distro-recipe-blacklist.inc and \ layers/meta-ros/meta-ros2-foxy/recipes-core/packagegroups/packagegroup-ros-world-foxy.bb files

ROS_WORLD_SKIP_GROUPS = " opengl qt5 qt5-widgets pyqt5 qt-gui-cpp x11 ffmpeg webots-python-modules java libomp connext gazebo coinor-libipopt gurumdds ignition doosan-robot2 clang launch pugixml lanelet2-traffic-rules mongodb kobuki-ftdi ros1"

 

### define package graphviz version

PREFERRED_VERSION_graphviz = "2.40.1%"

 

### accept freescale EULA license

ACCEPT_FSL_EULA = "1"

----------------------------------

 

./ 修改 layers/meta-ros/meta-ros2-foxy/recipes-bbappends/osqp-vendor/osqp-vendor_0.0.2-1.bbappend 文件修復(fù)當(dāng)前版本中的bug

----------------------------------

-SRCREV_osqp = "c536acf012d071eed3529e0147afdd419348362a"

+SRCREV_osqp = "36ad83aed022e714c2fda1f13138443150435994"

 SRCREV_qdldl = "12d56ee6b9494efee1da1e1dc6e7ac9c226f9ccf"

----------------------------------

 

d). 編譯imageSDK

-------------------------------

# compile Reference-Minimal image

$ bitbake bitbake tdx-reference-minimal-image

# compile Reference-Multimedia image

$ bitbake bitbake tdx-reference-multimedia-image

 

# compile SDK

bitbake tdx-reference-multimedia-image -c populate_sdk

-------------------------------

 

e). Ycoto Linux image部署

參考這里通過(guò)Toradex Easy installer將上面編譯好的image更新部署到模塊,目前最新季度發(fā)布版本為Ycoto Linux V5.2,這里使用Reference-Minimal BSP image進(jìn)行測(cè)試

 

 

4). ROS2 Foxy測(cè)試

a). 修改ROS初始化相關(guān)腳本權(quán)限,增加執(zhí)行權(quán)限

-------------------------------

root@apalis-imx8:~# chmod +x /etc/profile.d/ros/*

root@apalis-imx8:~# ls -al /etc/profile.d/ros/setup.sh                                       

-rwxr-xr-x    1 root     root          4372 Mar  9  2018 /etc/profile.d/ros/setup.sh

-------------------------------

 

b). 通過(guò)下面命令進(jìn)行ROS2 Foxy簡(jiǎn)單測(cè)試

-------------------------------

### check network connection

root@apalis-imx8:~# ping lge.com

 

### source setup script to export env

root@apalis-imx8:~# source /usr/bin/ros_setup.sh

 

### ros topic print

root@apalis-imx8:~# ros2 topic list

/parameter_events

/rosout

 

### ros interface print

root@apalis-imx8:~# ros2 interface list -m

……

 

### test

root@apalis-imx8:~# (sleep 5; ros2 topic pub /chatter std_msgs/String "data: Hello world") &

[1] 826

root@apalis-imx8:~# ros2 topic echo /chatter

publisher: beginning loop

publishing #1: std_msgs.msg.String(data='Hello world')

publishing #2: std_msgs.msg.String(data='Hello world')

publishing #3: std_msgs.msg.String(data='Hello world')

publishing #4: std_msgs.msg.String(data='Hello world')

data: Hello world

---

publishing #5: std_msgs.msg.String(data='Hello world')

data: Hello world

……

-------------------------------

 

 

5). 總結(jié)

本文基于NXP iMX8嵌入式平臺(tái)演示了通過(guò)Ycoto Project/Openembedded框架將ROS2 Foxy集成到嵌入式Linux BSP中,目前meta-ros layer除了Foxy,還支持ROS1 melodic,ROS1 noeticROS2 dashing,ROS2 eloquent,其他ROS版本可以自行根據(jù)所需要的layer不同而適應(yīng)修改后編譯。

 

參考文獻(xiàn)

https://github.com/ros/meta-ros/wiki/OpenEmbedded-Build-Instructions

https://developer.toradex.cn/knowledge-base/board-support-package/openembedded-core


*博客內(nèi)容為網(wǎng)友個(gè)人發(fā)布,僅代表博主個(gè)人觀點(diǎn),如有侵權(quán)請(qǐng)聯(lián)系工作人員刪除。



關(guān)鍵詞: iMX8 ROS Ycoto NXP ARM Linux Toradex Apalis

相關(guān)推薦

技術(shù)專(zhuān)區(qū)

關(guān)閉