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

Forward port changes from iron to master branch + Add new rmw_count_* functions #102

Merged
Merged
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
1 change: 1 addition & 0 deletions rmw_iceoryx_cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 3 additions & 1 deletion rmw_iceoryx_cpp/src/iceoryx_generate_gid.hpp
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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_
25 changes: 23 additions & 2 deletions rmw_iceoryx_cpp/src/internal/iceoryx_generate_gid.cpp
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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)
{
Expand All @@ -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<iox::popo::UniquePortId::value_type>(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);
Expand Down
22 changes: 22 additions & 0 deletions rmw_iceoryx_cpp/src/rmw_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<IceoryxClient *>(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"
40 changes: 40 additions & 0 deletions rmw_iceoryx_cpp/src/rmw_count.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,46 @@ rmw_count_subscribers(
return RMW_RET_OK;
}

rmw_ret_t
rmw_count_services(
const rmw_node_t * node,
const char * service_name,
size_t * count)
{
RCUTILS_CHECK_ARGUMENT_FOR_NULL(node, RMW_RET_ERROR);
RCUTILS_CHECK_ARGUMENT_FOR_NULL(service_name, RMW_RET_ERROR);
RCUTILS_CHECK_ARGUMENT_FOR_NULL(count, RMW_RET_ERROR);

RMW_CHECK_TYPE_IDENTIFIERS_MATCH(
rmw_count_services
: node, node->implementation_identifier,
rmw_get_implementation_identifier(), return RMW_RET_ERROR);

/// @todo There is no API to find out which 'ServiceDescription' is offered by which node
RMW_SET_ERROR_MSG("rmw_count_services is not supported in iceoryx");
mossmaurice marked this conversation as resolved.
Show resolved Hide resolved
return RMW_RET_UNSUPPORTED;
}

rmw_ret_t
rmw_count_clients(
const rmw_node_t * node,
const char * service_name,
size_t * count)
{
RCUTILS_CHECK_ARGUMENT_FOR_NULL(node, RMW_RET_ERROR);
RCUTILS_CHECK_ARGUMENT_FOR_NULL(service_name, RMW_RET_ERROR);
RCUTILS_CHECK_ARGUMENT_FOR_NULL(count, RMW_RET_ERROR);

RMW_CHECK_TYPE_IDENTIFIERS_MATCH(
rmw_count_clients
: node, node->implementation_identifier,
rmw_get_implementation_identifier(), return RMW_RET_ERROR);

/// @todo There is no API to find out which 'ServiceDescription' is offered by which node
RMW_SET_ERROR_MSG("rmw_count_clients is not supported in iceoryx");
return RMW_RET_UNSUPPORTED;
}

rmw_ret_t
rmw_subscription_count_matched_publishers(
const rmw_subscription_t * subscription,
Expand Down
67 changes: 67 additions & 0 deletions rmw_iceoryx_cpp/src/rmw_dynamic_type_support.cpp
Original file line number Diff line number Diff line change
@@ -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"
6 changes: 5 additions & 1 deletion rmw_iceoryx_cpp/src/types/iceoryx_client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -30,14 +32,16 @@ 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_;
iox::popo::UntypedClient * const iceoryx_client_;
bool is_fixed_size_{false};
size_t request_size_{0};
int64_t sequence_id_{0};
rmw_gid_t gid_;
};

#endif // TYPES__ICEORYX_CLIENT_HPP_
Loading