# Hub Integration

> **Version Warning**
> This documentation is targeted to RVC4 Devices and ROS2 Kilted and upwards. From
> **Kilted**
> onwards, the default ROS driver is v3 and package names are unsuffixed (for example
> `depthai_ros_driver`
> ). On
> **Humble**
> and
> **Jazzy**
> , the equivalent ROS v3 packages use the
> `_v3`
> suffix (for example
> `depthai_ros_driver_v3`
> ). It also assumes you already set up your RVC4 camera using our
> [getting started guide](https://docs.luxonis.com/cloud/hub/connect-oak.md)

## Quickstart - Basic App installation

After setting up your camera, you should be able to see the ROS Packages App category in Hub App Store.

If you install and run it, the camera will run ROS driver onboard and publish RGB, Depth and IMU data. You can inspect and
visualize this data on host PC that is connected to the same network same way you would with a normal ROS running device.

## Developing ROS Apps for RVC4

All examples below can be found in [examples repository](https://github.com/luxonis/oak-examples/tree/main/apps/ros).

## Modifying basic example

Let's take a look how basic example that is published to the store is built. You can find it in ros-driver-basic directory.

What interests us the most are oakapp.toml and parameters.yaml files. In parameters.yaml we can set parameters for the driver as
described in [parameters description article](https://docs.luxonis.com/software-v3/depthai/ros/parameters.md).

```yaml
/**:
  ros__parameters:
    driver:
      i_enable_ir: true
    pipeline_gen:
      i_pipeline_type: RGBD
```

oakapp.toml describes the environment in which our app is running. It uses a base ROS Kilted image in which depthai-ros package is
installed, and to which the parameters file is copied into. After setup, the driver is launched and parameter file is passed into
it.

```toml
identifier = "example.apps.ros.ros-driver-basic"
app_version = "0.9.0"

prepare_container = [
    { type = "COPY", source = "resolv.conf", target = "/etc/resolv.conf" },
    { type = "RUN", command = "apt-get update" },
    { type = "RUN", command = "apt-get install -y ros-kilted-depthai-ros"},
]

prepare_build_container = [

]

build_steps = [
]

entrypoint = ["bash", "-c", "source /opt/ros/kilted/setup.bash && ros2 launch depthai_ros_driver driver.launch.py params_file:=/app/parameters.yaml"]

[base_image]
api_url = "https://registry-1.docker.io" 
service = "registry.docker.io" 
oauth_url = "https://auth.docker.io/token"
auth_type = "repository" 
auth_name = "library/ros"
image_name = "library/ros"
image_tag = "kilted-ros-base"
```

ros-driver-rgb-pcl and ros-driver-spatial-bb examples follow similar logic, they use different launch files and parameters.

```toml
identifier = "example.apps.ros.driver-rgb-pcl"
app_version = "0.9.0"

prepare_container = [
    { type = "COPY", source = "resolv.conf", target = "/etc/resolv.conf" },
    { type = "RUN", command = "apt-get update" },
    { type = "RUN", command = "apt-get install -y ros-kilted-depthai-ros"},
]

prepare_build_container = [

]

build_steps = [
]

entrypoint = ["bash", "-c", "source /opt/ros/kilted/setup.bash && ros2 launch depthai_ros_driver rgbd_pcl.launch.py"]

[base_image]
api_url = "https://registry-1.docker.io" 
service = "registry.docker.io" 
oauth_url = "https://auth.docker.io/token"
auth_type = "repository" 
auth_name = "library/ros"
image_name = "library/ros"
image_tag = "kilted-ros-base"
```

```toml
identifier = "example.apps.ros.driver-spatial-bb"
app_version = "0.9.0"

prepare_container = [
    { type = "COPY", source = "resolv.conf", target = "/etc/resolv.conf" },
    { type = "RUN", command = "apt-get update" },
    { type = "RUN", command = "apt-get install -y ros-kilted-depthai-ros"},
]

prepare_build_container = [

]

build_steps = [
]

entrypoint = ["bash", "-c", "source /opt/ros/kilted/setup.bash && ros2 launch depthai_filters spatial_bb.launch.py"]

[base_image]
api_url = "https://registry-1.docker.io" 
service = "registry.docker.io" 
oauth_url = "https://auth.docker.io/token"
auth_type = "repository" 
auth_name = "library/ros"
image_name = "library/ros"
image_tag = "kilted-ros-base"
```

## Custom workspace and pipeline

Another interesting example is located in ros-driver-custom-workspace. In it we can see how one can develop a full ROS application
performing directly on the device.

As in the previous example, we have oakapp.toml and parameters.yaml files.

Additionally a src directory which corresponds to how src directory is set up in a classical ROS workspace. In it, we have two
packages example_package which is based on a ROS publisher tutorial and contains a custom launch file used for this demonstration.

We can also see dai_ros_plugins package which shows how one could create a custom plugin pipeline which then can be loaded
directly in the driver.

The pipeline plugin type is specified in parameters.yaml file which is passed to the custom launch file.

In oakapp.toml file we can see how our custom workspace is built (directly on the device!) and loaded.

```toml
identifier = "example.apps.ros.driver-custom-workspace"
app_version = "0.9.0"

prepare_container = [
    { type = "COPY", source = "resolv.conf", target = "/etc/resolv.conf" },
    { type = "RUN", command = "apt-get update -qq" },
    { type = "RUN", command = "apt install -y ros2-testing-apt-source"},
    { type = "RUN", command = "apt-get update -qq" },
    { type = "RUN", command = "apt-get install -qy ros-kilted-depthai-ros python3-colcon-common-extensions"},
]

prepare_build_container = [

]

build_steps = [
    "mkdir -p /ws/src",
    "cp -r /app/src/ /ws/",
    'bash -c "cd /ws && source /opt/ros/kilted/setup.bash && colcon build"'
]

entrypoint = ["bash", "-c", "source /ws/install/setup.bash && ros2 launch example_package example.launch.py"]

[base_image]
api_url = "https://registry-1.docker.io" 
service = "registry.docker.io" 
oauth_url = "https://auth.docker.io/token"
auth_type = "repository" 
auth_name = "library/ros"
image_name = "library/ros"
image_tag = "kilted-ros-base"
```
