Skip to content

Commit 986b18a

Browse files
committed
Add rmw_get_service_endpoint_info and update graph cache entity to support service type hash
Signed-off-by: Minju, Lee <[email protected]>
1 parent a16f9be commit 986b18a

File tree

12 files changed

+388
-53
lines changed

12 files changed

+388
-53
lines changed

rmw_connextdds/src/rmw_api_impl_ndds.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include "rmw/event.h"
1818
#include "rmw/get_node_info_and_types.h"
19+
#include "rmw/get_service_endpoint_info.h"
1920
#include "rmw/get_service_names_and_types.h"
2021
#include "rmw/get_topic_endpoint_info.h"
2122
#include "rmw/get_topic_names_and_types.h"
@@ -323,6 +324,31 @@ rmw_get_subscriptions_info_by_topic(
323324
node, allocator, topic_name, no_mangle, subscriptions_info);
324325
}
325326

327+
rmw_ret_t
328+
rmw_get_clients_info_by_service(
329+
const rmw_node_t * node,
330+
rcutils_allocator_t * allocator,
331+
const char * service_name,
332+
bool no_mangle,
333+
rmw_service_endpoint_info_array_t * clients_info)
334+
{
335+
return rmw_api_connextdds_get_clients_info_by_service(
336+
node, allocator, service_name, no_mangle, clients_info);
337+
}
338+
339+
340+
rmw_ret_t
341+
rmw_get_servers_info_by_service(
342+
const rmw_node_t * node,
343+
rcutils_allocator_t * allocator,
344+
const char * service_name,
345+
bool no_mangle,
346+
rmw_service_endpoint_info_array_t * servers_info)
347+
{
348+
return rmw_api_connextdds_get_servers_info_by_service(
349+
node, allocator, service_name, no_mangle, servers_info);
350+
}
351+
326352
/*****************************************************************************
327353
* Node API
328354
*****************************************************************************/

rmw_connextdds_common/include/rmw_connextdds/dds_api.hpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ rmw_connextdds_get_datawriter_qos(
108108
DDS_Topic * const topic,
109109
DDS_DataWriterQos * const qos,
110110
const rmw_qos_profile_t * const qos_policies,
111-
const rmw_publisher_options_t * const pub_options);
111+
const rmw_publisher_options_t * const pub_options,
112+
const rosidl_type_hash_t * ser_type_hash = nullptr);
112113

113114
rmw_ret_t
114115
rmw_connextdds_get_datareader_qos(
@@ -117,7 +118,8 @@ rmw_connextdds_get_datareader_qos(
117118
DDS_TopicDescription * const topic_desc,
118119
DDS_DataReaderQos * const qos,
119120
const rmw_qos_profile_t * const qos_policies,
120-
const rmw_subscription_options_t * const sub_options);
121+
const rmw_subscription_options_t * const sub_options,
122+
const rosidl_type_hash_t * ser_type_hash = nullptr);
121123

122124
DDS_DataWriter *
123125
rmw_connextdds_create_datawriter(
@@ -129,7 +131,8 @@ rmw_connextdds_create_datawriter(
129131
const bool internal,
130132
RMW_Connext_MessageTypeSupport * const type_support,
131133
DDS_Topic * const topic,
132-
DDS_DataWriterQos * const dw_qos);
134+
DDS_DataWriterQos * const dw_qos,
135+
const rosidl_type_hash_t * ser_type_hash = nullptr);
133136

134137
DDS_DataReader *
135138
rmw_connextdds_create_datareader(
@@ -141,7 +144,8 @@ rmw_connextdds_create_datareader(
141144
const bool internal,
142145
RMW_Connext_MessageTypeSupport * const type_support,
143146
DDS_TopicDescription * const topic_desc,
144-
DDS_DataReaderQos * const dr_qos);
147+
DDS_DataReaderQos * const dr_qos,
148+
const rosidl_type_hash_t * ser_type_hash = nullptr);
145149

146150
rmw_ret_t
147151
rmw_connextdds_write_message(

rmw_connextdds_common/include/rmw_connextdds/graph_cache.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ rmw_ret_t
7070
rmw_connextdds_graph_on_service_created(
7171
rmw_context_impl_t * const ctx,
7272
const rmw_node_t * const node,
73-
RMW_Connext_Service * const svc);
73+
RMW_Connext_Service * const svc,
74+
const rosidl_type_hash_t * ser_type_hash);
7475

7576
rmw_ret_t
7677
rmw_connextdds_graph_on_service_deleted(
@@ -82,7 +83,8 @@ rmw_ret_t
8283
rmw_connextdds_graph_on_client_created(
8384
rmw_context_impl_t * const ctx,
8485
const rmw_node_t * const node,
85-
RMW_Connext_Client * const client);
86+
RMW_Connext_Client * const client,
87+
const rosidl_type_hash_t * ser_type_hash);
8688

8789
rmw_ret_t
8890
rmw_connextdds_graph_on_client_deleted(

rmw_connextdds_common/include/rmw_connextdds/rmw_api_impl.hpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,24 @@ rmw_api_connextdds_get_subscriptions_info_by_topic(
224224
bool no_mangle,
225225
rmw_topic_endpoint_info_array_t * subscriptions_info);
226226

227+
RMW_CONNEXTDDS_PUBLIC
228+
rmw_ret_t
229+
rmw_api_connextdds_get_clients_info_by_service(
230+
const rmw_node_t * node,
231+
rcutils_allocator_t * allocator,
232+
const char * service_name,
233+
bool no_mangle,
234+
rmw_service_endpoint_info_array_t * clients_info);
235+
236+
RMW_CONNEXTDDS_PUBLIC
237+
rmw_ret_t
238+
rmw_api_connextdds_get_servers_info_by_service(
239+
const rmw_node_t * node,
240+
rcutils_allocator_t * allocator,
241+
const char * service_name,
242+
bool no_mangle,
243+
rmw_service_endpoint_info_array_t * servers_info);
244+
227245
/*****************************************************************************
228246
* Node API
229247
*****************************************************************************/

rmw_connextdds_common/include/rmw_connextdds/rmw_impl.hpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ class RMW_Connext_Publisher
152152
const RMW_Connext_MessageType msg_type = RMW_CONNEXT_MESSAGE_USERDATA,
153153
const void * const intro_members = nullptr,
154154
const bool intro_members_cpp = false,
155-
std::string * const type_name = nullptr);
155+
std::string * const type_name = nullptr,
156+
const rosidl_type_hash_t * ser_type_hash = nullptr);
156157

157158
rmw_ret_t
158159
finalize();
@@ -417,7 +418,8 @@ class RMW_Connext_Subscriber
417418
std::string * const type_name = nullptr,
418419
const char * const cft_name = nullptr,
419420
const char * const cft_filter = nullptr,
420-
RMW_Connext_Publisher * const related_pub = nullptr);
421+
RMW_Connext_Publisher * const related_pub = nullptr,
422+
const rosidl_type_hash_t * ser_type_hash = nullptr);
421423

422424
rmw_ret_t
423425
finalize();
@@ -978,7 +980,8 @@ rmw_connextdds_get_readerwriter_qos(
978980
DDS_UserDataQosPolicy * const user_data,
979981
const rmw_qos_profile_t * const qos_policies,
980982
const rmw_publisher_options_t * const pub_options,
981-
const rmw_subscription_options_t * const sub_options);
983+
const rmw_subscription_options_t * const sub_options,
984+
const rosidl_type_hash_t * ser_type_hash = nullptr);
982985

983986
rmw_ret_t
984987
rmw_connextdds_readerwriter_qos_to_ros(

rmw_connextdds_common/src/common/rmw_graph.cpp

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ rmw_connextdds_graph_add_entityEA(
4141
const DDS_LivelinessQosPolicy * const liveliness,
4242
const DDS_LifespanQosPolicy * const lifespan,
4343
const bool is_reader,
44-
const bool local);
44+
const bool local,
45+
const rosidl_type_hash_t * ser_type_hash = nullptr);
4546

4647
static rmw_ret_t
4748
rmw_connextdds_graph_remove_entityEA(
@@ -53,13 +54,15 @@ static rmw_ret_t
5354
rmw_connextdds_graph_add_local_publisherEA(
5455
rmw_context_impl_t * const ctx,
5556
const rmw_node_t * const node,
56-
RMW_Connext_Publisher * const pub);
57+
RMW_Connext_Publisher * const pub,
58+
const rosidl_type_hash_t * ser_type_hash = nullptr);
5759

5860
static rmw_ret_t
5961
rmw_connextdds_graph_add_local_subscriberEA(
6062
rmw_context_impl_t * const ctx,
6163
const rmw_node_t * const node,
62-
RMW_Connext_Subscriber * const sub);
64+
RMW_Connext_Subscriber * const sub,
65+
const rosidl_type_hash_t * ser_type_hash = nullptr);
6366

6467
rmw_ret_t
6568
rmw_connextdds_graph_initialize(rmw_context_impl_t * const ctx)
@@ -431,7 +434,8 @@ rmw_ret_t
431434
rmw_connextdds_graph_on_service_created(
432435
rmw_context_impl_t * const ctx,
433436
const rmw_node_t * const node,
434-
RMW_Connext_Service * const svc)
437+
RMW_Connext_Service * const svc,
438+
const rosidl_type_hash_t * ser_type_hash)
435439
{
436440
std::lock_guard<std::mutex> guard(ctx->common_mutex);
437441
const rmw_gid_t pub_gid = *svc->publisher()->gid(),
@@ -454,14 +458,14 @@ rmw_connextdds_graph_on_service_created(
454458
});
455459

456460
rmw_ret_t rc = rmw_connextdds_graph_add_local_subscriberEA(
457-
ctx, node, svc->subscriber());
461+
ctx, node, svc->subscriber(), ser_type_hash);
458462
if (RMW_RET_OK != rc) {
459463
return rc;
460464
}
461465
// set it so that it can be removed in the `scope_exit_entities_reset`
462466
added_sub = true;
463467

464-
rc = rmw_connextdds_graph_add_local_publisherEA(ctx, node, svc->publisher());
468+
rc = rmw_connextdds_graph_add_local_publisherEA(ctx, node, svc->publisher(), ser_type_hash);
465469
if (RMW_RET_OK != rc) {
466470
return rc;
467471
}
@@ -509,7 +513,8 @@ rmw_ret_t
509513
rmw_connextdds_graph_on_client_created(
510514
rmw_context_impl_t * const ctx,
511515
const rmw_node_t * const node,
512-
RMW_Connext_Client * const client)
516+
RMW_Connext_Client * const client,
517+
const rosidl_type_hash_t * ser_type_hash)
513518
{
514519
std::lock_guard<std::mutex> guard(ctx->common_mutex);
515520
const rmw_gid_t pub_gid = *client->publisher()->gid(),
@@ -532,13 +537,13 @@ rmw_connextdds_graph_on_client_created(
532537
});
533538

534539
rmw_ret_t rc = rmw_connextdds_graph_add_local_subscriberEA(
535-
ctx, node, client->subscriber());
540+
ctx, node, client->subscriber(), ser_type_hash);
536541
if (RMW_RET_OK != rc) {
537542
return rc;
538543
}
539544
added_sub = true;
540545

541-
rc = rmw_connextdds_graph_add_local_publisherEA(ctx, node, client->publisher());
546+
rc = rmw_connextdds_graph_add_local_publisherEA(ctx, node, client->publisher(), ser_type_hash);
542547
if (RMW_RET_OK != rc) {
543548
return rc;
544549
}
@@ -666,7 +671,8 @@ rmw_connextdds_graph_add_entityEA(
666671
const DDS_LivelinessQosPolicy * const liveliness,
667672
const DDS_LifespanQosPolicy * const lifespan,
668673
const bool is_reader,
669-
const bool local)
674+
const bool local,
675+
const rosidl_type_hash_t * ser_type_hash)
670676
{
671677
UNUSED_ARG(local);
672678
rmw_gid_t gid;
@@ -723,7 +729,8 @@ rmw_connextdds_graph_add_entityEA(
723729
type_hash,
724730
dp_gid,
725731
qos_profile,
726-
is_reader))
732+
is_reader,
733+
ser_type_hash))
727734
{
728735
// This is downgraded to a debug message because we might
729736
// enter this path when asserting entities from discovery.
@@ -755,7 +762,8 @@ rmw_ret_t
755762
rmw_connextdds_graph_add_local_publisherEA(
756763
rmw_context_impl_t * const ctx,
757764
const rmw_node_t * const node,
758-
RMW_Connext_Publisher * const pub)
765+
RMW_Connext_Publisher * const pub,
766+
const rosidl_type_hash_t * ser_type_hash)
759767
{
760768
UNUSED_ARG(node);
761769
RMW_CONNEXT_LOG_DEBUG_A(
@@ -820,14 +828,16 @@ rmw_connextdds_graph_add_local_publisherEA(
820828
nullptr /* Micro doesn't support LifespanQosPolicy */,
821829
#endif /* RMW_CONNEXT_DDS_API */
822830
false /* is_reader */,
823-
true /* local */);
831+
true /* local */,
832+
ser_type_hash);
824833
}
825834

826835
rmw_ret_t
827836
rmw_connextdds_graph_add_local_subscriberEA(
828837
rmw_context_impl_t * const ctx,
829838
const rmw_node_t * const node,
830-
RMW_Connext_Subscriber * const sub)
839+
RMW_Connext_Subscriber * const sub,
840+
const rosidl_type_hash_t * ser_type_hash)
831841
{
832842
UNUSED_ARG(node);
833843
RMW_CONNEXT_LOG_DEBUG_A(
@@ -888,7 +898,8 @@ rmw_connextdds_graph_add_local_subscriberEA(
888898
&dr_qos.liveliness,
889899
nullptr /* Lifespan is a writer-only qos policy */,
890900
true /* is_reader */,
891-
true /* local */);
901+
true /* local */,
902+
ser_type_hash);
892903
}
893904

894905
rmw_ret_t
@@ -932,6 +943,13 @@ rmw_connextdds_graph_add_remote_entity(
932943
// We handled the error, so clear it out
933944
rmw_reset_error();
934945
}
946+
rosidl_type_hash_t ser_type_hash;
947+
rosidl_type_hash_t * ser_type_hash_ptr = nullptr;
948+
if (RMW_RET_OK == rmw_dds_common::parse_sertype_hash_from_user_data(
949+
reinterpret_cast<const uint8_t *>(user_data_data), user_data_size, ser_type_hash))
950+
{
951+
ser_type_hash_ptr = &ser_type_hash;
952+
}
935953

936954
rmw_ret_t rc = rmw_connextdds_graph_add_entityEA(
937955
ctx,
@@ -947,7 +965,8 @@ rmw_connextdds_graph_add_remote_entity(
947965
liveliness,
948966
lifespan,
949967
is_reader,
950-
false /* local */);
968+
false /* local */,
969+
ser_type_hash_ptr);
951970
if (RMW_RET_OK != rc) {
952971
return rc;
953972
}

0 commit comments

Comments
 (0)