Skip to content

Commit

Permalink
Merge pull request #1702 from FIWARE/demo/ros2
Browse files Browse the repository at this point in the history
ros2 demo files
  • Loading branch information
kzangeli authored Oct 27, 2024
2 parents 36a8d17 + df1c12c commit 25fcdcd
Show file tree
Hide file tree
Showing 5 changed files with 189 additions and 0 deletions.
68 changes: 68 additions & 0 deletions demo/ros2/README.md
Original file line number Diff line number Diff line change
@@ -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"

48 changes: 48 additions & 0 deletions demo/ros2/demo-docker-compose/config-dds.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
}
}
52 changes: 52 additions & 0 deletions demo/ros2/demo-docker-compose/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -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


18 changes: 18 additions & 0 deletions demo/ros2/demo-dockerfile/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]

3 changes: 3 additions & 0 deletions scripts/check_files_compliance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 25fcdcd

Please sign in to comment.