Skip to content
Open
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
3 changes: 3 additions & 0 deletions system/xrcedds/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/xrcedds-client/
/microcdr/
/*.tar.gz
101 changes: 101 additions & 0 deletions system/xrcedds/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# ##############################################################################
# apps/system/xrcedds/CMakeLists.txt
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you 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.
#
# ##############################################################################

if(CONFIG_SYSTEM_XRCEDDS)
set(XRCEDDS_VERSION 3.0.1)
set(MICROCDR_VERSION 2.0.2)
set(XRCEDDS_DIR ${CMAKE_CURRENT_LIST_DIR}/xrcedds-client)
set(MICROCDR_DIR ${CMAKE_CURRENT_LIST_DIR}/microcdr)
set(XRCEDDS_URL https://github.com/eProsima/Micro-XRCE-DDS-Client/archive)
set(MICROCDR_URL https://github.com/eProsima/Micro-CDR/archive)

if(NOT EXISTS ${XRCEDDS_DIR})
FetchContent_Declare(
xrcedds_fetch
URL ${XRCEDDS_URL}/refs/tags/v${XRCEDDS_VERSION}.tar.gz
SOURCE_DIR ${XRCEDDS_DIR}
BINARY_DIR ${NUTTX_APPS_BINDIR}/system/xrcedds/xrcedds-client
DOWNLOAD_NO_PROGRESS true
TIMEOUT 30)
FetchContent_GetProperties(xrcedds_fetch)
if(NOT xrcedds_fetch_POPULATED)
FetchContent_Populate(xrcedds_fetch)
endif()
endif()

if(NOT EXISTS ${MICROCDR_DIR})
FetchContent_Declare(
microcdr_fetch
URL ${MICROCDR_URL}/refs/tags/v${MICROCDR_VERSION}.tar.gz
SOURCE_DIR ${MICROCDR_DIR}
BINARY_DIR ${NUTTX_APPS_BINDIR}/system/xrcedds/microcdr
DOWNLOAD_NO_PROGRESS true
TIMEOUT 30)
FetchContent_GetProperties(microcdr_fetch)
if(NOT microcdr_fetch_POPULATED)
FetchContent_Populate(microcdr_fetch)
endif()
endif()

file(GLOB XRCEDDS_SRCS
${XRCEDDS_DIR}/src/c/core/serialization/*.c
${XRCEDDS_DIR}/src/c/core/session/*.c
${XRCEDDS_DIR}/src/c/core/session/stream/*.c
${XRCEDDS_DIR}/src/c/util/*.c
${XRCEDDS_DIR}/src/c/profile/transport/custom/*.c)

if(CONFIG_SYSTEM_XRCEDDS_STREAM_FRAMING)
file(GLOB XRCEDDS_FRAMING_SRCS
${XRCEDDS_DIR}/src/c/profile/transport/stream_framing/*.c)
list(APPEND XRCEDDS_SRCS ${XRCEDDS_FRAMING_SRCS})
endif()

file(GLOB MICROCDR_SRCS ${MICROCDR_DIR}/src/c/*.c
${MICROCDR_DIR}/src/c/types/*.c)

nuttx_add_library(xrcedds STATIC)
target_sources(xrcedds PRIVATE ${XRCEDDS_SRCS} ${MICROCDR_SRCS})
target_include_directories(
xrcedds PRIVATE ${CMAKE_CURRENT_LIST_DIR}/include ${XRCEDDS_DIR}/include
${XRCEDDS_DIR}/src/c ${MICROCDR_DIR}/include)

set_property(
TARGET nuttx
APPEND
PROPERTY NUTTX_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_LIST_DIR}/include
${XRCEDDS_DIR}/include ${MICROCDR_DIR}/include)

if(CONFIG_SYSTEM_XRCEDDS_PUBLISH_DEMO)
nuttx_add_application(
NAME
${CONFIG_SYSTEM_XRCEDDS_PUBLISH_DEMO_PROGNAME}
SRCS
main.c
HelloWorld.c
STACKSIZE
${CONFIG_SYSTEM_XRCEDDS_PUBLISH_DEMO_STACKSIZE}
PRIORITY
${CONFIG_SYSTEM_XRCEDDS_PUBLISH_DEMO_PRIORITY}
DEPENDS
xrcedds)
endif()
endif()
70 changes: 70 additions & 0 deletions system/xrcedds/HelloWorld.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/****************************************************************************
* apps/system/xrcedds/HelloWorld.c
*
* This source file contains the definition of the HelloWorld type described
* in the IDL file. It was generated from HelloWorld.idl by the Micro
* XRCE-DDS Gen tool (microxrceddsgen) and is committed to the tree so that
* it does not need to be regenerated at build time. DO NOT EDIT: to change
* the type, edit HelloWorld.idl and regenerate with microxrceddsgen.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you 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.
*
****************************************************************************/

/****************************************************************************
* Included Files
****************************************************************************/

#include <string.h>

#include <ucdr/microcdr.h>

#include "HelloWorld.h"

/****************************************************************************
* Public Functions
****************************************************************************/

bool HelloWorld_serialize_topic(struct ucdrBuffer *writer,
const HelloWorld *topic)
{
(void)ucdr_serialize_uint32_t(writer, topic->index);
(void)ucdr_serialize_string(writer, topic->message);

return !writer->error;
}

bool HelloWorld_deserialize_topic(struct ucdrBuffer *reader,
HelloWorld *topic)
{
(void)ucdr_deserialize_uint32_t(reader, &topic->index);
(void)ucdr_deserialize_string(reader, topic->message, 255);

return !reader->error;
}

uint32_t HelloWorld_size_of_topic(const HelloWorld *topic, uint32_t size)
{
uint32_t previous_size = size;

size += (uint32_t)(ucdr_alignment(size, 4) + 4);
size += (uint32_t)(ucdr_alignment(size, 4) + 4 + strlen(topic->message) +
1);

return size - previous_size;
}
63 changes: 63 additions & 0 deletions system/xrcedds/HelloWorld.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/****************************************************************************
* apps/system/xrcedds/HelloWorld.h
*
* This header declares the HelloWorld type. It was generated from
* HelloWorld.idl by the Micro XRCE-DDS Gen tool (microxrceddsgen) and is
* committed to the tree so that it does not need to be regenerated at build
* time. DO NOT EDIT: to change the type, edit HelloWorld.idl and regenerate
* with microxrceddsgen.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you 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.
*
****************************************************************************/

#ifndef __APPS_SYSTEM_XRCEDDS_HELLOWORLD_H
#define __APPS_SYSTEM_XRCEDDS_HELLOWORLD_H

/****************************************************************************
* Included Files
****************************************************************************/

#include <stdbool.h>
#include <stdint.h>

/****************************************************************************
* Public Types
****************************************************************************/

/* This struct represents the HelloWorld structure defined in the IDL file. */

typedef struct HelloWorld
{
uint32_t index;
char message[255];
} HelloWorld;

struct ucdrBuffer;

/****************************************************************************
* Public Function Prototypes
****************************************************************************/

bool HelloWorld_serialize_topic(struct ucdrBuffer *writer,
const HelloWorld *topic);
bool HelloWorld_deserialize_topic(struct ucdrBuffer *reader,
HelloWorld *topic);
uint32_t HelloWorld_size_of_topic(const HelloWorld *topic, uint32_t size);

#endif /* __APPS_SYSTEM_XRCEDDS_HELLOWORLD_H */
5 changes: 5 additions & 0 deletions system/xrcedds/HelloWorld.idl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
struct HelloWorld
{
unsigned long index;
string message;
};
84 changes: 84 additions & 0 deletions system/xrcedds/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#

menuconfig SYSTEM_XRCEDDS
bool "eProsima Micro XRCE-DDS"
default n
---help---
Enable a lightweight build of Micro XRCE-DDS Client 3.0.1 and
Micro-CDR 2.0.2. Only the core client and the built-in UDP
transport are built; ROS 2, micro-ROS, discovery, and other
transports are not included.

if SYSTEM_XRCEDDS

config SYSTEM_XRCEDDS_STREAM_FRAMING
bool "Byte-stream transport framing"
default n
---help---
Enable HDLC framing for byte-stream transports such as UART.
The built-in UDP transport preserves packet boundaries, so this
is not needed for the UDP publisher demo.

config SYSTEM_XRCEDDS_MTU
int "UDP transport MTU"
range 64 65535
default 512

config SYSTEM_XRCEDDS_MAX_OUTPUT_BEST_EFFORT_STREAMS
int "Maximum output best-effort streams"
range 1 127
default 1

config SYSTEM_XRCEDDS_MAX_OUTPUT_RELIABLE_STREAMS
int "Maximum output reliable streams"
range 1 127
default 1

config SYSTEM_XRCEDDS_MAX_INPUT_BEST_EFFORT_STREAMS
int "Maximum input best-effort streams"
range 1 127
default 1

config SYSTEM_XRCEDDS_MAX_INPUT_RELIABLE_STREAMS
int "Maximum input reliable streams"
range 1 127
default 1

config SYSTEM_XRCEDDS_PUBLISH_DEMO
tristate "Micro XRCE-DDS UDP publisher demo"
default n
depends on NET_UDP && NET_IPv4
---help---
Build the PublishHelloWorldClient command. It connects to a
Micro XRCE-DDS Agent through the built-in UDP transport and
publishes HelloWorld samples.

if SYSTEM_XRCEDDS_PUBLISH_DEMO

config SYSTEM_XRCEDDS_PUBLISH_DEMO_PROGNAME
string "Publisher command name"
default "PublishHelloWorldClient"

config SYSTEM_XRCEDDS_PUBLISH_DEMO_PRIORITY
int "Publisher task priority"
default 100

config SYSTEM_XRCEDDS_PUBLISH_DEMO_STACKSIZE
int "Publisher task stack size"
default 4096

config SYSTEM_XRCEDDS_PUBLISH_DEMO_AGENT_IP
string "Agent IPv4 address"
default "127.0.0.1"

config SYSTEM_XRCEDDS_PUBLISH_DEMO_AGENT_PORT
int "Agent UDP port"
range 1 65535
default 8888

endif

endif
35 changes: 35 additions & 0 deletions system/xrcedds/Make.defs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
############################################################################
# apps/system/xrcedds/Make.defs
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you 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.
#
############################################################################

ifneq ($(CONFIG_SYSTEM_XRCEDDS),)
CONFIGURED_APPS += $(APPDIR)/system/xrcedds

XRCEDDS_DIR := $(APPDIR)/system/xrcedds

CFLAGS += ${INCDIR_PREFIX}"$(XRCEDDS_DIR)/include"
CFLAGS += ${INCDIR_PREFIX}"$(XRCEDDS_DIR)/xrcedds-client/include"
CFLAGS += ${INCDIR_PREFIX}"$(XRCEDDS_DIR)/microcdr/include"

CXXFLAGS += ${INCDIR_PREFIX}"$(XRCEDDS_DIR)/include"
CXXFLAGS += ${INCDIR_PREFIX}"$(XRCEDDS_DIR)/xrcedds-client/include"
CXXFLAGS += ${INCDIR_PREFIX}"$(XRCEDDS_DIR)/microcdr/include"
endif
Loading