forked from telefonicaid/fiware-orion
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1702 from FIWARE/demo/ros2
ros2 demo files
- Loading branch information
Showing
5 changed files
with
189 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters