|
1 | 1 | # roft-samples
|
2 | 2 |
|
3 |
| -A suite of applications based on [ROFT](https://github.com/hsp-iit/roft). |
4 |
| - |
5 |
| -## Run the dockerized environment |
6 |
| -1. Build the docker image: |
7 |
| - ```console |
8 |
| - cd dockerfiles |
9 |
| - bash build.sh # This will create an image named roft-samples-image |
10 |
| - ``` |
11 |
| - > It is important to build the image on the target machine to ensure efficiency on the target platform. |
12 |
| -1. Run the container: |
13 |
| - ```console |
14 |
| - cd dockerfiles |
15 |
| - bash run.sh # This will create and enter inside a container named roft-samples-cnt |
16 |
| - ``` |
17 |
| - > Warning: This run command uses `--privileged` and `--volume=/dev:/dev` to simplify using the RealSense from within the docker. Please be careful. |
18 |
| - |
19 |
| - > You might need to `xhost +` your host to allow the container accessing the X server. |
20 |
| - |
21 |
| - > If you need to open multiple sessions within the container you can simply use `docker exec -it roft-samples-cnt bash`. |
22 |
| - |
23 |
| -After the first run, you might access the container again using `docker start roft-samples-cnt` and `docker exec -it roft-samples-cnt bash`. |
24 |
| - |
25 |
| -Once inside the container, run `yarpmanager` and refer to the applications `ROFT` and `ROFT_Handover_with_iCub`. |
| 3 | +This repository hosts the code for running a sample application using [ROFT](https://github.com/hsp-iit/roft) and the `iCub` robot. |
| 4 | + |
| 5 | +It allows tracking objects with the robot gaze and interact with it via handover actions in real-time: |
| 6 | + |
| 7 | +<p align="center"><img src="https://github.com/hsp-iit/roft-samples/blob/master/assets/demo.webp"/></p> |
| 8 | + |
| 9 | + |
| 10 | +The application needs: |
| 11 | +1. a robot control module |
| 12 | +2. an instance of the ROFT 6D object pose tracker |
| 13 | +3. a segmentation algorithm |
| 14 | +4. a 6D object pose estimation algorithm |
| 15 | + |
| 16 | +We provide (1) and (2) within this repository in the form of a docker container. |
| 17 | +A secondary container hosts (3) and (4) but it is not public yet, at the moment. |
| 18 | + |
| 19 | + |
| 20 | +## Build the docker image for (1) and (2) |
| 21 | + |
| 22 | +Build the docker image: |
| 23 | +```console |
| 24 | +cd dockerfiles |
| 25 | +bash build.sh # This will create an image named roft-samples-image |
| 26 | +``` |
| 27 | + |
| 28 | +## Build the docker image for (3) and (4) |
| 29 | +Not available at the moment. |
| 30 | + |
| 31 | +## Setup a cluster with two machines |
| 32 | + |
| 33 | +Here we provide instructions on how to setup a cluster of two machines `machine_1` and `machine_2` (of course other configurations are possible). |
| 34 | +- `machine_1` needs: |
| 35 | + - an NVIDIA optical flow-enabled GPU (most GeForce RTX >= 20x0 cards) |
| 36 | + - the `roft-samples-image` docker image available |
| 37 | + - a docker engine (the most updated possible) |
| 38 | +- `machine_2` needs: |
| 39 | + - two NVIDIA GPUs for running segmentation and pose estimation modules |
| 40 | + - the `ghcr.io/hsp-iit/ycb-pretrained-cv-models` docker image available (to be made available to users soon) |
| 41 | + - a docker engine |
| 42 | + |
| 43 | +### Swarm setup |
| 44 | +First we need to setup a `docker swarm` cluster with `machine_1` the leader and `machine_2` a worker: |
| 45 | + |
| 46 | +On `machine_1`: |
| 47 | +```console |
| 48 | +docker swarm init |
| 49 | +docker swarm join-token worker |
| 50 | +``` |
| 51 | + |
| 52 | +The output of the second command shall be copy-pasted on `machine_2`. After that, verify that all nodes are visible by issuing `docker node ls` on `machine_1`. |
| 53 | + |
| 54 | +### Label assignment |
| 55 | +For simplicity, we assign labels to the two machines as we use this mechanism to assign containers - and possibly swap `machine_1` and/or `machine_2` with others providing the same requirements if needed. |
| 56 | + |
| 57 | +On `machine_1`: |
| 58 | +```console |
| 59 | +docker node update --label-add roft_deployer=true <machine_1_hostname> |
| 60 | +docker node update --label-add ycb_cv_deployer=true <machine_2_hostname> |
| 61 | +``` |
| 62 | + |
| 63 | +### GPUs configuration |
| 64 | + |
| 65 | +We need to make the cluster aware of the GPUs available on each worker. For each machine do the following. |
| 66 | + |
| 67 | +Find the GPU ids first: |
| 68 | + |
| 69 | +```console |
| 70 | +nvidia-smi -a | grep UUID | awk '{print substr($4,0,12)}' |
| 71 | +``` |
| 72 | + |
| 73 | +Then edit `/etc/docker/daemon.json` such that it looks like: |
| 74 | +```json |
| 75 | +{ |
| 76 | + "runtimes": { |
| 77 | + "nvidia": { |
| 78 | + "path": "/usr/bin/nvidia-container-runtime", |
| 79 | + "runtimeArgs": [] |
| 80 | + } |
| 81 | + }, |
| 82 | + "default-runtime": "nvidia", |
| 83 | + "node-generic-resources": [ |
| 84 | + "NVIDIA-GPU=<gpu_id_0>", |
| 85 | + "NVIDIA-GPU=<gpu_id_1>" |
| 86 | + ] |
| 87 | +} |
| 88 | +``` |
| 89 | + |
| 90 | +where `<gpu_id_x>` are provided by the output of the previous command. |
| 91 | + |
| 92 | +Then enable GPU advertising by uncommenting the line `swarm-resource = "DOCKER_RESOURCE_GPU"` in `/etc/nvidia-container-runtime/config.toml`. |
| 93 | + |
| 94 | +Finally, restart docker by issuing `sudo systemctl restart docker.service`. |
| 95 | + |
| 96 | +Nodes can be inspected using `docker node inspect <node_name>` to verify that the GPUs are correctly exposed. |
| 97 | + |
| 98 | +## Deploy the stack |
| 99 | + |
| 100 | +We assume that a `yarpserver` is already running within the network on port `10000`. Please insert the IP address of the server in: https://github.com/hsp-iit/roft-samples/blob/fa4bb5ce925ba611dac09a3edb6be04031417760/dockercompose/docker-compose.yml#L10 |
| 101 | + |
| 102 | +Then do the following: |
| 103 | + |
| 104 | +```console |
| 105 | +cd roft-samples/dockercompose |
| 106 | +docker stack deploy -c docker-compose.yml roft-samples-handover-stack |
| 107 | +``` |
| 108 | + |
| 109 | +After that, an instance of `yarpmanager` will open automatically on a `roft-deployer` while the segmentation and pose estimation modules will be running within a `ycb_cv_deployer` headlessly. |
| 110 | + |
| 111 | +In the `yarpmanager` above please open the application `ROFT Handover with iCub (embedded)` and just `run all` + `connect all`. Some modules / ports might remain unavailable - those are used to add speech functionality to the appliation and are optional. |
| 112 | + |
| 113 | +To stop the stack simply do |
| 114 | +``` |
| 115 | +docker stack rm roft-samples-handover-stack |
| 116 | +``` |
| 117 | + |
0 commit comments