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

Fix QoS history being unknown when copied from existing publisher #233

Merged
merged 4 commits into from Jun 16, 2023

Conversation

achim-k
Copy link
Collaborator

@achim-k achim-k commented Jun 15, 2023

Public-Facing Changes

Fix QoS history being unknown when copied from existing publisher

Description

When the QoS profile is copied from another existing publisher, it can happen that the history policy is Unknown, leading to an error when subsequently trying to create a publisher with that QoS profile. As a fix, we explicitly set the history policy to the system default.

Fixes #200

When the QoS profile is copied from another existing publisher, it can happen that the history policy is `Unknown`, leading to an error when subsequently trying to create a publisher with that QoS profile. As a fix, we explicitly set the history policy to the system default.

Fixes #200
@achim-k achim-k requested a review from jtbandes June 15, 2023 11:53
@@ -582,7 +582,9 @@ void FoxgloveBridge::clientAdvertise(const foxglove::ClientAdvertisement& advert
});
const rclcpp::QoS qos = otherPublisherIt == otherPublishers.end()
? rclcpp::SystemDefaultsQoS()
: otherPublisherIt->qos_profile();
: rclcpp::QoS(otherPublisherIt->qos_profile())
// Override the history policy as it can be `unknown`
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be better to only override if it is unknown and leave it otherwise?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, will do. Although it seems that this is ROS distro specific. On humble this is always unknown (might be a bug), on galactic the history is always set

Copy link
Contributor

@defunctzombie defunctzombie left a comment

Choose a reason for hiding this comment

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

LGTM

I would include some shorter version of your PR description as a code comment. I found the description helpful in clarifying that it will cause a publisher error

Copy link
Member

@jtbandes jtbandes left a comment

Choose a reason for hiding this comment

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

Is there any possibility to add a test for this?

rclcpp::QoS qos = otherPublisherIt == otherPublishers.end() ? rclcpp::SystemDefaultsQoS()
: otherPublisherIt->qos_profile();
if (qos.history() == rclcpp::HistoryPolicy::Unknown) {
qos.history(rclcpp::HistoryPolicy::SystemDefault);
Copy link
Member

Choose a reason for hiding this comment

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

Comment on why this is necessary?

@achim-k
Copy link
Collaborator Author

achim-k commented Jun 16, 2023

Is there any possibility to add a test for this?

Yes, added one. Fails for distros starting from humble without the history policy fix.

@achim-k achim-k merged commit ffb6c63 into main Jun 16, 2023
7 checks passed
@achim-k achim-k deleted the achim/fg-2519-invalid-qos-history-policy branch June 16, 2023 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

create_publisher() failed setting topic QoS, at ./src/publisher.cpp:226'
3 participants