差别

这里会显示出您选择的修订版和当前版本之间的差别。

到此差别页面的链接

两侧同时换到之前的修订记录 前一修订版
后一修订版
前一修订版
digi:arm-embedded:linux:dey:deycustomrootfs:ros2 [2024/03/05 14:57] robindigi:arm-embedded:linux:dey:deycustomrootfs:ros2 [2024/03/25 03:36] (当前版本) robin
行 9: 行 9:
  
 <code> <code>
-sudo apt update +sudo apt -y update  
-sudo apt install gawk wget git diffstat unzip gcc-multilib +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 
-        build-essential chrpath socat cpio python3-pip python3-pexpect +sudo locale-gen en_US.utf8 
-        xz-utils debianutils iputils-ping +sudo apt -y install python-is-python3
-        python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev xterm +
-        g++-multilib locales lsb-release python3-distutils time +
-        liblz4-tool zstd file +
-sudo locale-gen en_US.utf8  #这条不一定要执行,因为本来就是用默认英文的+
 </code> </code>
  
-2.找出环境变量配置文件备用 +2.安装DEY ALL In One开发环境,本开发环境会把meta-digi和meta-ros都和官方同步,用户只需在配置文件对镜像进行配置。 
-为了整合meta-ros到dey的镜象中有两种办法,一种是meta-ros中的镜像名来编译另一种是参考dey-image-qt创建dey-image-ros并在镜像的recipe里加上关键包的支持。为了调查清楚首先在一个全新的虚拟机上演练一下官方文档安装过程,并检查其配置文件。 +首先要安装repo在ubuntu 22.04中可直接用apt install repo安装如果您发行版不支持这种安装方式请从官方下载安装repo:
 <code> <code>
-mkdir ros2-test +sudo -H tmux 
-cd ros2-test+curl -o /usr/local/bin/repo http://commondatastorage.googleapis.com/git-repo-downloads/repo 
 +chmod a+x /usr/local/bin/repo 
 +exit 
 +</code> 
 +然后设置好git 
 +<code> 
 +git config --global user.name  “yourname”    
 +git config --global user.email "you@email.com“   
 +</code> 
 +接着就可以用repo安装DEY AIO了 
 +<code> 
 +cd 
 +mkdir dey-aio 
 +cd dey-aio 
 +repo init -u https://github.com/peyoot/dey-aio-manifest.git -b china 
 +repo sync 
 +</code>
  
-mkdir conf +3配置ROS支持
-ln -snf ../conf build/.+
  
-在build/files/下,有一系列的mcf文件,我们需要拷贝ros2-humble-kirkstone.mcf配置文件下,可见这是控制编译主本配文件, +我们需要把这个layer添加conf/bblayers.conf中,在文件的适当位插入这三句: 
-cp build/files/ros2-humble-kirkstone conf/.+<code> 
 +  /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 \
 </code> </code>
-上面这个主要是为了研究配置文件,供以碰到问题参考,可以不做这第2步,先直接拉meta-ros到源码,请参考下面+并在bblayers.conf的配置文件添加这两行变量定义: 
 +<code> 
 +ROS_DISTRO = "humble" 
 +ROS_DISTRO_TYPE = "ros2" 
 +</code> 
 + 
 +时可以尝试编译ros-core
  
-3. DEY的镜像bb文件研读 +bitbake ros-core
-主要的image配置文件在:dey4.0/sources/poky/meta/recipes-core/images和dey4.0/sources/meta-digi/meta-digi-dey/recipes-core/images +
-其中,core-image-base是在poky的基础镜像文件中添加一些包实现的,所以先研读core-image-base基础镜像,它继承自更基础的core-image(sources/poky/meta/classes/core-image.bbclass) +
-接下来将拉取meta-ros,并研读相关的bb文件。+
  
-4拉取meta-ros +5检查机器学习相关包
-下载meta-ros到dey的源码目录下+
 <code> <code>
-cd dey4.0/sources +cat ../../sources/meta-digi/meta-digi-dey/dynamic-layers/meta-ml/recipes-fsl/packagegroup/packagegroup-imx-ml.bbappend 
-git clone https://github.com/ros/meta-ros.git+最新的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"
 </code> </code>
-注意下载下来的目录,meta-ros-common和meta-ros2-humble是我们需要如果要编译ros的镜像,在meta-ros-common中有image相关的recipe,其中:+另外,在conf/local.conf添加机器学习包 
 +IMAGE_INSTALL:append = " packagegroup-imx-ml" 
 + 
 + 
 + 
 +6. 创建带ros支持镜像 
 + 
 +如果要编译ros的镜像,在meta-ros-common中有image相关的recipe,其中:
 cat ros-image-core可以观察,要定义的东西: cat ros-image-core可以观察,要定义的东西:
 <code> <code>
行 66: 行 91:
 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为基础才有意义。 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,整个过程如下 
 +<code> 
 +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)} \ 
 +"
  
-1. 尝试编译core-image-minimal \\ +# Remove graphical packages for non-graphical platforms 
-2添加相关digi包 \\ +IMAGE_FEATURES:remove = "${@oe.utils.conditional('IS_HEADLESS''true', ' splash ', '', d)}"
-或\\ +
-比较core-image-minimal和core-image-base的差异,如果不大,则\\ +
-1.ros-image-core改为以core-image-base为基础的镜像,  (可能这个方向更好一些,东西更多), +
- +
-正在进行的任务: +
-1. 编译一下core-image-minial ,并在cc93上跑起来,看看有哪些东西+
  
 +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
  
- +</code> 
-*****以下无用待参考后删除, 相关配置文件中一些敲定可能有需要 +成功编译,接来就是修改这个bb文件加入ros相关的
- +
- +
-待参考 +
- +
-待删除 +
-。。 +
- +
-。。 +
- +
-+
  
 <code> <code>
-********************************+DESCRIPTION = "A Robot image with base-featured + ROS core Linux system functionality installed."
  
-# Clone the OpenEmbedded metadata layers and generate conf/bblayers.conf . +LICENSE = "MIT"
-build/scripts/mcf -f conf/$cfg+
  
-# Set up the shell environment for this build and create a conf/local.conf . We expect all of the variables below to be unset. 
-unset BDIR BITBAKEDIR BUILDDIR OECORELAYERCONF OECORELOCALCONF OECORENOTESCONF OEROOT TEMPLATECONF 
-source openembedded-core/oe-init-build-env 
  
-# The current directory is now the build directory; return to the original+IMAGE_FEATURES += " \ 
-cd -+    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)} \ 
 +"
  
-An OpenEmbedded build produces a number of types of build artifacts, some of which can be shared between builds for +Remove graphical packages for non-graphical platforms 
-# different OpenEmbedded DISTRO-s and ROS distros. Create a common artifacts directory on the separate disk under which all +IMAGE_FEATURES:remove = "${@oe.utils.conditional('IS_HEADLESS', 'true', ' splash ', '', d)}"
-# the build artifacts will be placedThe edits to conf/local.conf done below will set TMPDIR to be a subdirectory of it. +
-mkdir -p "<ABSOLUTE-PATH-TO-DIRECTORY-ON-SEPARATE-DISK>" +
-</code>+
  
 +CORE_IMAGE_BASE_INSTALL += "dey-examples-digiapix"
  
-====以下待删除 
---- 
  
-在[[http://wiki.ros.org/Distributions|ROS]]官网上,可以看到,当前推荐的长期支持版本是:ROS Kinetic Kame ,该版本在github上有一个[[https://github.com/bulwahn/meta-ros/tree/kinetic-experimental-v3-alpha1|适用于yocto方式的验证性版本]]。+# SDK features (for toolchains generated from an image with populate_sdk) 
 +SDKIMAGE_FEATURES ?= "dev-pkgs dbg-pkgs staticdev-pkgs"
  
-meta-ros提供了两个镜像参考,分别是最小的core-image-ros-roscore以及扩展的core-image-ros-world  \\ +# Add our dey-image tweaks to the final image (like /etc/build info)
-检查这两个bb文件,core-image-ros-world集成有packagegroup-ros-world,这个bb文件在https://github.com/bulwahn/meta-ros/blob/kinetic-experimental-v3-alpha1/recipes-ros/packagegroups/packagegroup-ros-world.bb +
-可以发现,这个镜像带有canopen等众多应用层的包,不过这个镜像模板并不是以dey为基础的,为了能在dey里面用,应该把相关的包编译进dey中,甚至在熟练后可以做一个dey-image-ros的镜像bb文件来打包编译所需的镜像+
  
-要把第三方的layer添加到项目中,请按下面这个方式操作: +inherit core-image 
-<code> +inherit dey-image 
-1、 cd /usr/local/dey-2.4-r1/sources/meta-openembedded +inherit ros_distro_${ROS_DISTRO} 
-2、 git clone https://github.com/bulwahn/meta-ros -b kinetic-experimental-v3-alpha1 +inherit ${ROS_DISTRO_TYPE}_image
- +
-3. 在项目文件夹中conf/bblayers.conf,把meta-ros添加到bblayers.conf +
-4. 查一下相关的包:bitbake-layers show-recipes |grep ros +
-现在可以编译指定包甚至是roscore镜像 +
-5. bitbake core-image-ros-roscore  或者 bitbake core-image-ros-world 或者bitbake can_msgs等特定包+
  
 +IMAGE_INSTALL:append = " \
 +    ros-core \
 +"
 </code> </code>
-要把canopen等ros的包添加到dey镜像中,可参考参考[[digi:arm-embedded:linux:dey:deycustomrootfs|DEY文件系统定制]]把can_msgs或ros_canopen包添加到dey镜像中 
  
-调试过程: +新建一个项目myrobot, 编译首个core-image-ros,错误
-因为最初编译core-image-ros-world没过所以展开调试错,先试着编译一个socketcan_interface +
-出错时注意那些错误信息:比如这次是:+
 <code> <code>
-...undefined reference to symbol 'pthread_getspecific@@GLIBC_2.4' +bitbake core-image-ros
-.......error adding symbols:DSO missing from command line+
 </code> </code>
-google一下"undefined reference to symbol ‘pthread_getspecific@@GLIBC_2.4"(注意,最好不要用百度,查不到什么有用信息),有个贴子给出解决方案是:在编译时加上-lpthread控制参数 
-注意,如果您在tmp/work/ccimx6sbc-dey-linux-gnueabi/socketcan-interface/0.7.6-r0/里改是没有用的,在bitbake时会被刷新掉,用bitbake -C compile xxx可以使用本地的改变。为了更方便调试,可以用:bitbake -c devshell socketcan-interface来调出开发者shell,在源码树里临时改动并测试,这个devshell的源码树和tmp/work/ccimx6...gnueabi/里是一样的,找到socketcan_interface,里面有一个CMakeLists.txt,我们检查编译出错的地方刚好是socketcan_dump链接出错,所以在target_link_libraries(socketcan_dump..)最后加一个pthread,再编译就成功了 
  
  
 +
 +其它可能有用参考:https://community.nxp.com/t5/i-MX-Processors/I-MX8M-plus-AI-Robot-platform/m-p/1303809#M176520