# 生成和安装 slam-gmapping IPK

Source: [https://docs.qualcomm.com/doc/80-65220-2Y/topic/generate-and-install-slam-gmapping-ipks_5_1_2.html](https://docs.qualcomm.com/doc/80-65220-2Y/topic/generate-and-install-slam-gmapping-ipks_5_1_2.html)

手动生成 slam-gmapping IPK 文件并安装到设备。

## About this task

**生成**

**步骤：**

## Procedure

1. 在 `<workspace>/layers/meta-qcom-robotics/recipes` 目录中创建一个名为 `slam-gmapping` 的文件夹。然后，在 `slam-gmapping` 文件夹中写入两个 recipe：`openslam-gmapping.bb` 和 `slam-gmapping.bb`。
        
openslam-gmapping.bb 示例代码：

        inherit ros_distro_humble
        inherit ros_component
        
        DESCRIPTION = "Openslam gmapping"
        LICENSE = "CreativeCommons-by-nc-sa-2.0"
        LIC_FILES_CHKSUM = "file://package.xml;beginline=8;endline=8;md5=d566ef916e9dedc494f5f793a6690ba5"
        
        DEPENDS += "ament-cmake-native ament-cmake"
        ROS_BRANCH ?= "branch=eloquent-devel"
        SRC_URI = "git://github.com/Project-MANAS/slam_gmapping.git;${ROS_BRANCH};protocol=https"
        SRCREV = "771cfc7eae454aecb4e83c22a0b88656f2880c6c"
        S = "${WORKDIR}/git/openslam_gmapping"
        
        ROS_BUILD_TYPE = "ament_cmake"
        
        inherit ros_${ROS_BUILD_TYPE} robotics-package
        
        FILES:${PN}:prepend = "${datadir}/openslam_gmapping"
        FILES:${PN} += "${libdir}/*"
        
        PACKAGES = "qirf-${PN}"
        
        INSANE_SKIP:${PN} += "installed-vs-shipped"Copy to clipboard

slam-gmapping.bb 示例代码：

        inherit ros_distro_humble
        inherit ros_component
        
        DESCRIPTION = "Slam gmapping"
        LICENSE          = "Qualcomm-Technologies-Inc.-Proprietary"
        LIC_FILES_CHKSUM = "file://package.xml;beginline=13;endline=13;md5=d566ef916e9dedc494f5f793a6690ba5"
        
        DEPENDS += " \
            ament-cmake-native \
            ament-cmake \
            std-msgs \
            nav-msgs \
            tf2 \
            tf2-ros \
            tf2-geometry-msgs \
            message-filters \
            rclcpp \
            sensor-msgs \
            visualization-msgs \
            openslam-gmapping \
        "
        
        CXXFLAGS += "-Wno-format-security"
        
        ROS_BRANCH ?= "branch=eloquent-devel"
        SRC_URI = "git://github.com/Project-MANAS/slam_gmapping.git;${ROS_BRANCH};protocol=https"
        SRCREV = "771cfc7eae454aecb4e83c22a0b88656f2880c6c"
        S = "${WORKDIR}/git/slam_gmapping"
        
        ROS_BUILD_TYPE = "ament_cmake"
        
        inherit ros_${ROS_BUILD_TYPE} robotics-package
        
        FILES:${PN}:prepend = "${datadir}/slam_gmapping"
        FILES:${PN} += "${libdir}/*"
        
        PACKAGES = "qirf-${PN}"
        
        INSANE_SKIP:${PN} += "installed-vs-shipped"Copy to clipboard
2. 使用 Yocto 机制来编译这两个 recipe。通过编译会在相关的编译目录中生成 IPK。
        
cd <workspace>
        MACHINE=qcm6490 DISTRO=qcom-robotics-ros2-humble source setup-robotics-environment
        bitbake openslam-gmapping -c do_package_write_ipk
        bitbake slam-gmapping -c do_package_write_ipk
        Copy to clipboard

生成以下 IPK `<slam-gmapping.ipks>`：

    - `<workspace>/build-qcom-robotics-ros2-humble/tmp-glibc/work/armv8-2a-qcom-linux/openslam-gmapping/1.0-r0/deploy-ipks/armv8-2a/qirf-openslam-gmapping_1.0-r0_armv8-2a.ipk`
    - `<workspace>/build-qcom-robotics-ros2-humble/tmp-glibc/work/armv8-2a-qcom-linux/slam-gmapping/1.0-r0/deploy-ipks/armv8-2a/qirf-slam-gmapping_1.0-r0_armv8-2a.ipk`

## Results

**安装**

**步骤：**

1. 将 IPK 文件安装到设备。

        scp <slam_gmapping.ipks> root@[ip-addr]:/opt/
        ssh root@[ip-addr]
        (ssh) cd /opt/
        (ssh) opkg install --force-reinstall --force-overwrite --force-depends *.ipkCopy to clipboard
2. 在 `/opt/qcom/qirf-sdk/usr/share/slam_gmapping/launch` 文件夹中，按以下所示修改 `slam_gmapping.launch.py`。然后，`slam_gmapping` 节点将可正常运行。

        from launch import LaunchDescription
        from launch.substitutions import EnvironmentVariable
        import launch.actions
        import launch_ros.actions
        
        def generate_launch_description():
            use_sim_time = launch.substitutions.LaunchConfiguration('use_sim_time', default='false')
            return LaunchDescription([
                launch_ros.actions.Node(
                    package='slam_gmapping', executable='slam_gmapping', output='screen', parameters=[{'use_sim_time':use_sim_time}]),
            ])Copy to clipboard

**Parent Topic:** [搭建示例程序的 runtime 环境](https://docs.qualcomm.com/doc/80-65220-2Y/topic/set-up-the-runtime-environment-for-samples_5_1.html)

Last Published: Aug 09, 2024

[Previous Topic
搭建示例程序的 runtime 环境](https://docs.qualcomm.com/bundle/publicresource/80-65220-2Y/topics/set-up-the-runtime-environment-for-samples_5_1.md) [Next Topic
安装 Rviz2](https://docs.qualcomm.com/bundle/publicresource/80-65220-2Y/topics/install-rviz2_5_1_3.md)