diff --git a/demo/ros2/README.md b/demo/ros2/README.md new file mode 100644 index 0000000000..76ed1d2440 --- /dev/null +++ b/demo/ros2/README.md @@ -0,0 +1,68 @@ +# Demo ROS2 < - > NGSI-LD context Broker + +The demo is structured in 2 directories: + - `demo-dockerfile` + - `demo-docker-compose` + +## Make a precompiled docker image +This is convenient if you mean to run the demo more than once. +This is the reason the Dockerfile is needed. +To create the docker image with precompiled software, run: +``` +cd demo-dockerfile +docker build -t ros2 . +``` + +After this, you have a Docker image with all the needed Ros2 components for the demo, including the TurtleSim. + +Please, note that this image is a commodity image which makes running the software easier. + +## Starting the demo +Before starting the demo, as X11 session owners, other users must be allowed to use the X Window System (to show the +turtles on screen). +For that, the following command is executed: + +``` +xhost local:root +``` + +Once that is done done (only needed the first time), the containers can be started: +``` +cd demo-docker-compose +docker compose up -d +``` + +When the dockers have started, connect to bash in the container of ros2: +``` +docker exec -ti ros2 bash +``` + +### Turtles +Now the TurtleSim and the Keyboard controller can be started: + +``` +source /ros2-ws/install/setup.bash + +# Show the turtles on the screen +ros2 run docs_turtlesim turtlesim_node_keys & + +# Keyboard controller to move the turtles. +ros2 run docs_turtlesim turtlesim_multi_control +``` + +# About the broker +The file `demo-docker-compose/config-dds.json` is mounted in Orion-LD's container. +This is the file that must be configured with the conversion from DDS topic to Entity ID+Tupe and Attribute Name, for Orion-LD. +When the docker is started, this file is used inside Orion-LD's container as its configuration file (`/root/.orionld`). +Orionld's docker is exporting port 1026 - It can be accessed from any terminal as `locahost:1026` + + +# Restart +Typically, the configuration file of Orion-LD will be updated and the whole thing needs to be restarted. +Kill the system like this: +``` +cd demo-docker-compose +docker compose down +``` +Then follow (again) the instructions of "Starting the demo" + diff --git a/demo/ros2/demo-docker-compose/config-dds.json b/demo/ros2/demo-docker-compose/config-dds.json new file mode 100644 index 0000000000..02e226d7c0 --- /dev/null +++ b/demo/ros2/demo-docker-compose/config-dds.json @@ -0,0 +1,48 @@ +{ + "dds": { + "ddsmodule": { + "dds": { + "domain": 0, + "allowlist": [ + { + "name": "*" + } + ], + "blocklist": [ + { + "name": "add_blocked_topics_list_here" + } + ] + }, + "topics": { + "name": "*", + "qos": { + "durability": "TRANSIENT_LOCAL", + "history-depth": 10 + } + }, + "ddsenabler": null, + "specs": { + "threads": 12, + "logging": { + "stdout": false, + "verbosity": "info" + } + } + }, + "ngsild": { + "topics": { + "rt/cmd_vel": { + "entityType": "Robot", + "entityId": "urn:ngsi-ld:robot:1", + "attribute": "velocityCommand" + }, + "rt/pose": { + "entityType": "Robot", + "entityId": "urn:ngsi-ld:robot:1", + "attribute": "pose" + } + } + } + } +} diff --git a/demo/ros2/demo-docker-compose/docker-compose.yaml b/demo/ros2/demo-docker-compose/docker-compose.yaml new file mode 100644 index 0000000000..636351ab67 --- /dev/null +++ b/demo/ros2/demo-docker-compose/docker-compose.yaml @@ -0,0 +1,52 @@ +services: + ros2: + image: ros2 + hostname: ros2 + container_name: ros2 + privileged: true + ipc: host + networks: + - arise-demo-network + environment: + DISPLAY: ":0.0" + volumes: + - /tmp/.X11-unix:/tmp/.X11-unix + + orion-ld: + image: quay.io/fiware/orion-ld + hostname: orion-ld + container_name: orion-ld + privileged: true + ipc: host + networks: + - arise-demo-network + expose: + - 1026 + ports: + - 1026:1026 + depends_on: + - mongo-db + command: -dbhost mongo-db -wip dds -logLevel DEBUG + # -mongocOnly + volumes: + - ./config-dds.json:/root/.orionld + + mongo-db: + image: mongo:5.0 + hostname: mongo-db + container_name: mongo-db + networks: + - arise-demo-network + expose: + - 27017 + ports: + - 27017:27017 + command: --nojournal + volumes: + - ./data/db:/data/db + +networks: + arise-demo-network: + driver: bridge + + diff --git a/demo/ros2/demo-dockerfile/Dockerfile b/demo/ros2/demo-dockerfile/Dockerfile new file mode 100644 index 0000000000..139486c5f1 --- /dev/null +++ b/demo/ros2/demo-dockerfile/Dockerfile @@ -0,0 +1,18 @@ +FROM eprosima/vulcanexus:jazzy-desktop + +RUN mkdir -p /ros2-ws/src +WORKDIR /ros2-ws/src + +RUN apt update && \ + apt install -y x11-apps + +RUN git clone --depth=1 https://github.com/eProsima/vulcanexus.git tmp_dir + +RUN mv tmp_dir/code/turtlesim . +RUN rm -rf tmp_dir +WORKDIR /ros2-ws +RUN source /opt/vulcanexus/jazzy/setup.bash && \ + colcon build + +ENTRYPOINT ["/bin/bash", "-c", "sleep infinity"] + diff --git a/scripts/check_files_compliance.py b/scripts/check_files_compliance.py index c2ac4e1c80..dfaec93ab8 100755 --- a/scripts/check_files_compliance.py +++ b/scripts/check_files_compliance.py @@ -137,6 +137,9 @@ def ignore(root, file): if 'ldcontext' in root: return True + if 'demo' in root: + return True + # PNG files in manuals o functionalTest are ignored if ('manuals' in root or 'functionalTest' in root or 'apiary' in root) and file.endswith('.png'): return True