Skip to content

Commit

Permalink
Merge branch internal changes into external
Browse files Browse the repository at this point in the history
  • Loading branch information
brakmic-aleksandar-conti committed Oct 30, 2020
2 parents f2f2c49 + c7e57ca commit f1dd76e
Show file tree
Hide file tree
Showing 15 changed files with 405 additions and 135 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,4 @@ RMW can currently work with only one serialization method at the time.

* Dashing Diademata
* Eloquent Elusor
* Foxy Fitzroy
4 changes: 4 additions & 0 deletions rmw_ecal_dynamic_cpp/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
Changelog for package rmw_ecal_dynamic_cpp
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

0.5.0 (2020-10-19)
------------------
* Added support for Foxy Fitzroy

0.4.1 (2020-10-05)
------------------
* Performance improvements for messages containing primitive type arrays
Expand Down
10 changes: 8 additions & 2 deletions rmw_ecal_dynamic_cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,15 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
endif()

if(NOT $ENV{ROS_DISTRO} MATCHES "eloquent" AND NOT $ENV{ROS_DISTRO} MATCHES "dashing")
if(NOT $ENV{ROS_DISTRO} MATCHES "dashing" AND NOT $ENV{ROS_DISTRO} MATCHES "eloquent" AND NOT $ENV{ROS_DISTRO} MATCHES "foxy")
message(FATAL_ERROR "'$ENV{ROS_DISTRO}' is unsupported ros2 distro.")
endif()
add_compile_definitions($<UPPER_CASE:$ENV{ROS_DISTRO}>)

add_compile_definitions("DASHING=0")
add_compile_definitions("ELOQUENT=1")
add_compile_definitions("FOXY=2")

add_compile_definitions("ROS_DISTRO=$<UPPER_CASE:$ENV{ROS_DISTRO}>")

option(USE_PROTOBUF_SERIALIZATION "Use google protobuf as serialization format." OFF)
if(USE_PROTOBUF_SERIALIZATION)
Expand Down Expand Up @@ -69,6 +74,7 @@ add_library(${PROJECT_NAME} SHARED
src/get_node_info_and_types.cpp
src/get_service_names_and_types.cpp
src/get_topic_names_and_types.cpp
src/get_topic_endpoint_info.cpp
src/init_options.cpp
src/init.cpp
src/rmw.cpp
Expand Down
2 changes: 1 addition & 1 deletion rmw_ecal_dynamic_cpp/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>rmw_ecal_dynamic_cpp</name>
<version>0.4.1</version>
<version>0.5.0</version>
<description>RMW implementation based on eCAL.</description>
<maintainer email="aleksandar.brakmic@continental-corporation.com">Aleksandar Brakmić</maintainer>
<license>Apache License 2.0</license>
Expand Down
6 changes: 3 additions & 3 deletions rmw_ecal_dynamic_cpp/src/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ rmw_ret_t rmw_publisher_event_init(rmw_event_t *rmw_event,
RMW_CHECK_ARGUMENT_FOR_NULL(rmw_event, RMW_RET_INVALID_ARGUMENT);
RMW_CHECK_ARGUMENT_FOR_NULL(publisher, RMW_RET_INVALID_ARGUMENT);
CHECK_RMW_IMPLEMENTATION(publisher);

if (event_type != rmw_event_type_t::RMW_EVENT_OFFERED_DEADLINE_MISSED)
{
RMW_SET_ERROR_MSG("Unsupported publisher event type.");
return RMW_RET_INVALID_ARGUMENT;
return RMW_RET_UNSUPPORTED;
}

rmw_event->event_type = event_type;
Expand All @@ -62,7 +62,7 @@ rmw_ret_t rmw_subscription_event_init(rmw_event_t *rmw_event,
if (event_type != rmw_event_type_t::RMW_EVENT_REQUESTED_DEADLINE_MISSED)
{
RMW_SET_ERROR_MSG("Unsupported publisher event type.");
return RMW_RET_INVALID_ARGUMENT;
return RMW_RET_UNSUPPORTED;
}

rmw_event->event_type = event_type;
Expand Down
47 changes: 47 additions & 0 deletions rmw_ecal_dynamic_cpp/src/get_topic_endpoint_info.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/* ========================= RMW eCAL LICENSE =================================
*
* Copyright (C) 2019 - 2020 Continental Corporation
*
* 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.
*
* ========================= RMW eCAL LICENSE =================================
*/

#if ROS_DISTRO >= FOXY

#include <rmw/get_topic_endpoint_info.h>

#include <rmw/rmw.h>

#include "internal/graph.hpp"
#include "internal/common.hpp"

rmw_ret_t rmw_get_publishers_info_by_topic(const rmw_node_t * /* node */,
rcutils_allocator_t * /* allocator */,
const char * /* topic_name */,
bool /* no_mangle */,
rmw_topic_endpoint_info_array_t * /* publishers_info */)
{
UNSUPPORTED;
}

rmw_ret_t rmw_get_subscriptions_info_by_topic(const rmw_node_t * /* node */,
rcutils_allocator_t * /* allocator */,
const char * /* topic_name */,
bool /* no_mangle */,
rmw_topic_endpoint_info_array_t * /* subscriptions_info */)
{
UNSUPPORTED;
}

#endif
1 change: 1 addition & 0 deletions rmw_ecal_dynamic_cpp/src/internal/qos.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#pragma once

#include <limits>
#include <stdexcept>

#include <ecal/ecal.h>

Expand Down
129 changes: 129 additions & 0 deletions rmw_ecal_dynamic_cpp/src/internal/rosidl_generator_c_pkg_adapter.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
/* ========================= RMW eCAL LICENSE =================================
*
* Copyright (C) 2019 - 2020 Continental Corporation
*
* 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.
*
* ========================= RMW eCAL LICENSE =================================
*/

//From Foxy distro rosidl_generator_c has been renamed to rosidl_generator_c,
//purpose of this header file is to alias old C type names to new ones, that way the
//rest of the code doesn't have to care about old package name regardless of distro.
//any rosidl_generator_c to rosidl_runtime_c adaptions should be added here

#if ROS_DISTRO >= FOXY

#include <rosidl_runtime_c/primitives_sequence.h>
#include <rosidl_runtime_c/primitives_sequence_functions.h>
#include <rosidl_runtime_c/string.h>
#include <rosidl_runtime_c/string_functions.h>

#else

#include <rosidl_generator_c/primitives_sequence.h>
#include <rosidl_generator_c/primitives_sequence_functions.h>
#include <rosidl_generator_c/string.h>
#include <rosidl_generator_c/string_functions.h>

#define ADAPT_PRIMITIVE_SEQUENCE_NAMESPACE(STRUCT_NAME) \
using rosidl_runtime_c__##STRUCT_NAME##__Sequence = rosidl_generator_c__##STRUCT_NAME##__Sequence;

ADAPT_PRIMITIVE_SEQUENCE_NAMESPACE(float)
ADAPT_PRIMITIVE_SEQUENCE_NAMESPACE(double)
ADAPT_PRIMITIVE_SEQUENCE_NAMESPACE(long_double)
ADAPT_PRIMITIVE_SEQUENCE_NAMESPACE(char)
ADAPT_PRIMITIVE_SEQUENCE_NAMESPACE(wchar)
ADAPT_PRIMITIVE_SEQUENCE_NAMESPACE(boolean)
ADAPT_PRIMITIVE_SEQUENCE_NAMESPACE(octet)
ADAPT_PRIMITIVE_SEQUENCE_NAMESPACE(uint8)
ADAPT_PRIMITIVE_SEQUENCE_NAMESPACE(int8)
ADAPT_PRIMITIVE_SEQUENCE_NAMESPACE(uint16)
ADAPT_PRIMITIVE_SEQUENCE_NAMESPACE(int16)
ADAPT_PRIMITIVE_SEQUENCE_NAMESPACE(uint32)
ADAPT_PRIMITIVE_SEQUENCE_NAMESPACE(int32)
ADAPT_PRIMITIVE_SEQUENCE_NAMESPACE(uint64)
ADAPT_PRIMITIVE_SEQUENCE_NAMESPACE(int64)
ADAPT_PRIMITIVE_SEQUENCE_NAMESPACE(String)

#undef ADAPT_PRIMITIVE_SEQUENCE_NAMESPACE

using rosidl_runtime_c__String = rosidl_generator_c__String;

#define rosidl_runtime_c__float__Sequence__fini(sequence) rosidl_generator_c__float__Sequence__fini(sequence)
#define rosidl_runtime_c__float__Sequence__init(sequence, size) rosidl_generator_c__float__Sequence__init(sequence, size)

#define rosidl_runtime_c__double__Sequence__fini(sequence) rosidl_generator_c__double__Sequence__fini(sequence)
#define rosidl_runtime_c__double__Sequence__init(sequence, size) rosidl_generator_c__double__Sequence__init(sequence, size)

#define rosidl_runtime_c__long_double__Sequence__fini(sequence) rosidl_generator_c__long_double__Sequence__fini(sequence)
#define rosidl_runtime_c__long_double__Sequence__init(sequence, size) rosidl_generator_c__long_double__Sequence__init(sequence, size)

#define rosidl_runtime_c__char__Sequence__fini(sequence) rosidl_generator_c__char__Sequence__fini(sequence)
#define rosidl_runtime_c__char__Sequence__init(sequence, size) rosidl_generator_c__char__Sequence__init(sequence, size)

#define rosidl_runtime_c__wchar__Sequence__fini(sequence) rosidl_generator_c__wchar__Sequence__fini(sequence)
#define rosidl_runtime_c__wchar__Sequence__init(sequence, size) rosidl_generator_c__wchar__Sequence__init(sequence, size)

#define rosidl_runtime_c__boolean__Sequence__fini(sequence) rosidl_generator_c__boolean__Sequence__fini(sequence)
#define rosidl_runtime_c__boolean__Sequence__init(sequence, size) rosidl_generator_c__boolean__Sequence__init(sequence, size)

#define rosidl_runtime_c__octet__Sequence__fini(sequence) rosidl_generator_c__octet__Sequence__fini(sequence)
#define rosidl_runtime_c__octet__Sequence__init(sequence, size) rosidl_generator_c__octet__Sequence__init(sequence, size)

#define rosidl_runtime_c__uint8__Sequence__fini(sequence) rosidl_generator_c__uint8__Sequence__fini(sequence)
#define rosidl_runtime_c__uint8__Sequence__init(sequence, size) rosidl_generator_c__uint8__Sequence__init(sequence, size)

#define rosidl_runtime_c__int8__Sequence__fini(sequence) rosidl_generator_c__int8__Sequence__fini(sequence)
#define rosidl_runtime_c__int8__Sequence__init(sequence, size) rosidl_generator_c__int8__Sequence__init(sequence, size)

#define rosidl_runtime_c__uint16__Sequence__fini(sequence) rosidl_generator_c__uint16__Sequence__fini(sequence)
#define rosidl_runtime_c__uint16__Sequence__init(sequence, size) rosidl_generator_c__uint16__Sequence__init(sequence, size)

#define rosidl_runtime_c__int16__Sequence__fini(sequence) rosidl_generator_c__int16__Sequence__fini(sequence)
#define rosidl_runtime_c__int16__Sequence__init(sequence, size) rosidl_generator_c__int16__Sequence__init(sequence, size)

#define rosidl_runtime_c__uint32__Sequence__fini(sequence) rosidl_generator_c__uint32__Sequence__fini(sequence)
#define rosidl_runtime_c__uint32__Sequence__init(sequence, size) rosidl_generator_c__uint32__Sequence__init(sequence, size)

#define rosidl_runtime_c__int32__Sequence__fini(sequence) rosidl_generator_c__int32__Sequence__fini(sequence)
#define rosidl_runtime_c__int32__Sequence__init(sequence, size) rosidl_generator_c__int32__Sequence__init(sequence, size)

#define rosidl_runtime_c__uint64__Sequence__fini(sequence) rosidl_generator_c__uint64__Sequence__fini(sequence)
#define rosidl_runtime_c__uint64__Sequence__init(sequence, size) rosidl_generator_c__uint64__Sequence__init(sequence, size)

#define rosidl_runtime_c__int64__Sequence__fini(sequence) rosidl_generator_c__int64__Sequence__fini(sequence)
#define rosidl_runtime_c__int64__Sequence__init(sequence, size) rosidl_generator_c__int64__Sequence__init(sequence, size)

#define rosidl_runtime_c__bool__Sequence__init(sequence, size) rosidl_generator_c__bool__Sequence__init(sequence, size)
#define rosidl_runtime_c__bool__Sequence__fini(sequence) rosidl_generator_c__bool__Sequence__init(sequence)

#define rosidl_runtime_c__byte__Sequence__init(sequence, size) rosidl_generator_c__byte__Sequence__init(sequence, size)
#define rosidl_runtime_c__byte__Sequence__fini(sequence) rosidl_generator_c__byte__Sequence__fini(sequence)

#define rosidl_runtime_c__float32__Sequence__init(sequence, size) rosidl_generator_c__float32__Sequence__init(sequence, size)
#define rosidl_runtime_c__float32__Sequence__fini(sequence) rosidl_generator_c__float32__Sequence__fini(sequence)

#define rosidl_runtime_c__float64__Sequence__init(sequence, size) rosidl_generator_c__float64__Sequence__init(sequence, size)
#define rosidl_runtime_c__float64__Sequence__fini(sequence) rosidl_generator_c__float64__Sequence__fini(sequence)

#define rosidl_runtime_c__String__init(str) rosidl_generator_c__String__init(str)
#define rosidl_runtime_c__String__fini(str) rosidl_generator_c__String__fini(str)
#define rosidl_runtime_c__String__assignn(str, value, n) rosidl_generator_c__String__assignn(str, value, n)
#define rosidl_runtime_c__String__assign(str, value) rosidl_generator_c__String__assign(str, value)
#define rosidl_runtime_c__String__Sequence__init(sequence, size) rosidl_generator_c__String__Sequence__init(sequence, size)
#define rosidl_runtime_c__String__Sequence__fini(sequence) rosidl_generator_c__String__Sequence__fini(sequence)
#define rosidl_runtime_c__String__Sequence__create(size) rosidl_generator_c__String__Sequence__create(size)
#define rosidl_runtime_c__String__Sequence__destroy(sequence) rosidl_generator_c__String__Sequence__destroy(sequence)

#endif
1 change: 0 additions & 1 deletion rmw_ecal_dynamic_cpp/src/internal/serialization.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

#pragma once

#include <rosidl_generator_c/message_type_support_struct.h>
#include <rosidl_typesupport_introspection_cpp/message_introspection.hpp>
#include <rosidl_typesupport_introspection_c/message_introspection.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,10 @@
#include <algorithm>
#include <stdexcept>

#include <rosidl_generator_c/primitives_sequence.h>
#include <rosidl_generator_c/primitives_sequence_functions.h>
#include <rosidl_generator_c/string.h>
#include <rosidl_generator_c/string_functions.h>
#include <rosidl_typesupport_introspection_c/field_types.h>

#include "internal/common.hpp"
#include "internal/rosidl_generator_c_pkg_adapter.hpp"

namespace eCAL
{
Expand All @@ -49,9 +46,9 @@ void CDeserializer::DeserializeSingle<std::string>(char *member, const char **se
auto size = *reinterpret_cast<const array_size_t *>(*serialized_data);
*serialized_data += sizeof(array_size_t);

auto sequence = reinterpret_cast<rosidl_generator_c__String *>(member);
rosidl_generator_c__String__init(sequence);
rosidl_generator_c__String__assignn(sequence, *serialized_data, size);
auto sequence = reinterpret_cast<rosidl_runtime_c__String *>(member);
rosidl_runtime_c__String__init(sequence);
rosidl_runtime_c__String__assignn(sequence, *serialized_data, size);

*serialized_data += size;
}
Expand All @@ -69,7 +66,7 @@ void CDeserializer::DeserializeArray<std::string>(char *member, size_t size, con
for (size_t i = 0; i < size; i++)
{
DeserializeSingle<std::string>(member, serialized_data);
member += sizeof(rosidl_generator_c__String__Sequence);
member += sizeof(rosidl_runtime_c__String__Sequence);
}
}

Expand All @@ -92,11 +89,10 @@ void CDeserializer::DeserializeDynamicArray(char *member, const char **serialize
auto arr_size = *reinterpret_cast<const array_size_t *>(*serialized_data);
*serialized_data += sizeof(array_size_t);

auto sequence = reinterpret_cast<rosidl_generator_c__char__Sequence *>(member);
sequence->data = nullptr;
auto sequence = reinterpret_cast<rosidl_runtime_c__char__Sequence *>(member);
sequence->size = arr_size;
sequence->capacity = arr_size;
if(arr_size > 0)
if (arr_size > 0)
{
sequence->data = new signed char[arr_size * sizeof(T)];
DeserializeArray<T>(reinterpret_cast<char *>(sequence->data), sequence->size, serialized_data);
Expand All @@ -109,10 +105,10 @@ void CDeserializer::DeserializeDynamicArray<std::string>(char *member, const cha
auto arr_size = *reinterpret_cast<const array_size_t *>(*serialized_data);
*serialized_data += sizeof(array_size_t);

auto sequence = reinterpret_cast<rosidl_generator_c__String__Sequence *>(member);
rosidl_generator_c__String__Sequence__init(sequence, arr_size);
if(arr_size > 0)
auto sequence = reinterpret_cast<rosidl_runtime_c__String__Sequence *>(member);
rosidl_runtime_c__String__Sequence__init(sequence, arr_size);

if (arr_size > 0)
{
DeserializeArray<std::string>(reinterpret_cast<char *>(sequence->data), sequence->size, serialized_data);
}
Expand All @@ -126,15 +122,14 @@ void CDeserializer::DeserializeDynamicArray<ros_message_t>(char *message,
auto arr_size = *reinterpret_cast<const array_size_t *>(*serialized_data);
*serialized_data += sizeof(array_size_t);

auto sequence = reinterpret_cast<rosidl_generator_c__char__Sequence *>(message);
sequence->data = nullptr;
auto sequence = reinterpret_cast<rosidl_runtime_c__char__Sequence *>(message);
sequence->size = arr_size;
sequence->capacity = arr_size;

if(arr_size > 0)
if (arr_size > 0)
{
auto sub_members = GetMembers(member);

sequence->data = new signed char[arr_size * sub_members->size_of_];
auto data = sequence->data;

Expand Down
Loading

0 comments on commit f1dd76e

Please sign in to comment.