Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for topic QOS for ros2topic bw, delay and hz #935

Open
wants to merge 3 commits into
base: rolling
Choose a base branch
from

Conversation

TonyWelte
Copy link

This PR adds support for QoS configuration for the verbs: bw, delay and hz.

It moves the logic to decide on the QoS from echo into ros2topic.api to keep the same logic for the 4 verbs.

I'm not really satisfied with my extract_qos_arguments function. It's a bit useless, it might be cleaner to just pass the full args to each _rostopic_verb function

Resolves: #719

Copy link
Collaborator

@fujitatomoya fujitatomoya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test with QoS arguments would be ideal for hz, bw, deleyand echo. (this also can be a follow-up PR, i think)

@@ -253,3 +256,78 @@ def add_qos_arguments(parser: ArgumentParser, subscribe_or_publish: str, default
help=(
f'Quality of service liveliness lease duration setting to {subscribe_or_publish} '
'with (overrides liveliness lease duration value of --qos-profile option'))

def extract_qos_arguments(args):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not understand why this is needed here. it does not do anything but passing all variables into another class object, can you elaborate this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's definitely useless. I had a few alternatives in mind but none that I was satisfied with:

  • just pass args to the _rostopic_verb functions as the qos parameter. But in that case I might as well remove the other arguments from _rostopic_verb since args has all of them
  • split each qos argument into their own function parameters but that would have added 6 parameters to both _rostopic_verb and choose_qos
    I'm not sure what would best fit the style of this package. What do you think ?


return qos

def choose_qos(node, topic_name: str, qos_args):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think moving this to ros2topic/api is nice to do here aligned with add_qos_arguments.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

besides that, i see choose_qos function is doing like adaptive qos configuration based on the concerned publisher information for durability and reliability to avoid incompatible QoS setting when it starts echo. I think this can be also applied to ros2 topic pub without this adaptive qos checking for the publisher? that does a bit more refactoring and cleaning for ros2topic qos functions.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what you mean. From what I understand apart from the adaptive QoS configuration choose_qos just calls qos_profile_from_short_keys which ends up calling the same function profile_configure_short_keys that is called by pub ?

Comment on lines -65 to +67
'topic',
'topic_name',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to change this? Is this related to what this PR is fixing? just checking.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not needed but I initially implemented this feature by removing all parameters from _rostopic_verb and just passing it args and noticed that different verbs used different argument names so I harmonized them.

Comment on lines -70 to +73
'--window', '-w', type=positive_int, default=DEFAULT_WINDOW_SIZE,
'--window', '-w', dest='window_size', type=positive_int, default=DEFAULT_WINDOW_SIZE,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, is this required for this PR?

Signed-off-by: Anthony Welte <[email protected]>
@TonyWelte
Copy link
Author

I'm planning on adding tests once I have time and figure out how to run the tests without getting 13 failures after over 7 min of runtime

@TonyWelte
Copy link
Author

I’ve explored adding tests for the QoS parameters but couldn’t find a clear starting point. Since the other verbs, pub and echo, don’t have similar tests, there’s no existing reference to build upon. I’ve removed the Draft status, and if reviewers have suggestions on how to approach these tests, I’d be happy to implement them.

Additionally, I made a small change to the existing tests to address an instability in test_topic_bw. If the "bw" timer is triggered immediately after the two default (52 bytes) messages are received, the estimated bandwidth might slightly exceed 100B/s, requiring three digits. This modification resolves that issue.

@TonyWelte TonyWelte marked this pull request as ready for review November 19, 2024 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add qos parameters to ros2 topic hz
2 participants