Skip to content

Commit beef9db

Browse files
Add new methods and minor changes for ROS 2 Iron Irwini (#101)
* Address review findings (#84) Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai> * Implement new rmw functions needed for iron (#99) Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai> * Change CI to iron (#99) Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai> --------- Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai>
1 parent 4936431 commit beef9db

13 files changed

+141
-27
lines changed

.github/workflows/main.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Integration build rmw_iceoryx
33
on:
44
push:
55
branches:
6-
- humble
6+
- iron
77
pull_request:
88

99
jobs:
@@ -18,11 +18,11 @@ jobs:
1818
- name: Setup ROS
1919
uses: ros-tooling/setup-ros@master
2020
with:
21-
required-ros-distributions: humble
21+
required-ros-distributions: iron
2222
- name: Install Iceoryx Dependencies
2323
run: sudo apt-get update && sudo apt-get install -y cmake libacl1-dev libncurses5-dev pkg-config
2424
- name: Build & Test
2525
uses: ros-tooling/action-ros-ci@master
2626
with:
2727
package-name: rmw_iceoryx_cpp
28-
target-ros2-distro: humble
28+
target-ros2-distro: iron

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ To install rmw_iceoryx in a ROS 2 workspace with the latest ROS version, just ex
1515
```bash
1616
mkdir -p ~/iceoryx_ws/src
1717
cd $_
18-
# LATEST_ROS_VERSION could be e.g. humble
18+
# LATEST_ROS_VERSION could be e.g. iron
1919
git clone --branch LATEST_ROS_VERSION https://github.com/ros2/rmw_iceoryx.git
2020
```
2121

rmw_iceoryx_cpp/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ add_library(rmw_iceoryx_cpp SHARED
114114
src/rmw_trigger_guard_condition.cpp
115115
src/rmw_wait.cpp
116116
src/rmw_wait_set.cpp
117+
src/rmw_dynamic_type_support.cpp
117118
)
118119
ament_target_dependencies(rmw_iceoryx_cpp
119120
"rcutils"

rmw_iceoryx_cpp/src/iceoryx_generate_gid.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Copyright (c) 2019 by Robert Bosch GmbH. All rights reserved.
2-
// Copyright (c) 2022 by Apex.AI Inc. All rights reserved.
2+
// Copyright (c) 2022 - 2023 by Apex.AI Inc. All rights reserved.
33
//
44
// Licensed under the Apache License, Version 2.0 (the "License");
55
// you may not use this file except in compliance with the License.
@@ -19,7 +19,9 @@
1919
#include "rmw/types.h"
2020

2121
#include "iceoryx_posh/popo/untyped_publisher.hpp"
22+
#include "iceoryx_posh/popo/untyped_client.hpp"
2223

2324
rmw_gid_t generate_publisher_gid(iox::popo::UntypedPublisher * const publisher);
25+
rmw_gid_t generate_client_gid(iox::popo::UntypedClient * const client);
2426

2527
#endif // ICEORYX_GENERATE_GID_HPP_

rmw_iceoryx_cpp/src/internal/iceoryx_generate_gid.cpp

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Copyright (c) 2019 by Robert Bosch GmbH. All rights reserved.
2-
// Copyright (c) 2022 by Apex.AI Inc. All rights reserved.
2+
// Copyright (c) 2022 - 2023 by Apex.AI Inc. All rights reserved.
33
//
44
// Licensed under the Apache License, Version 2.0 (the "License");
55
// you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@
1818
#include "rmw/impl/cpp/macros.hpp"
1919

2020
#include "iceoryx_posh/popo/untyped_publisher.hpp"
21+
#include "iceoryx_posh/popo/untyped_client.hpp"
2122

2223
rmw_gid_t generate_publisher_gid(iox::popo::UntypedPublisher * const publisher)
2324
{
@@ -31,7 +32,27 @@ rmw_gid_t generate_publisher_gid(iox::popo::UntypedPublisher * const publisher)
3132
size_t size = sizeof(uid);
3233

3334
if (!typed_uid.isValid() || size > RMW_GID_STORAGE_SIZE) {
34-
RMW_SET_ERROR_MSG("Could not generated gid");
35+
RMW_SET_ERROR_MSG("Could not generated client gid");
36+
return gid;
37+
}
38+
memcpy(gid.data, &uid, size);
39+
40+
return gid;
41+
}
42+
43+
rmw_gid_t generate_client_gid(iox::popo::UntypedClient * const client)
44+
{
45+
rmw_gid_t gid;
46+
gid.implementation_identifier = rmw_get_implementation_identifier();
47+
memset(gid.data, 0, RMW_GID_STORAGE_SIZE);
48+
49+
iox::popo::UniquePortId typed_uid = client->getUid();
50+
iox::popo::UniquePortId::value_type uid =
51+
static_cast<iox::popo::UniquePortId::value_type>(typed_uid);
52+
size_t size = sizeof(uid);
53+
54+
if (!typed_uid.isValid() || size > RMW_GID_STORAGE_SIZE) {
55+
RMW_SET_ERROR_MSG("Could not generated publisher gid");
3556
return gid;
3657
}
3758
memcpy(gid.data, &uid, size);

rmw_iceoryx_cpp/src/internal/iceoryx_topic_names_and_types.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,18 +165,19 @@ std::map<std::string, std::string> get_service_names_and_types()
165165
iox::popo::MessagingPattern::REQ_RES);
166166

167167
for (auto & server : available_servers) {
168-
auto name_and_type = rmw_iceoryx_cpp::get_name_n_type_from_service_description(
168+
/// @todo Use structured bindings once all platforms are on C++17
169+
std::string name;
170+
std::string type;
171+
std::tie(name, type) = rmw_iceoryx_cpp::get_name_n_type_from_service_description(
169172
std::string(server.getServiceIDString().c_str()),
170173
std::string(server.getInstanceIDString().c_str()),
171174
std::string(server.getEventIDString().c_str()));
172175

173-
names_n_types[std::get<0>(name_and_type)] = std::get<1>(name_and_type);
176+
names_n_types[name] = type;
174177
/// @todo There is no API to find out which 'ServiceDescription' is offered by which node,
175178
/// for now we use 'NodeFoo'..
176-
servers_topics[std::string("NodeFoo")].push_back(
177-
std::get<0>(
178-
name_and_type));
179-
topic_servers[std::get<0>(name_and_type)].push_back(std::string("NodeFoo"));
179+
servers_topics[std::string("NodeFoo")].push_back(name);
180+
topic_servers[name].push_back(std::string("NodeFoo"));
180181
}
181182

182183
return names_n_types;

rmw_iceoryx_cpp/src/rmw_client.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,4 +203,26 @@ rmw_ret_t rmw_client_set_on_new_response_callback(
203203

204204
return RMW_RET_UNSUPPORTED;
205205
}
206+
207+
rmw_ret_t
208+
rmw_get_gid_for_client(const rmw_client_t * client, rmw_gid_t * gid)
209+
{
210+
RCUTILS_CHECK_ARGUMENT_FOR_NULL(client, RMW_RET_INVALID_ARGUMENT);
211+
RCUTILS_CHECK_ARGUMENT_FOR_NULL(gid, RMW_RET_INVALID_ARGUMENT);
212+
213+
RMW_CHECK_TYPE_IDENTIFIERS_MATCH(
214+
rmw_get_gid_for_client
215+
: client, client->implementation_identifier,
216+
rmw_get_implementation_identifier(),
217+
return RMW_RET_INCORRECT_RMW_IMPLEMENTATION);
218+
219+
IceoryxClient * iceoryx_client_abstraction = static_cast<IceoryxClient *>(client->data);
220+
221+
if (!iceoryx_client_abstraction) {
222+
RMW_SET_ERROR_MSG("client info handle is null");
223+
return RMW_RET_INVALID_ARGUMENT;
224+
}
225+
*gid = iceoryx_client_abstraction->gid_;
226+
return RMW_RET_OK;
227+
}
206228
} // extern "C"
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// Copyright (c) 2023 by Apex.AI Inc. All rights reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#include "rmw/impl/cpp/macros.hpp"
16+
#include "rmw/rmw.h"
17+
18+
extern "C"
19+
{
20+
rmw_ret_t
21+
rmw_take_dynamic_message(
22+
const rmw_subscription_t * subscription,
23+
rosidl_dynamic_typesupport_dynamic_data_t * dynamic_message,
24+
bool * taken,
25+
rmw_subscription_allocation_t * allocation)
26+
{
27+
RCUTILS_CHECK_ARGUMENT_FOR_NULL(subscription, RMW_RET_ERROR);
28+
RCUTILS_CHECK_ARGUMENT_FOR_NULL(dynamic_message, RMW_RET_ERROR);
29+
RCUTILS_CHECK_ARGUMENT_FOR_NULL(taken, RMW_RET_ERROR);
30+
RCUTILS_CHECK_ARGUMENT_FOR_NULL(allocation, RMW_RET_ERROR);
31+
32+
RMW_SET_ERROR_MSG("rmw_take_dynamic_message is not supported in iceoryx");
33+
return RMW_RET_UNSUPPORTED;
34+
}
35+
36+
rmw_ret_t
37+
rmw_take_dynamic_message_with_info(
38+
const rmw_subscription_t * subscription,
39+
rosidl_dynamic_typesupport_dynamic_data_t * dynamic_message,
40+
bool * taken,
41+
rmw_message_info_t * message_info,
42+
rmw_subscription_allocation_t * allocation)
43+
{
44+
RCUTILS_CHECK_ARGUMENT_FOR_NULL(subscription, RMW_RET_ERROR);
45+
RCUTILS_CHECK_ARGUMENT_FOR_NULL(dynamic_message, RMW_RET_ERROR);
46+
RCUTILS_CHECK_ARGUMENT_FOR_NULL(taken, RMW_RET_ERROR);
47+
RCUTILS_CHECK_ARGUMENT_FOR_NULL(message_info, RMW_RET_ERROR);
48+
RCUTILS_CHECK_ARGUMENT_FOR_NULL(allocation, RMW_RET_ERROR);
49+
50+
RMW_SET_ERROR_MSG("rmw_take_dynamic_message_with_info is not supported in iceoryx");
51+
return RMW_RET_UNSUPPORTED;
52+
}
53+
54+
rmw_ret_t
55+
rmw_serialization_support_init(
56+
const char * serialization_lib_name,
57+
rcutils_allocator_t * allocator,
58+
rosidl_dynamic_typesupport_serialization_support_t * serialization_support)
59+
{
60+
RCUTILS_CHECK_ARGUMENT_FOR_NULL(serialization_lib_name, RMW_RET_ERROR);
61+
RCUTILS_CHECK_ARGUMENT_FOR_NULL(allocator, RMW_RET_ERROR);
62+
RCUTILS_CHECK_ARGUMENT_FOR_NULL(serialization_support, RMW_RET_ERROR);
63+
64+
RMW_SET_ERROR_MSG("rmw_serialization_support_init is not supported in iceoryx");
65+
return RMW_RET_UNSUPPORTED;
66+
}
67+
} // extern "C"

rmw_iceoryx_cpp/src/rmw_request.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,10 @@ rmw_take_request(
139139
iceoryx_server->take()
140140
.and_then(
141141
[&](const void * iceoryx_request_payload) {
142-
const iox::mepoo::ChunkHeader * chunk_header =
142+
const auto * chunk_header =
143143
iox::mepoo::ChunkHeader::fromUserPayload(
144144
iceoryx_request_payload);
145-
const iox::popo::RequestHeader * iceoryx_request_header =
145+
const auto * iceoryx_request_header =
146146
iox::popo::RequestHeader::fromPayload(
147147
iceoryx_request_payload);
148148

rmw_iceoryx_cpp/src/rmw_response.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ rmw_take_response(
9898
&iceoryx_client_abstraction->type_supports_,
9999
ros_response);
100100
}
101-
iceoryx_client->releaseResponse(iceoryx_response_payload);
102101

103102
*taken = true;
104103
ret = RMW_RET_OK;
@@ -107,6 +106,7 @@ rmw_take_response(
107106
*taken = false;
108107
ret = RMW_RET_ERROR;
109108
}
109+
iceoryx_client->releaseResponse(iceoryx_response_payload);
110110
})
111111
.or_else(
112112
[&](auto &) {

0 commit comments

Comments
 (0)