Skip to content

Commit

Permalink
Merge pull request #75 from eProsima/develop
Browse files Browse the repository at this point in the history
Release 2.0.0
  • Loading branch information
pablogs9 committed Mar 29, 2021
2 parents 441b497 + 1157972 commit 21a253d
Show file tree
Hide file tree
Showing 29 changed files with 1,512 additions and 152 deletions.
17 changes: 13 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()

project(microxrcedds VERSION "1.3.1")
project(microxrcedds VERSION "2.0.0")

set(_client_tag v1.2.5)
set(_agent_tag v1.4.1)
set(_gen_tag v1.1.0)
set(_client_tag master)
set(_client_version 2.0.0)
set(_agent_tag master)
set(_gen_tag master)

###############################################################################
# Build options.
Expand All @@ -41,6 +42,7 @@ option(UXRCE_ENABLE_CLIENT "Enable the building and installation of Micro XRCE-D
option(UXRCE_ENABLE_AGENT "Enable the building and installation of Micro XRCE-DDS Agent." ON)
option(UXRCE_ENABLE_GEN "Enable the building and installation of Micro XRCE-DDS Gen." OFF)
option(UXRCE_BUILD_TESTS "Build tests." OFF)
option(UXRCE_BUILD_PROFILING "Build profiling test executables.")

option(UXRCE_BUILD_CI_TESTS "Build CI tests." OFF)
if(UXRCE_BUILD_CI_TESTS)
Expand Down Expand Up @@ -149,6 +151,9 @@ if(UXRCE_ENABLE_AGENT)
-DLIB_INSTALL_DIR:PATH=${LIB_INSTALL_DIR}
-DDATA_INSTALL_DIR:PATH=${DATA_INSTALL_DIR}
-DUAGENT_BUILD_TESTS:BOOL=${UXRCE_BUILD_TESTS}
-DUAGENT_P2P_CLIENT_TAG:STRING=${_client_tag}
-DUAGENT_P2P_CLIENT_VERSION:STRING=${_client_version}
-DUAGENT_BUILD_EXECUTABLE:BOOL=OFF
-DUAGENT_ISOLATED_INSTALL:BOOL=OFF
-DGTEST_INDIVIDUAL:BOOL=ON
DEPENDS
Expand Down Expand Up @@ -235,6 +240,10 @@ if(UXRCE_BUILD_TESTS)
)
endif()

if(UXRCE_BUILD_PROFILING)
add_subdirectory(test/profiling)
endif()

###############################################################################
# Install
###############################################################################
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ RUN cd /uxrce/build && \
-DCMAKE_INSTALL_PREFIX=../install \
-DUXRCE_BUILD_EXAMPLES=ON \
.. &&\
make && make install
make -j $(nproc) && make install

# Prepare Micro XRCE-DDS artifacts
RUN cd /uxrce && \
Expand Down
31 changes: 21 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,34 @@

<a href="http://www.eprosima.com"><img src="https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcSd0PDlVz1U_7MgdTe0FRIWD0Jc9_YH-gGi0ZpLkr-qgCI6ZEoJZ5GBqQ" align="left" hspace="8" vspace="2" width="100" height="100" ></a>

*eProsima Micro XRCE-DDS* is a software solution which allows to communicate eXtremely Resource Constrained Environments (XRCEs) with an existing DDS network.
This implementation complies with the specification proposal, "eXtremely Resource Constrained Environments DDS (DDS-XRCE)" submitted to the Object Management Group (OMG) consortium.
*eProsima Micro XRCE-DDS* is a library implementing the [DDS-XRCE protocol](https://www.omg.org/spec/DDS-XRCE/About-DDS-XRCE/) as defined and maintained by the OMG, whose aim is to allow resource constrained devices such as microcontrollers to communicate with the [DDS](https://www.omg.org/spec/DDS/About-DDS/>) world as any other DDS actor would do.
It follows a client/server paradigm and is composed by two libraries, the *Micro XRCE-DDS Client* and the *Micro XRCE-DDS Agent*. The *Micro XRCE-DDS Clients* are lightweight entities meant to be compiled on e**X**tremely **R**esource **C**onstrained **E**nvironments, while the *Micro XRCE-DDS Agent* is a broker which bridges the *Clients* with the DDS world.

*Micro XRCE-DDS* implements a client-server protocol to enable resource-constrained devices (clients) to take part in DDS communications.
*Micro XRCE-DDS Agent* (server) makes possible this communication.
The *Micro XRCE-DDS Agent* acts on behalf of the *Micro XRCE-DDS Clients* and enables them to take part as DDS publishers and/or subscribers in the DDS Global Data Space.
*Micro XRCE-DDS* provides both, a plug and play *Micro XRCE-DDS Agent* and an API layer which allows you to implement your *Micro XRCE-DDS Clients*.
<p align="center"> <img src="docs/Concept.png" alt="Image" width="90%"/> </p>

<p align="center"> <img src="docs/xrcedds_architecture.png" alt="Image"/> </p>
The *Micro XRCE-DDS Clients* request operations to the *Agent* to publish and/or subscribe to topics in the DDS global dataspace. Remote procedure calls, as defined by the [DDS-RPC standard](https://www.omg.org/spec/DDS-RPC/About-DDS-RPC/), are also supported, allowing *Clients* to communicate in the DDS dataspace according to a request/reply paradigm.
The *Agents* process these requests and send back a response with the operation status result and with the requested data, in the case of subscribe/reply operations.

This repository contains the totality of *Micro XRCE-DDS* products:
*eProsima Micro XRCE-DDS* provides the user with a C API to create *Micro XRCE-DDS Clients* applications. The library can be configured at compile-time via a set of CMake flags allowing to enable or disable some profiles before compilation, and to manipulate several parameters controlling some of the library's functionalities, which in turn allow tuning the library size.

<p align="center"> <img src="docs/general_architecture.png" alt="Image"/> </p>
The *Micro XRCE-DDS Agent* receives messages containing request operations from the *Clients*, processes these requests and sends back a response with the operation status result and with the requested data, in the case of subscribe/reply operations.

*Agents* keep track of the *Clients* by means of a dedicated `ProxyClient` entity that acts on behalf of the latter.
This is made possible by the creation of *DDS Entities* on the *Agent* as a result of *Clients*' operations, such as *Participants*, *Topics*, *Publishers*, and *Subscribers*, which can interact with the DDS global dataspace.

The communication between a *Micro XRCE-DDS Client* and a *Micro XRCE-DDS Agent* is achieved by means of several kinds of built-in transports: **UDPv4**, **UDPv6**, **TCPv4**, **TCPv6** and **Serial** communication. In addition, there is the possibility for the user to generate its own **Custom** transport.

<p align="center"> <img src="docs/General.png" alt="Image" width="70%"/> </p>

This repository contains the totality of the *eProsima Micro XRCE-DDS* products:

- [*Micro XRCE-DDS Client*](https://github.com/eProsima/Micro-XRCE-DDS-Client)
- [*Micro XRCE-DDS Agent*](https://github.com/eProsima/Micro-XRCE-DDS-Agent)
- [*Micro XRCE-DDS Gen*](https://github.com/eProsima/Micro-XRCE-DDS-Gen)

## Documentation

You can access Micro XRCE-DDS documentation online, which is hosted on Read the Docs.
You can access the *eProsima Micro XRCE-DDS* user documentation online, which is hosted on Read the Docs.

* [Start Page](http://micro-xrce-dds.readthedocs.io)
* [Installation manual](http://micro-xrce-dds.readthedocs.io/en/latest/installation.html)
Expand Down
8 changes: 4 additions & 4 deletions ci/linux/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ include(ExternalProject)
include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)

set(_c_flags "-fwrapv -fprofile-arcs -ftest-coverage")
set(_cxx_flags "-fwrapv -fprofile-arcs -ftest-coverage")
set(_exe_linker_flags "-fprofile-arcs -ftest-coverage")
set(_shared_linker_flags "-fprofile-arcs -ftest-coverage")
set(_c_flags "-fwrapv -fprofile-arcs -ftest-coverage --coverage -fno-inline -fno-inline-small-functions -fno-default-inline")
set(_cxx_flags "-fwrapv -fprofile-arcs -ftest-coverage --coverage -fno-inline -fno-inline-small-functions -fno-default-inline")
set(_exe_linker_flags "-fprofile-arcs -ftest-coverage --coverage -fno-inline -fno-inline-small-functions -fno-default-inline")
set(_shared_linker_flags "-fprofile-arcs -ftest-coverage --coverage -fno-inline -fno-inline-small-functions -fno-default-inline")

check_cxx_compiler_flag("-fprofile-abs-path" _have_fprofile_abs_path)
if(_have_fprofile_abs_path)
Expand Down
Binary file added docs/Concept.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/General.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/general_architecture.png
Binary file not shown.
Binary file removed docs/xrcedds_architecture.png
Binary file not shown.
1 change: 1 addition & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,5 @@ add_subdirectory(test/interaction_client)
add_subdirectory(test/client_agent)
add_subdirectory(test/publisher_subscriber)
add_subdirectory(test/discovery)
add_subdirectory(test/custom_transports)
#add_subdirectory(test/shapes_demo) TODO (julibert): fix client and agent paths.
96 changes: 96 additions & 0 deletions test/profiling/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# Copyright 2017-present Proyectos y Sistemas de Mantenimiento SL (eProsima).
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

cmake_minimum_required(VERSION 3.5)

project(microxrcedds-profiling)

ExternalProject_Add(clientlib
GIT_REPOSITORY
https://github.com/eProsima/Micro-XRCE-DDS-Client.git
GIT_TAG
${_client_tag}
PREFIX
${PROJECT_BINARY_DIR}/client
INSTALL_DIR
${PROJECT_BINARY_DIR}/install
CMAKE_CACHE_ARGS
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
)

ExternalProject_Add(agentlib
GIT_REPOSITORY
https://github.com/eProsima/Micro-XRCE-DDS-Agent.git
GIT_TAG
${_agent_tag}
PREFIX
${PROJECT_BINARY_DIR}/agent
INSTALL_DIR
${PROJECT_BINARY_DIR}/install
CMAKE_CACHE_ARGS
-DBUILD_SHARED_LIBS:BOOL=FALSE
-DCMAKE_BUILD_TYPE:STRING=MinSizeRel
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
-DUAGENT_FAST_PROFILE:BOOL=FALSE
-DUAGENT_DISCOVERY_PROFILE:BOOL=FALSE
-DUAGENT_P2P_PROFILE:BOOL=FALSE
-DUAGENT_LOGGER_PROFILE:BOOL=FALSE
-DUAGENT_SERVER_BUFFER_SIZE:STRING=1024
)

ExternalProject_Add(publisher
SOURCE_DIR
${CMAKE_CURRENT_LIST_DIR}/publisher
PREFIX
${PROJECT_BINARY_DIR}/publisher
INSTALL_DIR
${PROJECT_BINARY_DIR}/install
CMAKE_CACHE_ARGS
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
-DCMAKE_PREFIX_PATH:PATH=${PROJECT_BINARY_DIR}/install
DEPENDS
clientlib
)

ExternalProject_Add(subscriber
SOURCE_DIR
${CMAKE_CURRENT_LIST_DIR}/subscriber
PREFIX
${PROJECT_BINARY_DIR}/subscriber
INSTALL_DIR
${PROJECT_BINARY_DIR}/install
CMAKE_CACHE_ARGS
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
-DCMAKE_PREFIX_PATH:PATH=${PROJECT_BINARY_DIR}/install
DEPENDS
clientlib
)

ExternalProject_Add(agent
SOURCE_DIR
${CMAKE_CURRENT_LIST_DIR}/agent
PREFIX
${PROJECT_BINARY_DIR}/agent
INSTALL_DIR
${PROJECT_BINARY_DIR}/install
CMAKE_CACHE_ARGS
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
-DCMAKE_PREFIX_PATH:PATH=<INSTALL_DIR>
DEPENDS
agentlib
)

file(COPY ${CMAKE_CURRENT_LIST_DIR}/agent-profiling.py DESTINATION ${PROJECT_BINARY_DIR})
file(COPY ${CMAKE_CURRENT_LIST_DIR}/publisher-profiling.py DESTINATION ${PROJECT_BINARY_DIR})
file(COPY ${CMAKE_CURRENT_LIST_DIR}/subscriber-profiling.py DESTINATION ${PROJECT_BINARY_DIR})
24 changes: 24 additions & 0 deletions test/profiling/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Profiling test

Profiling test is composed of three components:

* A minimal Agent with just `UAGENT_CED_PROFILE` enable.
* A publisher developed with the Client library.
* A subscriber developed with the Client library.

## Why?

There are some scenarios where the Agent must run over low resource devices, so it is needed to characterize the minimum requirements of the Agent in terms of memory footprint.
In that sense, the Agent profiling with the lowest memory footprint is the one that only use the `CedMiddleware` implementation without logger, cli, and p2p.
Such configuration could be address disabling all the Agent's profiles except the `UAGENT_CED_PROFILE`.

## How?

```bash
cmake .. -DUXRCE_ENABLE_CLIENT=OFF -DUXRCE_ENABLE_AGENT=OFF -DUXRCE_BUILD_PROFILING=ON
cmake --build .
cd build/test/profiling
python3 agent-profiling.py
python3 publisher-profiling.py
python3 subscriber-profiling.py
```
70 changes: 70 additions & 0 deletions test/profiling/agent-profiling.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import msparser
import os
import signal
import subprocess
import sys
import time
import matplotlib.pyplot as plt
from tabulate import tabulate

n_pubsub = [1, 1 << 1, 1 << 2, 1 << 3, 1 << 4, 1 << 5]
topic_size = [1 << 8, 1 << 3]
stack_usage = []
heap_usage = []
total_usage = []

for t in topic_size:
stack = [t]
heap = [t]
total = [t]
for n in n_pubsub:
agent_sp = subprocess.Popen(("valgrind --tool=massif --stacks=yes --detailed-freq=1 --max-snapshots=300 --threshold=0.0 --massif-out-file=./massif-agent.out ./install/bin/agent-profiling").split(), shell=False)
time.sleep(1)

client_key = 1
sub_sps = []
pub_sps = []
for i in range(n):
sub_sps.append(subprocess.Popen(["./install/bin/subscriber-profiling {} topic_name_{}".format(client_key, i)], shell=True))
client_key += 1
pub_sps.append(subprocess.Popen(["./install/bin/publisher-profiling {} topic_name_{} {}".format(client_key, i, t)], shell=True))
client_key += 1

time.sleep(5)

for i in range(n):
pub_sps[i].terminate()
sub_sps[i].terminate()

agent_sp.send_signal(signal.SIGINT)
time.sleep(1.0)

data = msparser.parse_file('massif-agent.out')
peak_index = data['peak_snapshot_index']
peak_snapshot = data['snapshots'][peak_index]
for c in peak_snapshot['heap_tree']['children']:
if c['details'] and c['details']['function'] == '???':
std_heap = c['nbytes']

stack.append(round((peak_snapshot['mem_stack'] / 1000), 2))
heap.append(round((peak_snapshot['mem_heap'] / 1000), 2))
total.append(round(((peak_snapshot['mem_stack'] + peak_snapshot['mem_heap'] + peak_snapshot['mem_heap_extra'] - std_heap) / 1000), 2))

stack_usage.append(stack)
heap_usage.append(heap)
total_usage.append(total)

fig, ax = plt.subplots()
for i in range(len(topic_size)):
ax.scatter(n_pubsub, total_usage[i][1:], label="topic size = {} B".format(topic_size[i]))
ax.set_ylim(bottom=1)
ax.set_xlabel("Number of topics")
ax.set_ylabel("Memory usage (KB)")
ax.legend()
plt.show()

table_header = ["topic size (B) / #topics"]
for n in n_pubsub:
table_header.append(n)

print(tabulate(total_usage, headers=table_header))
34 changes: 34 additions & 0 deletions test/profiling/agent/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

# Copyright 2017-present Proyectos y Sistemas de Mantenimiento SL (eProsima).
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

cmake_minimum_required(VERSION 3.5)

project(agent-profiling)

find_package(microxrcedds_agent)

add_executable(${PROJECT_NAME} main.cpp)

target_link_libraries(${PROJECT_NAME}
PRIVATE
microxrcedds_agent
)

install(
TARGETS
${PROJECT_NAME}
RUNTIME DESTINATION
bin
)
27 changes: 27 additions & 0 deletions test/profiling/agent/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright 2017-present Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include <uxr/agent/transport/udp/UDPv4AgentLinux.hpp>

int main()
{
eprosima::uxr::UDPv4Agent agent(2020, eprosima::uxr::Middleware::Kind::CED);
agent.start();

while (true) {
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}

return 0;
}
Loading

0 comments on commit 21a253d

Please sign in to comment.