差别

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

到此差别页面的链接

两侧同时换到之前的修订记录 前一修订版
后一修订版
前一修订版
digi:arm-embedded:linux:dey:deycustomrootfs:ros2 [2024/03/06 10:41] 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>
行 73: 行 98:
  
 首先测试一下没加layer前的效果,也就是bb文件在meta-custom是否能正常编译,将core-image-base.bbappend文件复制出来,重命名为core-image-ros.bb,并加上一句inherit core-image,整个过程如下 首先测试一下没加layer前的效果,也就是bb文件在meta-custom是否能正常编译,将core-image-base.bbappend文件复制出来,重命名为core-image-ros.bb,并加上一句inherit core-image,整个过程如下
 +<code>
 cd sources/meta-custom cd sources/meta-custom
 mkdir -p recipe-core/images mkdir -p recipe-core/images
 nano core-image-ros.bb nano core-image-ros.bb
-<code>+
 # #
 # Copyright (C) 2016-2022 Digi International. # Copyright (C) 2016-2022 Digi International.
行 108: 行 134:
 inherit dey-image inherit dey-image
  
-<code>+</code>
 可以成功编译,接下来就是修改这个bb文件,加入ros相关的包。 可以成功编译,接下来就是修改这个bb文件,加入ros相关的包。
  
行 148: 行 174:
 </code> </code>
  
- +新建一项目myrobot, 编译首个core-image-ros,并错误
-。 +
- +
-。 +
- +
-。 +
- +
- +
-接下来的方向是: +
- +
-1. 尝试编译core-image-minimal \\ +
-2. 添加相关digi包 \\ +
-或\\ +
-比较core-image-minimal和core-image-base的差异,如果不大,则\\ +
-1.ros-image-core改为以core-image-base为基础的镜像,  (可能这方向更好一些东西更多), +
- +
-正在进行的任务: +
-1. 编译一下core-image-minial ,并在cc93上跑起来,看看有哪些东西 +
- +
- +
- +
- +
- +
- +
-*****以下无用待参考后删, 相关配置文件中的一些敲定可能有需要 +
- +
- +
-待参考 +
- +
-待删除 +
-。。 +
- +
-。。 +
- +
- +
 <code> <code>
-******************************** +bitbake core-image-ros
- +
-# Clone the OpenEmbedded metadata layers and generate conf/bblayers.conf . +
-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. +
-cd - +
- +
-# An OpenEmbedded build produces a number of types of build artifacts, some of which can be shared between builds for +
-# different OpenEmbedded DISTRO-s and ROS distros. Create a common artifacts directory on the separate disk under which all +
-# the build artifacts will be placed. The 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> </code>
  
- 
-====以下待删除 
---- 
- 
-在[[http://wiki.ros.org/Distributions|ROS]]官网上,可以看到,当前推荐的长期支持版本是:ROS Kinetic Kame ,该版本在github上有一个[[https://github.com/bulwahn/meta-ros/tree/kinetic-experimental-v3-alpha1|适用于yocto方式的验证性版本]]。 
- 
-meta-ros提供了两个镜像参考,分别是最小的core-image-ros-roscore以及扩展的core-image-ros-world  \\ 
-检查这两个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添加到项目中,请按下面这个方式操作: 
-<code> 
-1、 cd /usr/local/dey-2.4-r1/sources/meta-openembedded 
-2、 git clone https://github.com/bulwahn/meta-ros -b kinetic-experimental-v3-alpha1 
- 
-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等特定包 
- 
-</code> 
-要把canopen等ros的包添加到dey镜像中,可参考参考[[digi:arm-embedded:linux:dey:deycustomrootfs|DEY文件系统定制]]把can_msgs或ros_canopen包添加到dey镜像中 
- 
-调试过程: 
-因为最初编译core-image-ros-world没过,所以展开调试排错,先试着编译一个socketcan_interface 
-出错时注意那些错误信息:比如这次是: 
-<code> 
-...undefined reference to symbol 'pthread_getspecific@@GLIBC_2.4' 
-.......error adding symbols:DSO missing from command line 
-</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