此页面由 AI 自动翻译。查看英文原版

本页目录

  • 快速入门 - 基本应用安装
  • 为 RVC4 开发 ROS 应用
  • 修改基本示例
  • 自定义工作空间和管道

Hub 集成

快速入门 - 基本应用安装

设置好相机后,您应该能在 Hub 应用商店中看到 ROS Packages 应用类别。如果安装并运行它,相机将在设备上运行 ROS 驱动程序,并发布 RGB、深度和 IMU 数据。您可以在连接到同一网络的宿主机 PC 上检查和可视化这些数据,就像处理普通 ROS 运行设备一样。

为 RVC4 开发 ROS 应用

下方所有示例均可在 examples repository 中找到

修改基本示例

让我们看看商店中发布的基本示例是如何构建的。您可以在 ros-driver-basic 目录中找到它。最让我们感兴趣的是 oakapp.tomlparameters.yaml 文件。在 parameters.yaml 中,我们可以按照 参数描述文章 中的说明设置驱动程序的参数。
Yaml
1/**:
2  ros__parameters:
3    driver:
4      i_enable_ir: true
5    pipeline_gen:
6      i_pipeline_type: RGBD
oakapp.toml 描述了我们的应用程序运行的环境。它使用一个已安装 depthai-ros 包的基础 ROS Kilted 镜像,并将参数文件复制到其中。设置完成后,将启动驱动程序并将参数文件传递给它。
Toml
1identifier = "example.apps.ros.ros-driver-basic"
2app_version = "0.9.0"
3
4prepare_container = [
5    { type = "COPY", source = "resolv.conf", target = "/etc/resolv.conf" },
6    { type = "RUN", command = "apt-get update" },
7    { type = "RUN", command = "apt-get install -y ros-kilted-depthai-ros"},
8]
9
10prepare_build_container = [
11
12]
13
14build_steps = [
15]
16
17entrypoint = ["bash", "-c", "source /opt/ros/kilted/setup.bash && ros2 launch depthai_ros_driver driver.launch.py params_file:=/app/parameters.yaml"]
18
19[base_image]
20api_url = "https://registry-1.docker.io" 
21service = "registry.docker.io" 
22oauth_url = "https://auth.docker.io/token"
23auth_type = "repository" 
24auth_name = "library/ros"
25image_name = "library/ros"
26image_tag = "kilted-ros-base"
ros-driver-rgb-pclros-driver-spatial-bb 示例遵循类似的逻辑,它们使用不同的启动文件和参数。
Toml
1identifier = "example.apps.ros.driver-rgb-pcl"
2app_version = "0.9.0"
3
4prepare_container = [
5    { type = "COPY", source = "resolv.conf", target = "/etc/resolv.conf" },
6    { type = "RUN", command = "apt-get update" },
7    { type = "RUN", command = "apt-get install -y ros-kilted-depthai-ros"},
8]
9
10prepare_build_container = [
11
12]
13
14build_steps = [
15]
16
17entrypoint = ["bash", "-c", "source /opt/ros/kilted/setup.bash && ros2 launch depthai_ros_driver rgbd_pcl.launch.py"]
18
19[base_image]
20api_url = "https://registry-1.docker.io" 
21service = "registry.docker.io" 
22oauth_url = "https://auth.docker.io/token"
23auth_type = "repository" 
24auth_name = "library/ros"
25image_name = "library/ros"
26image_tag = "kilted-ros-base"
Toml
1identifier = "example.apps.ros.driver-spatial-bb"
2app_version = "0.9.0"
3
4prepare_container = [
5    { type = "COPY", source = "resolv.conf", target = "/etc/resolv.conf" },
6    { type = "RUN", command = "apt-get update" },
7    { type = "RUN", command = "apt-get install -y ros-kilted-depthai-ros"},
8]
9
10prepare_build_container = [
11
12]
13
14build_steps = [
15]
16
17entrypoint = ["bash", "-c", "source /opt/ros/kilted/setup.bash && ros2 launch depthai_filters spatial_bb.launch.py"]
18
19[base_image]
20api_url = "https://registry-1.docker.io" 
21service = "registry.docker.io" 
22oauth_url = "https://auth.docker.io/token"
23auth_type = "repository" 
24auth_name = "library/ros"
25image_name = "library/ros"
26image_tag = "kilted-ros-base"

自定义工作空间和管道

另一个有趣的示例位于 ros-driver-custom-workspace 中。在此示例中,我们可以看到如何开发一个直接在设备上运行的完整 ROS 应用程序。与前面的示例一样,我们有 oakapp.tomlparameters.yaml 文件。此外,还有一个 src 目录,对应于经典 ROS 工作空间中 src 目录的设置方式。其中,我们有两个包:example_package(基于 ROS publisher 教程)包含用于此演示的自定义启动文件。我们还可以看到 dai_ros_plugins 包,它展示了如何创建自定义插件管道,然后可以直接在驱动程序中加载。管道插件类型在传递给自定义启动文件的 parameters.yaml 文件中指定。oakapp.toml 文件中,我们可以看到我们的自定义工作空间是如何构建(直接在设备上!)和加载的。
Toml
1identifier = "example.apps.ros.driver-custom-workspace"
2app_version = "0.9.0"
3
4prepare_container = [
5    { type = "COPY", source = "resolv.conf", target = "/etc/resolv.conf" },
6    { type = "RUN", command = "apt-get update -qq" },
7    { type = "RUN", command = "apt install -y ros2-testing-apt-source"},
8    { type = "RUN", command = "apt-get update -qq" },
9    { type = "RUN", command = "apt-get install -qy ros-kilted-depthai-ros python3-colcon-common-extensions"},
10]
11
12prepare_build_container = [
13
14]
15
16build_steps = [
17    "mkdir -p /ws/src",
18    "cp -r /app/src/ /ws/",
19    'bash -c "cd /ws && source /opt/ros/kilted/setup.bash && colcon build"'
20]
21
22entrypoint = ["bash", "-c", "source /ws/install/setup.bash && ros2 launch example_package example.launch.py"]
23
24[base_image]
25api_url = "https://registry-1.docker.io" 
26service = "registry.docker.io" 
27oauth_url = "https://auth.docker.io/token"
28auth_type = "repository" 
29auth_name = "library/ros"
30image_name = "library/ros"
31image_tag = "kilted-ros-base"