====ROS2机器人操作系统的DEY镜像定制==== DEY是以Yocto的方式开发定制嵌入式Linux系统,这意味着除了添加Meta-Digi外,您也可以添加其它Yocto项目组的layer,包括在生产自动化和物流行业常用ROS机器人操作系统。在github中我们可以看到[[https://github.com/ros/meta-ros|meta-ros]]在一直保持开发和演进状态。 Yocto 4.0 Kirkstone (LTS)对应支持ROS2 Humble (LTS)是个长期支持的版本,也是我们要集成的对象。官方文档位于:https://docs.ros.org/en/humble/。更确切地说,在嵌入式Yocto源代码层面安装的文档是: https://github.com/ros/meta-ros/wiki/OpenEmbedded-Build-Instructions 1. 预安装包查缺补漏 通常在安装DEY时,应该已经把大部分依赖的安装包都安装好了,但为了防止ROS需要一些额外的包,参考文档,再执行一下它的依赖包安装: sudo apt -y update sudo apt -y install gawk wget file git diffstat file unzip texinfo gcc gcc-multilib build-essential chrpath socat cpio python3 python3-pip python3-pexpect python3-distutils python3-subunit xz-utils debianutils iputils-ping python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev pylint xterm mesa-common-dev g++-multilib locales lsb-release time zstd locales liblz4-tool sudo locale-gen en_US.utf8 sudo apt -y install python-is-python3 2.安装DEY ALL In One开发环境,本开发环境会把meta-digi和meta-ros都和官方同步,用户只需在配置文件对镜像进行配置。 首先要安装repo,在ubuntu 22.04中可直接用apt install repo来安装,如果您的发行版不支持这种安装方式,请从官方下载安装repo: sudo -H tmux curl -o /usr/local/bin/repo http://commondatastorage.googleapis.com/git-repo-downloads/repo chmod a+x /usr/local/bin/repo exit 然后设置好git git config --global user.name “yourname” git config --global user.email "you@email.com“ 接着就可以用repo安装DEY AIO了 cd mkdir dey-aio cd dey-aio repo init -u https://github.com/peyoot/dey-aio-manifest.git -b china repo sync 3. 配置ROS支持 我们还需要把这个layer添加到conf/bblayers.conf中,在文件的适当位置插入这三句: /home/robin/dey-aio/dey4.0/sources/meta-ros/meta-ros-common \ /home/robin/dey-aio/dey4.0/sources/meta-ros/meta-ros2 \ /home/robin/dey-aio/dey4.0/sources/meta-ros/meta-ros2-humble \ 并在bblayers.conf的配置文件最后添加这两行变量定义: ROS_DISTRO = "humble" ROS_DISTRO_TYPE = "ros2" 此时可以尝试编译ros-core bitbake ros-core 5. 检查机器学习相关包 cat ../../sources/meta-digi/meta-digi-dey/dynamic-layers/meta-ml/recipes-fsl/packagegroup/packagegroup-imx-ml.bbappend 最新的bb文件应该如下所录,使用tensorflow-lite,如果不是请按下面注释掉原来的一行,并添加这一新行 #ML_PKGS:mx9-nxp-bsp:remove = "deepview-rt-examples" # Only install tensorflow-lite to save space ML_PKGS:mx9-nxp-bsp:mx93-nxp-bsp = "tensorflow-lite" 另外,在conf/local.conf中添加机器学习包 IMAGE_INSTALL:append = " packagegroup-imx-ml" 6. 创建带ros支持的镜像 如果要编译ros的镜像,在meta-ros-common中有image相关的recipe,其中: cat ros-image-core可以观察,要定义的东西: require ${COREBASE}/meta/recipes-core/images/core-image-minimal.bb SUMMARY = "A small image just capable of starting core ROS." DESCRIPTION = "${SUMMARY}" inherit ros_distro_${ROS_DISTRO} inherit ${ROS_DISTRO_TYPE}_image IMAGE_INSTALL:append = " \ ros-core \ " 从上面可以看出,和core-image-base的bbappend类似,这个ros-image-core也是参考poky/meta/recipes-core/images的基础镜像core-image-minimal添加一些包。 core-image-base和core-image-minimal的差别在于:core-image-base使用meta/classes/core-image.bbclass中的IMAGE_INSTALL定义的包,而core-image-minimal则在bb文件里定义来覆盖原来core-image下的包,移除了packagegroup-base-extended,得到一个更小的镜像。所以,ros2的镜像,应该以core-image-base为基础才有意义。 从网络找到的一些参考: https://gitee.com/zxd2021-imx/meta-robot-platform/blob/Hardknott-5.10/imx/meta-robot/recipes-core/images/imx-robot-core.bb 5. 定制core-image-ros 我们给镜像取这个名字,是因为core-image-base能支持cc93的BSP,我们只需加入ros支持即可,这个镜像的bb文件可以放在meta-digi/meta-digi-dey下的recipe-core/images。先一步一步来,从基础的core-image-base中添加ros相关的支持。 首先测试一下没加layer前的效果,也就是bb文件在meta-custom是否能正常编译,将core-image-base.bbappend文件复制出来,重命名为core-image-ros.bb,并加上一句inherit core-image,整个过程如下 cd sources/meta-custom mkdir -p recipe-core/images nano core-image-ros.bb # # Copyright (C) 2016-2022 Digi International. # IMAGE_FEATURES += " \ dey-network \ eclipse-debug \ ssh-server-dropbear \ ${@bb.utils.contains('DISTRO_FEATURES', 'gstreamer', 'dey-gstreamer', '', d)} \ ${@bb.utils.contains('MACHINE_FEATURES', 'alsa', 'dey-audio', '', d)} \ ${@bb.utils.contains('MACHINE_FEATURES', 'bluetooth', 'dey-bluetooth', '', d)} \ ${@bb.utils.contains('MACHINE_FEATURES', 'wifi', 'dey-wireless', '', d)} \ " # Remove graphical packages for non-graphical platforms IMAGE_FEATURES:remove = "${@oe.utils.conditional('IS_HEADLESS', 'true', ' splash ', '', d)}" CORE_IMAGE_BASE_INSTALL += "dey-examples-digiapix" # The connectcore demo was removed from 'packagegroup-dey-core' for the # 6UL (because of rootfs space limits). Add it here, to install it in the # non-graphical core-image-base. CORE_IMAGE_BASE_INSTALL:append:ccimx6ul = " connectcore-demo-example" # SDK features (for toolchains generated from an image with populate_sdk) SDKIMAGE_FEATURES ?= "dev-pkgs dbg-pkgs staticdev-pkgs" # Add our dey-image tweaks to the final image (like /etc/build info) inherit core-image inherit dey-image 可以成功编译,接下来就是修改这个bb文件,加入ros相关的包。 DESCRIPTION = "A Robot image with base-featured + ROS core Linux system functionality installed." LICENSE = "MIT" IMAGE_FEATURES += " \ dey-network \ eclipse-debug \ ssh-server-dropbear \ ${@bb.utils.contains('DISTRO_FEATURES', 'gstreamer', 'dey-gstreamer', '', d)} \ ${@bb.utils.contains('MACHINE_FEATURES', 'alsa', 'dey-audio', '', d)} \ ${@bb.utils.contains('MACHINE_FEATURES', 'bluetooth', 'dey-bluetooth', '', d)} \ ${@bb.utils.contains('MACHINE_FEATURES', 'wifi', 'dey-wireless', '', d)} \ " # Remove graphical packages for non-graphical platforms IMAGE_FEATURES:remove = "${@oe.utils.conditional('IS_HEADLESS', 'true', ' splash ', '', d)}" CORE_IMAGE_BASE_INSTALL += "dey-examples-digiapix" # SDK features (for toolchains generated from an image with populate_sdk) SDKIMAGE_FEATURES ?= "dev-pkgs dbg-pkgs staticdev-pkgs" # Add our dey-image tweaks to the final image (like /etc/build info) inherit core-image inherit dey-image inherit ros_distro_${ROS_DISTRO} inherit ${ROS_DISTRO_TYPE}_image IMAGE_INSTALL:append = " \ ros-core \ " 新建一个项目myrobot, 编译首个core-image-ros,并排除错误。 bitbake core-image-ros 其它可能有用参考:https://community.nxp.com/t5/i-MX-Processors/I-MX8M-plus-AI-Robot-platform/m-p/1303809#M176520