diff --git a/rmw_iceoryx_cpp/CMakeLists.txt b/rmw_iceoryx_cpp/CMakeLists.txt index 86c0491..6968d78 100644 --- a/rmw_iceoryx_cpp/CMakeLists.txt +++ b/rmw_iceoryx_cpp/CMakeLists.txt @@ -114,6 +114,7 @@ add_library(rmw_iceoryx_cpp SHARED src/rmw_trigger_guard_condition.cpp src/rmw_wait.cpp src/rmw_wait_set.cpp + src/rmw_dynamic_type_support.cpp ) ament_target_dependencies(rmw_iceoryx_cpp "rcutils" diff --git a/rmw_iceoryx_cpp/src/iceoryx_generate_gid.hpp b/rmw_iceoryx_cpp/src/iceoryx_generate_gid.hpp index 6da6751..8e677c6 100644 --- a/rmw_iceoryx_cpp/src/iceoryx_generate_gid.hpp +++ b/rmw_iceoryx_cpp/src/iceoryx_generate_gid.hpp @@ -1,5 +1,5 @@ // Copyright (c) 2019 by Robert Bosch GmbH. All rights reserved. -// Copyright (c) 2022 by Apex.AI Inc. All rights reserved. +// Copyright (c) 2022 - 2023 by Apex.AI Inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -19,7 +19,9 @@ #include "rmw/types.h" #include "iceoryx_posh/popo/untyped_publisher.hpp" +#include "iceoryx_posh/popo/untyped_client.hpp" rmw_gid_t generate_publisher_gid(iox::popo::UntypedPublisher * const publisher); +rmw_gid_t generate_client_gid(iox::popo::UntypedClient * const client); #endif // ICEORYX_GENERATE_GID_HPP_ diff --git a/rmw_iceoryx_cpp/src/internal/iceoryx_generate_gid.cpp b/rmw_iceoryx_cpp/src/internal/iceoryx_generate_gid.cpp index 3648332..85acd5b 100644 --- a/rmw_iceoryx_cpp/src/internal/iceoryx_generate_gid.cpp +++ b/rmw_iceoryx_cpp/src/internal/iceoryx_generate_gid.cpp @@ -1,5 +1,5 @@ // Copyright (c) 2019 by Robert Bosch GmbH. All rights reserved. -// Copyright (c) 2022 by Apex.AI Inc. All rights reserved. +// Copyright (c) 2022 - 2023 by Apex.AI Inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ #include "rmw/impl/cpp/macros.hpp" #include "iceoryx_posh/popo/untyped_publisher.hpp" +#include "iceoryx_posh/popo/untyped_client.hpp" rmw_gid_t generate_publisher_gid(iox::popo::UntypedPublisher * const publisher) { @@ -31,7 +32,27 @@ rmw_gid_t generate_publisher_gid(iox::popo::UntypedPublisher * const publisher) size_t size = sizeof(uid); if (!typed_uid.isValid() || size > RMW_GID_STORAGE_SIZE) { - RMW_SET_ERROR_MSG("Could not generated gid"); + RMW_SET_ERROR_MSG("Could not generated client gid"); + return gid; + } + memcpy(gid.data, &uid, size); + + return gid; +} + +rmw_gid_t generate_client_gid(iox::popo::UntypedClient * const client) +{ + rmw_gid_t gid; + gid.implementation_identifier = rmw_get_implementation_identifier(); + memset(gid.data, 0, RMW_GID_STORAGE_SIZE); + + iox::popo::UniquePortId typed_uid = client->getUid(); + iox::popo::UniquePortId::value_type uid = + static_cast(typed_uid); + size_t size = sizeof(uid); + + if (!typed_uid.isValid() || size > RMW_GID_STORAGE_SIZE) { + RMW_SET_ERROR_MSG("Could not generated publisher gid"); return gid; } memcpy(gid.data, &uid, size); diff --git a/rmw_iceoryx_cpp/src/rmw_client.cpp b/rmw_iceoryx_cpp/src/rmw_client.cpp index 1e125b3..21c24e2 100644 --- a/rmw_iceoryx_cpp/src/rmw_client.cpp +++ b/rmw_iceoryx_cpp/src/rmw_client.cpp @@ -203,4 +203,26 @@ rmw_ret_t rmw_client_set_on_new_response_callback( return RMW_RET_UNSUPPORTED; } + +rmw_ret_t +rmw_get_gid_for_client(const rmw_client_t * client, rmw_gid_t * gid) +{ + RCUTILS_CHECK_ARGUMENT_FOR_NULL(client, RMW_RET_INVALID_ARGUMENT); + RCUTILS_CHECK_ARGUMENT_FOR_NULL(gid, RMW_RET_INVALID_ARGUMENT); + + RMW_CHECK_TYPE_IDENTIFIERS_MATCH( + rmw_get_gid_for_client + : client, client->implementation_identifier, + rmw_get_implementation_identifier(), + return RMW_RET_INCORRECT_RMW_IMPLEMENTATION); + + IceoryxClient * iceoryx_client_abstraction = static_cast(client->data); + + if (!iceoryx_client_abstraction) { + RMW_SET_ERROR_MSG("client info handle is null"); + return RMW_RET_INVALID_ARGUMENT; + } + *gid = iceoryx_client_abstraction->gid_; + return RMW_RET_OK; +} } // extern "C" diff --git a/rmw_iceoryx_cpp/src/rmw_dynamic_type_support.cpp b/rmw_iceoryx_cpp/src/rmw_dynamic_type_support.cpp new file mode 100644 index 0000000..4268bff --- /dev/null +++ b/rmw_iceoryx_cpp/src/rmw_dynamic_type_support.cpp @@ -0,0 +1,67 @@ +// Copyright (c) 2023 by Apex.AI Inc. All rights reserved. +// +// 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 "rmw/impl/cpp/macros.hpp" +#include "rmw/rmw.h" + +extern "C" +{ +rmw_ret_t +rmw_take_dynamic_message( + const rmw_subscription_t * subscription, + rosidl_dynamic_typesupport_dynamic_data_t * dynamic_message, + bool * taken, + rmw_subscription_allocation_t * allocation) +{ + RCUTILS_CHECK_ARGUMENT_FOR_NULL(subscription, RMW_RET_ERROR); + RCUTILS_CHECK_ARGUMENT_FOR_NULL(dynamic_message, RMW_RET_ERROR); + RCUTILS_CHECK_ARGUMENT_FOR_NULL(taken, RMW_RET_ERROR); + RCUTILS_CHECK_ARGUMENT_FOR_NULL(allocation, RMW_RET_ERROR); + + RMW_SET_ERROR_MSG("rmw_take_dynamic_message is not supported in iceoryx"); + return RMW_RET_UNSUPPORTED; +} + +rmw_ret_t +rmw_take_dynamic_message_with_info( + const rmw_subscription_t * subscription, + rosidl_dynamic_typesupport_dynamic_data_t * dynamic_message, + bool * taken, + rmw_message_info_t * message_info, + rmw_subscription_allocation_t * allocation) +{ + RCUTILS_CHECK_ARGUMENT_FOR_NULL(subscription, RMW_RET_ERROR); + RCUTILS_CHECK_ARGUMENT_FOR_NULL(dynamic_message, RMW_RET_ERROR); + RCUTILS_CHECK_ARGUMENT_FOR_NULL(taken, RMW_RET_ERROR); + RCUTILS_CHECK_ARGUMENT_FOR_NULL(message_info, RMW_RET_ERROR); + RCUTILS_CHECK_ARGUMENT_FOR_NULL(allocation, RMW_RET_ERROR); + + RMW_SET_ERROR_MSG("rmw_take_dynamic_message_with_info is not supported in iceoryx"); + return RMW_RET_UNSUPPORTED; +} + +rmw_ret_t +rmw_serialization_support_init( + const char * serialization_lib_name, + rcutils_allocator_t * allocator, + rosidl_dynamic_typesupport_serialization_support_t * serialization_support) +{ + RCUTILS_CHECK_ARGUMENT_FOR_NULL(serialization_lib_name, RMW_RET_ERROR); + RCUTILS_CHECK_ARGUMENT_FOR_NULL(allocator, RMW_RET_ERROR); + RCUTILS_CHECK_ARGUMENT_FOR_NULL(serialization_support, RMW_RET_ERROR); + + RMW_SET_ERROR_MSG("rmw_serialization_support_init is not supported in iceoryx"); + return RMW_RET_UNSUPPORTED; +} +} // extern "C" diff --git a/rmw_iceoryx_cpp/src/types/iceoryx_client.hpp b/rmw_iceoryx_cpp/src/types/iceoryx_client.hpp index e2f66a1..9a559c3 100644 --- a/rmw_iceoryx_cpp/src/types/iceoryx_client.hpp +++ b/rmw_iceoryx_cpp/src/types/iceoryx_client.hpp @@ -15,6 +15,8 @@ #ifndef TYPES__ICEORYX_CLIENT_HPP_ #define TYPES__ICEORYX_CLIENT_HPP_ +#include "../iceoryx_generate_gid.hpp" + #include "iceoryx_posh/popo/untyped_client.hpp" #include "rmw/rmw.h" @@ -30,7 +32,8 @@ struct IceoryxClient : type_supports_(*type_supports), iceoryx_client_(iceoryx_client), is_fixed_size_(rmw_iceoryx_cpp::iceoryx_is_fixed_size(type_supports)), - request_size_(rmw_iceoryx_cpp::iceoryx_get_request_size(type_supports)) + request_size_(rmw_iceoryx_cpp::iceoryx_get_request_size(type_supports)), + gid_(generate_client_gid(iceoryx_client_)) {} rosidl_service_type_support_t type_supports_; @@ -38,6 +41,7 @@ struct IceoryxClient bool is_fixed_size_{false}; size_t request_size_{0}; int64_t sequence_id_{0}; + rmw_gid_t gid_; }; #endif // TYPES__ICEORYX_CLIENT_HPP_