原始参考:https://github.com/ros/meta-ros/blob/kirkstone-next/meta-ros-common/recipes-core/images/ros-image-world.bb 注意它的inherit:

inherit ros_distro_${ROS_DISTRO}
inherit ${ROS_DISTRO_TYPE}_image

但我们在工作目录的bblayers.conf中有设置:

ROS_DISTRO = "humble"
ROS_DISTRO_TYPE = "ros2"

所以,它会先inherit ros_distro_humble, 这个对应是https://github.com/ros/meta-ros/blob/kirkstone-next/meta-ros2-humble/classes/ros_distro_humble.bbclass ,内容如下:

ROS_DISTRO = "humble"
inherit ${ROS_DISTRO_TYPE}_distro

上面会继承https://github.com/ros/meta-ros/blob/kirkstone-next/meta-ros2/classes/ros2_distro.bbclass

看来没啥毛病,只是我们编译的包没带ros2可执行的文件,突然看到: https://github.com/ros/meta-ros/blob/kirkstone/meta-ros2/recipes-core/packagegroups/packagegroup-ros2-demos.bb

这里面应该会编译出ros2节点所需的例程,在image中加上这个

IMAGE_INSTALL:append = " \
    packagegroup-ros2-demos \
"

上面这个应该就有些东西了,更多的东西应该是在:https://github.com/ros/meta-ros/blob/kirkstone/meta-ros2-humble/下,注意到https://github.com/ros/meta-ros/blob/kirkstone/meta-ros2-humble/recipes-core/packagegroups/packagegroup-ros-world-humble.bb, 原来,我们参考ros-image-world没必要,它是条件触发, 完全可以加上这个包直接编译相关包到镜像中:

IMAGE_INSTALL:append = " \
    packagegroup-ros2-demos \
    packagegroup-ros-world-humble \
"