mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-01 02:55:07 +08:00
uxrce_client: add option to set polling rate limit per topic
This commit is contained in:
committed by
Silvan Fuhrer
parent
8c6d7235e4
commit
238dffcd1b
@@ -30,7 +30,7 @@ import os
|
|||||||
#include <uORB/topics/@(include).h>
|
#include <uORB/topics/@(include).h>
|
||||||
@[end for]@
|
@[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);
|
typedef bool (*UcdrSerializeMethod)(const void* data, ucdrBuffer& buf, int64_t time_offset);
|
||||||
|
|
||||||
@@ -66,6 +66,7 @@ struct SendSubscription {
|
|||||||
uint32_t message_version;
|
uint32_t message_version;
|
||||||
uint32_t topic_size;
|
uint32_t topic_size;
|
||||||
UcdrSerializeMethod ucdr_serialize_method;
|
UcdrSerializeMethod ucdr_serialize_method;
|
||||||
|
uint64_t publish_interval_ms;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Subscribers for messages to send
|
// Subscribers for messages to send
|
||||||
@@ -79,6 +80,7 @@ struct SendTopicsSubs {
|
|||||||
get_message_version<@(pub['simple_base_type'])_s>(),
|
get_message_version<@(pub['simple_base_type'])_s>(),
|
||||||
ucdr_topic_size_@(pub['simple_base_type'])(),
|
ucdr_topic_size_@(pub['simple_base_type'])(),
|
||||||
&ucdr_serialize_@(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]@
|
@[ end for]@
|
||||||
};
|
};
|
||||||
@@ -98,7 +100,7 @@ bool SendTopicsSubs::init(uxrSession *session, uxrStreamId reliable_out_stream_i
|
|||||||
if (fds[idx].events == 0) {
|
if (fds[idx].events == 0) {
|
||||||
fds[idx].fd = orb_subscribe(send_subscriptions[idx].orb_meta);
|
fds[idx].fd = orb_subscribe(send_subscriptions[idx].orb_meta);
|
||||||
fds[idx].events = POLLIN;
|
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,
|
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,
|
||||||
|
|||||||
Reference in New Issue
Block a user