mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
uxrce_client: add option to set polling rate limit per topic
This commit is contained in:
parent
8c6d7235e4
commit
238dffcd1b
@ -30,7 +30,7 @@ import os
|
||||
#include <uORB/topics/@(include).h>
|
||||
@[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<uint64_t>((@(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<ORB_ID>(send_subscriptions[idx].orb_meta->o_id), client_namespace, send_subscriptions[idx].topic,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user