From 238dffcd1b71e5ceb2f30ac817706d20da03c0d0 Mon Sep 17 00:00:00 2001 From: GuillaumeLaine Date: Fri, 23 May 2025 12:38:28 +0200 Subject: [PATCH] uxrce_client: add option to set polling rate limit per topic --- src/modules/uxrce_dds_client/dds_topics.h.em | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/modules/uxrce_dds_client/dds_topics.h.em b/src/modules/uxrce_dds_client/dds_topics.h.em index deba362668..7ff7605ccd 100644 --- a/src/modules/uxrce_dds_client/dds_topics.h.em +++ b/src/modules/uxrce_dds_client/dds_topics.h.em @@ -30,7 +30,7 @@ import os #include @[end for]@ -#define UXRCE_DEFAULT_POLL_RATE 10 +#define UXRCE_DEFAULT_POLL_INTERVAL_MS 10 typedef bool (*UcdrSerializeMethod)(const void* data, ucdrBuffer& buf, int64_t time_offset); @@ -66,6 +66,7 @@ struct SendSubscription { uint32_t message_version; uint32_t topic_size; UcdrSerializeMethod ucdr_serialize_method; + uint64_t publish_interval_ms; }; // Subscribers for messages to send @@ -79,6 +80,7 @@ struct SendTopicsSubs { get_message_version<@(pub['simple_base_type'])_s>(), ucdr_topic_size_@(pub['simple_base_type'])(), &ucdr_serialize_@(pub['simple_base_type']), + static_cast((@(pub.get('rate_limit', 0)) > 0) ? (1e3 / @(pub.get('rate_limit', 1e3))) : UXRCE_DEFAULT_POLL_INTERVAL_MS), }, @[ end for]@ }; @@ -98,7 +100,7 @@ bool SendTopicsSubs::init(uxrSession *session, uxrStreamId reliable_out_stream_i if (fds[idx].events == 0) { fds[idx].fd = orb_subscribe(send_subscriptions[idx].orb_meta); fds[idx].events = POLLIN; - orb_set_interval(fds[idx].fd, UXRCE_DEFAULT_POLL_RATE); + orb_set_interval(fds[idx].fd, send_subscriptions[idx].publish_interval_ms); } if (!create_data_writer(session, reliable_out_stream_id, participant_id, static_cast(send_subscriptions[idx].orb_meta->o_id), client_namespace, send_subscriptions[idx].topic,