Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker #6

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ utils::ReturnCode RecorderWriter::write_(
}
catch(const utils::Exception& e)
{
logError(
logWarning(
DDSRECORDER_RECORDER_WRITER,
"Error storing data: <" << e.what() << ">.\nContinue recording...");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ utils::ReturnCode TypeObjectWriter::write_(
// TODO: this will call multiple times to generate_type_object_schema unnecesary
// Add this type object as a new schema
mcap_handler_->add_schema(type_name, recorder::generate_dyn_type_schema(dyn_type));

logUser(DDSRECORDER_RECORDER_WRITER,
"Type Object " << type_name << " stored.");
}
catch(const utils::Exception& e)
{
Expand Down
58 changes: 58 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#########################################################################################
# DDS Recorder Demos Dockerfile
#########################################################################################

FROM ubuntu:jammy

# Avoids using interactions during building
ENV DEBIAN_FRONTEND=noninteractive

# Use a bash shell so it is possigle to run things like `source` (required for colcon builds)
SHELL ["/bin/bash", "-c"]

# Avoid interactuation with installation of some package that needs the locale.
ENV TZ=Europe/Madrid
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

# Download DDS Recorder dependencies
RUN apt update && \
apt install -y \
cmake \
g++ \
pip \
wget \
git \
libasio-dev \
libtinyxml2-dev \
libssl-dev \
libyaml-cpp-dev \
liblz4-dev \
libzstd-dev && \
pip3 install -U colcon-common-extensions vcstool

# Download eProsima dependencies
WORKDIR /ddsrecorder
RUN wget https://raw.githubusercontent.com/eProsima/DDS-Recorder/feature/docker/docker/recorder.repos && \
mkdir src && \
vcs import src < recorder.repos

# Build DDS Recorder
RUN colcon build

# Add DDS Recorder configuration files
COPY resources resources

# Build TypeIntrospection example
WORKDIR /dyn_types_example
RUN cp -r /ddsrecorder/src/fastdds/examples/cpp/dds/TypeIntrospectionExample/* . && \
source /ddsrecorder/install/setup.bash && \
mkdir build && \
cd build && \
cmake .. && \
make

# Source built workspace
RUN echo "source /ddsrecorder/install/setup.bash" >> ~/.bashrc

# Restore working directory to default
WORKDIR /
98 changes: 98 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# eProsima DDS Recorder docker Image

This image is installed with a DDS Recorder Prototype that is able to run a `DDS Recorder` application
Fast DDS, DDS Recorder and all dependencies are already installed in the image.
In order to run the image use the following command.

---

## DDS Recorder Tool

This tool is a CLI tool with several arguments and configured by a `.yaml` file.
This tool subscribes to allowed DDS Topics and record the data received in a `.mcap` file.
The schemas to deserialize this data in FoxGlove are also written in the `.mcap` file in `.msg` ROS 2 format.
Those schemas are generated when the tool has access to the Type Object or Type Identifier of the Data Type used.

### How to retrieve Data Type to the tool

Fast DDS does not send the Data Type information by default, it must be configured to do so.
First of all, when generating the Types using Fast DDS Gen, the option `-typeobject` must be added in order to generate the needed code to fill the TypeObject data.

For native types (Data Types that does not rely in other Data Types) this is enough, as Fast DDS will send the TypeObject by default.
However, for more complex types, it is required to use `TypeInformation` mechanism.
In the Fast DDS `DomainParticipant` set the following QoS in order to send this information:

```cpp
DomainParticipantQos pqos;
pqos.wire_protocol().builtin.typelookup_config.use_server = true;
```

---

## Run DDS Recorder

There are some configurations already available in the container under directory `/ddsrecorder/resources/`

- `simple_configuration.yaml` Configuration with just the basics to run the executable.
- `complete_configuration.yaml` Configuration with all the possible configurations available.

In order to execute the `DDS Recorder` use the following command:
```bash
ddsrecorder --config-path /ddsrecorder/resources/<configuration>.yaml
```

In order to know all the possible arguments supported by this tool, use the command:
```bash
ddsrecorder --help` or `ddsrecorder -h
```

In order to see further information and debugging info about what the tool is executing, use the argument `--debug`:
```bash
ddsrecorder --config-path /ddsrecorder/resources/<configuration>.yaml --debug
```

### Use Custom Configurations

There are 2 ways to write a custom configuration:

1. Modify a `.yaml` file within the container instance.
2. Using shared volumes to share the `.yaml` configuration file.

### Run with shared volume

In order to automatically retrieve every `.mcap` file generated inside the container, use a docker volume.
Run the following command to share your local `<shared/folder> and container `<shared/folder>`.

```bash
docker run -it --net=host --ipc=host --privileged --volume $(pwd)/<shared/folder>/:<shared/folder> ddsrecorder:v0.1.0
```


### Connectivity issues

- `--net=host` allow the DDS Recorder to connect with external (different device) participants.
- `--ipc=host` allow the DDS Recorder to use Shared Memory Transport with the participants in the same host.

If local Participants (same host) are unable to connect with the DDS Recorder inside a Docker, it may be because they try to use Shared Memory, but the docker has no access to the same shared segment.
To avoid this, run the other participants as `root` or change the docker image user name to be the same as the external participants one.
Other option may be to not using Shared Memory by disabling it by Fast DDS configuration (by XML or QoS in code) or by CMake option when compiling `-DSHM_TRANSPORT_DEFAULT=ON`.

---

## Configuration

This first version does support the following configurations:

| | Description | Type | Default |
|---------------|-------------------------------------------------------------|----------------|-----------|
| allowlist | List of topics that are going to be recorded | List of topics | Empty |
| blocklist | List of topics that are **not** going to be recorded | List of topics | Empty |
| domain | DDS Domain to discover and subscribe to topics allowed | integer | 0 |
| extension | File extension for the result file | string | .mcap |
| filename | File name for the result file | string | MANDATORY |
| path | Path to result file | string | ./ |
| use-timestamp | Whether to add or not the timestamp to the result file name | bool | true |

The topics in `allowlist` and `blocklist` are filled with elements with field `name` referring to the Topic name.
Optionally each element can have the element `type` referring to the Topic Data Type name.
Both name and allow wildcards (`*`).
14 changes: 14 additions & 0 deletions docker/__internal_info__.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Instructions to build the Docker image

## Branches

- Fast DDS: `bugfix/complex-dynamic-types`
- DDS Recorder: `prototype`

## Commands

build
```sh
# Build docker image
docker build --rm -t ddsrecorder:figure -f Dockerfile .
```
21 changes: 21 additions & 0 deletions docker/recorder.repos
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
repositories:
foonathan_memory_vendor:
type: git
url: https://github.com/eProsima/foonathan_memory_vendor.git
version: master
fastcdr:
type: git
url: https://github.com/eProsima/Fast-CDR.git
version: master
fastdds:
type: git
url: https://github.com/eProsima/Fast-DDS.git
version: bugfix/complex-dynamic-types
dev-utils:
type: git
url: https://github.com/eProsima/dev-utils.git
version: main
ddsrecorder:
type: git
url: https://github.com/eProsima/DDS-Recorder.git
version: prototype
16 changes: 16 additions & 0 deletions docker/resources/complete_configuration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Allowed topics - Optional (Default: "*")
allowlist:
- name: "*"

# Blocked topics - Optional (Default: empty)
blocklist:
- name: "add_blocked_topics_list_here"

# DDS Domain - Optional (Default: 0)
domain: 0

# Recorder output file
extension: ".mcap" # Optional (Default: ".mcap")
path: "." # Optional (Default: ".")
filename: "output" # Required
use-timestamp: true # Optional (Default: true)
6 changes: 6 additions & 0 deletions docker/resources/simple_configuration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# DDS Domain - Optional (Default: 0)
domain: 0

# Recorder output file
filename: "output" # Required
use-timestamp: false # Optional (Default: true)