-
Notifications
You must be signed in to change notification settings - Fork 22
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 function for checking QoS profile compatibility #45
Merged
Merged
Changes from 14 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
17df0fb
Add function for checking QoS profile compatibility
jacobperron f549bae
Fix spelling
jacobperron cc81b3f
Fix header order
jacobperron 132b3e1
Refactor signature of _write_to_buffer
jacobperron 1a156da
Set error message instead of setting reason
jacobperron e7d4b0a
Error is null reason and non-zero reason_size
jacobperron 9c43a6e
Avoid heap allocations
jacobperron 70dc190
Do not set output parameter if an error occurs
jacobperron ff1ece3
Add test for reason buffer too small
jacobperron 55e56f3
Update docs
jacobperron 26f2e63
Improve docs
jacobperron 530c42f
Zero-initialize reason string
jacobperron 6c789b4
Warn on unknown values instead of error
jacobperron 6a67320
Fixes
jacobperron a8862ee
Guard against zero reason_size
jacobperron File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright 2021 Open Source Robotics Foundation, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#ifndef RMW_DDS_COMMON__QOS_HPP_ | ||
#define RMW_DDS_COMMON__QOS_HPP_ | ||
|
||
#include "rmw/qos_profiles.h" | ||
#include "rmw/types.h" | ||
|
||
#include "rmw_dds_common/visibility_control.h" | ||
|
||
namespace rmw_dds_common | ||
{ | ||
|
||
/// Check if two QoS profiles are compatible | ||
/** | ||
* Two QoS profiles are compatible if a publisher and subcription | ||
* using the QoS policies can communicate with each other. | ||
* | ||
* This implements the rmw API \ref rmw_qos_profile_check_compatible(). | ||
* See \ref rmw_qos_profile_check_compatible() for more information. | ||
* | ||
* \param[in] publisher_profile: The QoS profile used for a publisher. | ||
* \param[in] subscription_profile: The QoS profile used for a subscription. | ||
* \param[out] compatibility: `RMW_QOS_COMPATIBILITY_OK` if the QoS profiles are compatible, or | ||
* `RMW_QOS_COMPATIBILITY_WARNING` if the QoS profiles might be compatible, or | ||
* `RMW_QOS_COMPATIBILITY_ERROR` if the QoS profiles are not compatible. | ||
jacobperron marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* \param[out] reason: A detailed reason for a QoS incompatibility or potential incompatibility. | ||
* Must be pre-allocated by the caller. | ||
* This parameter is optional and may be set to `nullptr` if the reason information is not | ||
* desired. | ||
* \param[in] reason_size: Size of the string buffer `reason`, if one is provided. | ||
* If `reason` is `nullptr`, then this parameter must be zero. | ||
* \return `RMW_RET_OK` if the check was successful, or | ||
* \return `RMW_RET_INVALID_ARGUMENT` if `compatiblity` is `nullptr`, or | ||
* \return `RMW_RET_INVALID_ARGUMENT` if `reason` is `nullptr` and `reason_size` is not zero, or | ||
* \return `RMW_RET_ERROR` if there is an unexpected error. | ||
*/ | ||
RMW_DDS_COMMON_PUBLIC | ||
rmw_ret_t | ||
qos_profile_check_compatible( | ||
const rmw_qos_profile_t publisher_qos, | ||
const rmw_qos_profile_t subscription_qos, | ||
rmw_qos_compatibility_type_t * compatibility, | ||
char * reason, | ||
size_t reason_size); | ||
|
||
} // namespace rmw_dds_common | ||
|
||
#endif // RMW_DDS_COMMON__QOS_HPP_ |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for my edification: I've always wondered about the inconsistent terminology, IMO: "publisher" and subscription" versus, "publisher" and "subscriber" or "publication" and "subscription." Any quick background info on that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH, I can't recall why that terminology. I'm just following suit with the terminology used throughout the rest of the ROS 2 stack, though I think we're also inconsistent about what terminology we're using 🙃 The tutorials seem to use "subscriber" instead of "subscription".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wjwwood Probably has some insight.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A publisher publishes, a subscription is a receipt of a subscription, it isn't a subscriber. So subscriber is the wrong term. A node is kind of a subscriber as it is the thing that subscribes. A publication could be a thing, but because our object publishes, it is a publisher.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wjwwood Interesting. I guess I just think of it more like this (probably attracted to the symmetry/uniformity):
Anyways, thanks for the info. It helps to fill in some of the blanks.