Skip to content

Commit 8e91fea

Browse files
Use new Blueberry v2.0.3 feature request-response and its discovery (ros2#84)
1 parent 590037d commit 8e91fea

24 files changed

+1106
-61
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ Unfortunately, not all features are yet fully fleshed out.
154154
| `ros2 node list` | :heavy_check_mark: |
155155
| `ros2 node info` | :heavy_check_mark: |
156156
| `ros2 interface *` | :heavy_check_mark: |
157-
| `ros2 service *` | :x: (coming with iceoryx v2.0) |
158-
| `ros2 param list` | :x: (coming with iceoryx v2.0) |
157+
| `ros2 service *` | :heavy_check_mark: |
158+
| `ros2 param list` | :x: |
159159
| `rqt_graph` | :heavy_check_mark: |
160160
| `rqt_top` | :heavy_check_mark: |
161161
| `rqt_console` | :heavy_check_mark: |

rmw_iceoryx_cpp/include/rmw_iceoryx_cpp/iceoryx_deserialize.hpp

+12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// Copyright (c) 2019 by Robert Bosch GmbH. All rights reserved.
2+
// Copyright (c) 2023 by Apex.AI Inc. All rights reserved.
23
//
34
// Licensed under the Apache License, Version 2.0 (the "License");
45
// you may not use this file except in compliance with the License.
@@ -16,6 +17,7 @@
1617
#define RMW_ICEORYX_CPP__ICEORYX_DESERIALIZE_HPP_
1718

1819
struct rosidl_message_type_support_t;
20+
struct rosidl_service_type_support_t;
1921

2022
namespace rmw_iceoryx_cpp
2123
{
@@ -26,5 +28,15 @@ void deserialize(
2628
const rosidl_message_type_support_t * type_supports,
2729
void * ros_message);
2830

31+
void deserializeRequest(
32+
const char * serialized_msg,
33+
const rosidl_service_type_support_t * type_supports,
34+
void * ros_message);
35+
36+
void deserializeResponse(
37+
const char * serialized_msg,
38+
const rosidl_service_type_support_t * type_supports,
39+
void * ros_message);
40+
2941
} // namespace rmw_iceoryx_cpp
3042
#endif // RMW_ICEORYX_CPP__ICEORYX_DESERIALIZE_HPP_

rmw_iceoryx_cpp/include/rmw_iceoryx_cpp/iceoryx_name_conversion.hpp

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Copyright (c) 2019 by Robert Bosch GmbH. All rights reserved.
22
// Copyright (c) 2021 by ZhenshengLee. All rights reserved.
3+
// Copyright (c) 2023 by Apex.AI Inc. All rights reserved.
34
//
45
// Licensed under the Apache License, Version 2.0 (the "License");
56
// you may not use this file except in compliance with the License.
@@ -24,6 +25,7 @@
2425
#include "iceoryx_dust/cxx/std_string_support.hpp"
2526

2627
struct rosidl_message_type_support_t;
28+
struct rosidl_service_type_support_t;
2729

2830
namespace rmw_iceoryx_cpp
2931
{
@@ -72,5 +74,10 @@ get_iceoryx_service_description(
7274
const std::string & topic,
7375
const rosidl_message_type_support_t * type_supports);
7476

77+
iox::capro::ServiceDescription
78+
get_iceoryx_service_description(
79+
const std::string & topic,
80+
const rosidl_service_type_support_t * type_supports);
81+
7582
} // namespace rmw_iceoryx_cpp
7683
#endif // RMW_ICEORYX_CPP__ICEORYX_NAME_CONVERSION_HPP_

rmw_iceoryx_cpp/include/rmw_iceoryx_cpp/iceoryx_serialize.hpp

+12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// Copyright (c) 2019 by Robert Bosch GmbH. All rights reserved.
2+
// Copyright (c) 2023 by Apex.AI Inc. All rights reserved.
23
//
34
// Licensed under the Apache License, Version 2.0 (the "License");
45
// you may not use this file except in compliance with the License.
@@ -18,6 +19,7 @@
1819
#include <vector>
1920

2021
struct rosidl_message_type_support_t;
22+
struct rosidl_service_type_support_t;
2123

2224
namespace rmw_iceoryx_cpp
2325
{
@@ -27,5 +29,15 @@ void serialize(
2729
const rosidl_message_type_support_t * type_supports,
2830
std::vector<char> & payload_vector);
2931

32+
void serializeRequest(
33+
const void * ros_message,
34+
const rosidl_service_type_support_t * type_supports,
35+
std::vector<char> & payload_vector);
36+
37+
void serializeResponse(
38+
const void * ros_message,
39+
const rosidl_service_type_support_t * type_supports,
40+
std::vector<char> & payload_vector);
41+
3042
} // namespace rmw_iceoryx_cpp
3143
#endif // RMW_ICEORYX_CPP__ICEORYX_SERIALIZE_HPP_

rmw_iceoryx_cpp/include/rmw_iceoryx_cpp/iceoryx_topic_names_and_types.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// Copyright (c) 2019 by Robert Bosch GmbH. All rights reserved.
2+
// Copyright (c) 2023 by Apex.AI Inc. All rights reserved.
23
//
34
// Licensed under the Apache License, Version 2.0 (the "License");
45
// you may not use this file except in compliance with the License.
@@ -35,6 +36,7 @@ void fill_topic_containers(
3536
std::map<std::string, std::vector<std::string>> & topic_publishers_);
3637

3738
std::map<std::string, std::string> get_topic_names_and_types();
39+
std::map<std::string, std::string> get_service_names_and_types();
3840

3941
std::map<std::string, std::vector<std::string>> get_nodes_and_publishers();
4042

rmw_iceoryx_cpp/include/rmw_iceoryx_cpp/iceoryx_type_info_introspection.hpp

+13-1
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) 2021 by Apex.AI Inc. All rights reserved.
2+
// Copyright (c) 2021 - 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.
@@ -20,6 +20,7 @@
2020
#include <utility>
2121

2222
struct rosidl_message_type_support_t;
23+
struct rosidl_service_type_support_t;
2324

2425
namespace rmw_iceoryx_cpp
2526
{
@@ -35,15 +36,26 @@ enum class TypeSupportLanguage
3536
const std::pair<TypeSupportLanguage, const rosidl_message_type_support_t *> get_type_support(
3637
const rosidl_message_type_support_t * type_supports);
3738

39+
/// @brief Wraps get_service_typesupport_handle() and does error handling
40+
/// @return std::pair containing enum TypeSupportLanguage and handle to the type support
41+
const std::pair<TypeSupportLanguage, const rosidl_service_type_support_t *> get_type_support(
42+
const rosidl_service_type_support_t * type_supports);
43+
3844
bool iceoryx_is_fixed_size(const rosidl_message_type_support_t * type_supports);
45+
bool iceoryx_is_fixed_size(const rosidl_service_type_support_t * type_supports);
3946

4047
bool iceoryx_is_valid_type_support(const rosidl_message_type_support_t * type_supports);
48+
bool iceoryx_is_valid_type_support(const rosidl_service_type_support_t * type_supports);
4149

4250
size_t iceoryx_get_message_size(const rosidl_message_type_support_t * type_supports);
51+
size_t iceoryx_get_request_size(const rosidl_service_type_support_t * type_supports);
52+
size_t iceoryx_get_response_size(const rosidl_service_type_support_t * type_supports);
4353

4454
std::string iceoryx_get_message_name(const rosidl_message_type_support_t * type_supports);
55+
std::string iceoryx_get_service_name(const rosidl_service_type_support_t * type_supports);
4556

4657
std::string iceoryx_get_message_namespace(const rosidl_message_type_support_t * type_supports);
58+
std::string iceoryx_get_service_namespace(const rosidl_service_type_support_t * type_supports);
4759

4860
void iceoryx_init_message(
4961
const rosidl_message_type_support_t * type_supports,

rmw_iceoryx_cpp/package.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<?xml-model href="http://download.ros.org/schema/package_format2.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
33
<package format="2">
44
<name>rmw_iceoryx_cpp</name>
5-
<version>1.0.1</version>
5+
<version>2.0.3</version>
66
<description>rmw implementation for Bosch's zero copy middleware iceoryx</description>
77
<maintainer email="[email protected]">Simon Hoinkis</maintainer>
88
<license>Apache License 2.0</license>

rmw_iceoryx_cpp/src/internal/iceoryx_deserialize.cpp

+38-1
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) 2021 by Apex.AI Inc. All rights reserved.
2+
// Copyright (c) 2021 - 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.
@@ -17,6 +17,7 @@
1717

1818
#include "rosidl_typesupport_introspection_c/identifier.h"
1919
#include "rosidl_typesupport_introspection_c/message_introspection.h"
20+
#include "rosidl_typesupport_introspection_c/service_introspection.h"
2021

2122
#include "rosidl_typesupport_introspection_cpp/identifier.hpp"
2223
#include "rosidl_typesupport_introspection_cpp/message_introspection.hpp"
@@ -50,4 +51,40 @@ void deserialize(
5051
}
5152
}
5253

54+
void deserializeRequest(
55+
const char * serialized_msg,
56+
const rosidl_service_type_support_t * type_supports,
57+
void * ros_message)
58+
{
59+
auto ts = get_type_support(type_supports);
60+
61+
if (ts.first == TypeSupportLanguage::CPP) {
62+
auto members_cpp =
63+
static_cast<const rosidl_typesupport_introspection_cpp::ServiceMembers *>(ts.second->data);
64+
rmw_iceoryx_cpp::details_cpp::deserializeRequest(serialized_msg, members_cpp, ros_message);
65+
} else if (ts.first == TypeSupportLanguage::C) {
66+
auto members_c =
67+
static_cast<const rosidl_typesupport_introspection_c__ServiceMembers *>(ts.second->data);
68+
rmw_iceoryx_cpp::details_c::deserializeRequest(serialized_msg, members_c, ros_message);
69+
}
70+
}
71+
72+
void deserializeResponse(
73+
const char * serialized_msg,
74+
const rosidl_service_type_support_t * type_supports,
75+
void * ros_message)
76+
{
77+
auto ts = get_type_support(type_supports);
78+
79+
if (ts.first == TypeSupportLanguage::CPP) {
80+
auto members_cpp =
81+
static_cast<const rosidl_typesupport_introspection_cpp::ServiceMembers *>(ts.second->data);
82+
rmw_iceoryx_cpp::details_cpp::deserializeResponse(serialized_msg, members_cpp, ros_message);
83+
} else if (ts.first == TypeSupportLanguage::C) {
84+
auto members_c =
85+
static_cast<const rosidl_typesupport_introspection_c__ServiceMembers *>(ts.second->data);
86+
rmw_iceoryx_cpp::details_c::deserializeResponse(serialized_msg, members_c, ros_message);
87+
}
88+
}
89+
5390
} // namespace rmw_iceoryx_cpp

rmw_iceoryx_cpp/src/internal/iceoryx_deserialize_typesupport_c.hpp

+18
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved.
2+
// Copyright (c) 2023 by Apex.AI Inc. All rights reserved.
23
//
34
// Licensed under the Apache License, Version 2.0 (the "License");
45
// you may not use this file except in compliance with the License.
@@ -27,6 +28,7 @@
2728

2829
#include "rosidl_typesupport_introspection_c/field_types.h"
2930
#include "rosidl_typesupport_introspection_c/message_introspection.h"
31+
#include "rosidl_typesupport_introspection_c/service_introspection.h"
3032

3133
#include "./iceoryx_serialization_common.hpp"
3234

@@ -239,6 +241,22 @@ const char * deserialize(
239241
return serialized_msg;
240242
}
241243

244+
const char * deserializeResponse(
245+
const char * serialized_msg,
246+
const rosidl_typesupport_introspection_c__ServiceMembers * service_members,
247+
void * ros_message)
248+
{
249+
return deserialize(serialized_msg, service_members->response_members_, ros_message);
250+
}
251+
252+
const char * deserializeRequest(
253+
const char * serialized_msg,
254+
const rosidl_typesupport_introspection_c__ServiceMembers * service_members,
255+
void * ros_message)
256+
{
257+
return deserialize(serialized_msg, service_members->request_members_, ros_message);
258+
}
259+
242260
} // namespace details_c
243261
} // namespace rmw_iceoryx_cpp
244262
#endif // INTERNAL__ICEORYX_DESERIALIZE_TYPESUPPORT_C_HPP_

rmw_iceoryx_cpp/src/internal/iceoryx_deserialize_typesupport_cpp.hpp

+18-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved.
2+
// Copyright (c) 2023 by Apex.AI Inc. All rights reserved.
23
//
34
// Licensed under the Apache License, Version 2.0 (the "License");
45
// you may not use this file except in compliance with the License.
@@ -24,7 +25,7 @@
2425
#include <vector>
2526

2627
#include "rosidl_typesupport_introspection_cpp/field_types.hpp"
27-
#include "rosidl_typesupport_introspection_cpp/message_introspection.hpp"
28+
#include "rosidl_typesupport_introspection_cpp/service_introspection.hpp"
2829

2930
#include "./iceoryx_serialization_common.hpp"
3031

@@ -309,6 +310,22 @@ const char * deserialize(
309310
return serialized_msg;
310311
}
311312

313+
const char * deserializeResponse(
314+
const char * serialized_msg,
315+
const rosidl_typesupport_introspection_cpp::ServiceMembers * service_members,
316+
void * ros_message)
317+
{
318+
return deserialize(serialized_msg, service_members->response_members_, ros_message);
319+
}
320+
321+
const char * deserializeRequest(
322+
const char * serialized_msg,
323+
const rosidl_typesupport_introspection_cpp::ServiceMembers * service_members,
324+
void * ros_message)
325+
{
326+
return deserialize(serialized_msg, service_members->request_members_, ros_message);
327+
}
328+
312329
} // namespace details_cpp
313330
} // namespace rmw_iceoryx_cpp
314331
#endif // INTERNAL__ICEORYX_DESERIALIZE_TYPESUPPORT_CPP_HPP_

rmw_iceoryx_cpp/src/internal/iceoryx_get_topic_endpoint_info.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// Copyright (c) 2021 by ZhenshengLee. All rights reserved.
2+
// Copyright (c) 2023 by Apex.AI Inc. All rights reserved.
23
//
34
// Licensed under the Apache License, Version 2.0 (the "License");
45
// you may not use this file except in compliance with the License.
@@ -117,7 +118,7 @@ fill_rmw_publisher_end_info(
117118

118119
int i = 0;
119120
// store all data in rmw_topic_endpoint_info_array_t
120-
for (const auto node_full_name : full_name_array) {
121+
for (const auto & node_full_name : full_name_array) {
121122
auto name_n_space = get_name_n_space_from_node_full_name(node_full_name);
122123
auto rmw_topic_endpoint_info = rmw_get_zero_initialized_topic_endpoint_info();
123124
// duplicate and store the topic_name
@@ -204,7 +205,7 @@ fill_rmw_subscriber_end_info(
204205

205206
int i = 0;
206207
// store all data in rmw_topic_endpoint_info_array_t
207-
for (const auto node_full_name : full_name_array) {
208+
for (const auto & node_full_name : full_name_array) {
208209
auto name_n_space = get_name_n_space_from_node_full_name(node_full_name);
209210
auto rmw_topic_endpoint_info = rmw_get_zero_initialized_topic_endpoint_info();
210211
// duplicate and store the topic_name

rmw_iceoryx_cpp/src/internal/iceoryx_name_conversion.cpp

+39-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Copyright (c) 2019 by Robert Bosch GmbH. All rights reserved.
22
// Copyright (c) 2021 by ZhenshengLee. All rights reserved.
3+
// Copyright (c) 2023 by Apex.AI Inc. All rights reserved.
34
//
45
// Licensed under the Apache License, Version 2.0 (the "License");
56
// you may not use this file except in compliance with the License.
@@ -21,6 +22,7 @@
2122
#include "rcpputils/split.hpp"
2223

2324
#include "rosidl_typesupport_cpp/message_type_support.hpp"
25+
#include "rosidl_typesupport_cpp/service_type_support.hpp"
2426

2527
#include "rosidl_typesupport_introspection_c/field_types.h"
2628
#include "rosidl_typesupport_introspection_c/identifier.h"
@@ -62,6 +64,15 @@ inline void extract_type(
6264
type_name = rmw_iceoryx_cpp::iceoryx_get_message_name(type_support);
6365
}
6466

67+
inline void extract_type(
68+
const rosidl_service_type_support_t * type_support,
69+
std::string & package_name,
70+
std::string & type_name)
71+
{
72+
package_name = to_message_type(rmw_iceoryx_cpp::iceoryx_get_service_namespace(type_support));
73+
type_name = rmw_iceoryx_cpp::iceoryx_get_service_name(type_support);
74+
}
75+
6576
namespace rmw_iceoryx_cpp
6677
{
6778

@@ -159,16 +170,10 @@ get_service_description_from_name_n_type(
159170
return std::make_tuple(service, instance, event);
160171
}
161172

162-
iox::capro::ServiceDescription
163-
get_iceoryx_service_description(
173+
iox::capro::ServiceDescription make_service_description(
164174
const std::string & topic_name,
165-
const rosidl_message_type_support_t * type_supports)
175+
const std::string & type_name)
166176
{
167-
std::string package_name;
168-
std::string type_name;
169-
extract_type(type_supports, package_name, type_name);
170-
type_name = package_name + "/" + type_name;
171-
172177
auto serviceDescriptionTuple = get_service_description_from_name_n_type(topic_name, type_name);
173178

174179
return iox::capro::ServiceDescription(
@@ -186,4 +191,30 @@ get_iceoryx_service_description(
186191
serviceDescriptionTuple))));
187192
}
188193

194+
iox::capro::ServiceDescription
195+
get_iceoryx_service_description(
196+
const std::string & topic_name,
197+
const rosidl_message_type_support_t * type_supports)
198+
{
199+
std::string package_name;
200+
std::string type_name;
201+
extract_type(type_supports, package_name, type_name);
202+
type_name = package_name + "/" + type_name;
203+
204+
return make_service_description(topic_name, type_name);
205+
}
206+
207+
iox::capro::ServiceDescription
208+
get_iceoryx_service_description(
209+
const std::string & topic_name,
210+
const rosidl_service_type_support_t * type_supports)
211+
{
212+
std::string package_name;
213+
std::string type_name;
214+
extract_type(type_supports, package_name, type_name);
215+
type_name = package_name + "/" + type_name;
216+
217+
return make_service_description(topic_name, type_name);
218+
}
219+
189220
} // namespace rmw_iceoryx_cpp

0 commit comments

Comments
 (0)