Skip to content

Commit

Permalink
Convert interval to max_rate_hz
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexisTM committed Aug 5, 2024
1 parent 5117b54 commit b10d53f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/modules/uxrce_dds_client/dds_topics.h.em
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ struct SendSubscription {
const char* topic;
uint32_t topic_size;
UcdrSerializeMethod ucdr_serialize_method;
uint16_t polling_interval;
uint16_t max_rate_hz;
};

// Subscribers for messages to send
Expand All @@ -57,7 +57,7 @@ struct SendTopicsSubs {
"@(pub['topic'])",
ucdr_topic_size_@(pub['simple_base_type'])(),
&ucdr_serialize_@(pub['simple_base_type']),
@(pub['polling_interval']),
@(pub['max_rate_hz']),
},
@[ end for]@
};
Expand All @@ -75,7 +75,7 @@ void SendTopicsSubs::init() {
for (unsigned idx = 0; idx < sizeof(send_subscriptions)/sizeof(send_subscriptions[0]); ++idx) {
fds[idx].fd = orb_subscribe(send_subscriptions[idx].orb_meta);
fds[idx].events = POLLIN;
orb_set_interval(fds[idx].fd, send_subscriptions[idx].polling_interval);
orb_set_interval(fds[idx].fd, send_subscriptions[idx].max_rate_hz ? 1000000 / send_subscriptions[idx].max_rate_hz : 0);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/modules/uxrce_dds_client/dds_topics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ publications:

- topic: /fmu/out/sensor_combined
type: px4_msgs::msg::SensorCombined
polling_interval: 1
max_rate_hz: 1000

- topic: /fmu/out/timesync_status
type: px4_msgs::msg::TimesyncStatus
Expand Down
8 changes: 4 additions & 4 deletions src/modules/uxrce_dds_client/generate_dds_topics.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
import em
import yaml

DEFAULT_POLLING_RATE = 10
DEFAULT_MAX_RATE_HZ = 100

parser = argparse.ArgumentParser()
parser.add_argument("-m", "--topic-msg-dir", dest='msgdir', type=str,
Expand Down Expand Up @@ -100,10 +100,10 @@ def process_message_type(msg_type):
msg_type['dds_type'] = msg_type['type'].replace("::msg::", "::msg::dds_::") + "_"
# topic_simple: eg vehicle_status
msg_type['topic_simple'] = msg_type['topic'].split('/')[-1]
if "polling_interval" not in msg_type:
msg_type["polling_interval"] = DEFAULT_POLLING_RATE
if "max_rate_hz" not in msg_type:
msg_type["max_rate_hz"] = DEFAULT_MAX_RATE_HZ
else:
msg_type["polling_interval"] = int(msg_type["polling_interval"])
msg_type["max_rate_hz"] = int(msg_type["max_rate_hz"])

pubs_not_empty = msg_map['publications'] is not None
if pubs_not_empty:
Expand Down

0 comments on commit b10d53f

Please sign in to comment.