> ## Documentation Index
> Fetch the complete documentation index at: https://dragonwingdocs.qualcomm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 设置运行示例应用程序的环境

要成功运行 QIR SDK 提供的示例应用程序，您必须在主机环境和设备上完成以下设置，以确保后续步骤的正常运行。

## 设置设备

完成以下配置，使设备准备好运行示例应用程序：

<Tabs>
  <Tab title="IQ-9075 EVK">
    1. 转到 IQ-9075 文档的[设置设备](../../Linux/devices/iq9075-evk/set-up-the-device)。
    2. 完成以下设置：

       a. [设置调试 UART](../../Linux/devices/iq9075-evk/set-up-the-device#set-up-the-debug-uart)。

       b. 按照[连接到网络](../../Linux/devices/iq9075-evk/set-up-the-device#connect-to-the-network)将设备连接到网络。

       c. 按照[通过 SSH 连接](../../Linux/devices/iq9075-evk/set-up-the-device#connect-over-ssh)连接到设备的 SSH shell。
  </Tab>

  <Tab title="IQ-8275 EVK">
    1. 转到 IQ-8275 文档的[设置设备](../../Linux/devices/iq8275-evk/set-up-the-device)。
    2. 完成以下设置：

       a. [设置调试 UART](../../Linux/devices/iq8275-evk/set-up-the-device#set-up-the-debug-uart)。

       b. 按照[连接到网络](../../Linux/devices/iq8275-evk/set-up-the-device#connect-to-the-network)将设备连接到网络。

       c. 按照[通过 SSH 连接](../../Linux/devices/iq8275-evk/set-up-the-device#connect-over-ssh)连接到设备的 SSH shell。
  </Tab>
</Tabs>

## 设置主机

通过在主机和设备上分别运行 `ping <device IP address>`，确保 Ubuntu 主机和设备处于同一网络中。

```python theme={null}
ping <device/host IP address>
```

## **设置主机 Docker**

示例应用程序在主机上使用 ROS 2 Jazzy 进行通信。为了隔离主机 Ubuntu 版本对 ROS 通信的影响，请执行以下步骤配置 Ubuntu 24.04 Docker 环境。

## 前提条件

开始之前，请确保：

* 主机运行的是 Ubuntu 24.04。
* 已安装 Docker Engine。
* Docker 服务正在运行。
* 当前用户属于 `docker` 组。

1. 下载 `qrb_ros_simulation` 仓库和网格文件。
   ```powershell theme={null}
   mkdir -p ~/qrb_ros_simulation_ws
   cd ~/qrb_ros_simulation_ws
   git clone https://github.com/qualcomm-qrb-ros/qrb_ros_simulation.git
   cd qrb_ros_simulation
   git checkout -b 4dec08e7f35905389d7e76c5045a73616b6ec04c
   ```
2. 构建本地 Docker 镜像。

   ```python theme={null}
   chmod +x scripts/docker_build.sh
   bash ./scripts/docker_build.sh
   ```

   <Note>
     **注意**

     如果您在使用 Docker 时遇到问题，请参阅[排查常见问题](./troubleshoot)。
   </Note>
3. 启动 Docker 容器。
   ```python theme={null}
   chmod +x scripts/docker_run.sh
   bash ./scripts/docker_run.sh
   ```
4. 在 Docker 容器中，为 `root` 用户设置密码并启动 SSH 服务。
   ```powershell theme={null}
   # Set the password of user root
   passwd
   # Enable SSH service
   service ssh start
   ```
5. 确定 Docker 容器、开发套件和 X server 都能访问的主机 IP 地址。不要使用 `127.0.0.1`、`localhost` 或仅限 Docker 的网桥地址（如 `docker0`）。在主机上列出接口地址：
   ```bash theme={null}
   ip -4 addr show
   ```
   使用与开发套件处于同一网络的 IP 地址。您可以从设备上验证该地址：
   ```bash theme={null}
   ping <host-interface-ip-address>
   ```
6. 在主机上打开一个新终端，通过 SSH 连接到 Docker 容器。
   ```bash theme={null}
   ssh -X -p 222 root@<host-interface-ip-address>
   ```
7. 配置 ROS 2 环境和显示设置。将 `DISPLAY` 设置为同一个可访问的主机接口地址，因为示例输出将在此处显示。
   ```bash theme={null}
   (ssh) source /opt/ros/jazzy/setup.bash
   (ssh) export DISPLAY=<host-interface-ip-address>:0
   (ssh) export ROS_DOMAIN_ID=123
   (ssh) rqt
   ```

现在，您已构建了 ROS 2 Jazzy 的 Docker 环境。如果环境配置正确，`rqt` 窗口将显示在主机系统上。

<Note>
  **注意**

  有关如何使用 `rqt` 查看示例应用程序的运行效果，请参阅各示例应用程序的步骤。
</Note>

## 后续步骤

* [运行演示应用程序](./run-demo-application)
* [评估更多示例应用程序](./qir-sdk-sample-applications)
* [开发机器人应用程序](./develop-applications-using-the-qir-sdk)
