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 function for checking QoS profile compatibility #45

Merged
merged 15 commits into from
Feb 28, 2021
Merged
6 changes: 6 additions & 0 deletions rmw_dds_common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ rosidl_generate_interfaces(
add_library(${PROJECT_NAME}_library SHARED
src/gid_utils.cpp
src/graph_cache.cpp
src/qos.cpp
src/time_utils.cpp)

set_target_properties(${PROJECT_NAME}_library
Expand Down Expand Up @@ -92,6 +93,11 @@ if(BUILD_TESTING)
target_link_libraries(test_gid_utils ${PROJECT_NAME}_library)
endif()

ament_add_gmock(test_qos test/test_qos.cpp)
if(TARGET test_qos)
target_link_libraries(test_qos ${PROJECT_NAME}_library)
endif()

ament_add_gmock(test_time_utils test/test_time_utils.cpp)
if(TARGET test_time_utils)
target_link_libraries(test_time_utils ${PROJECT_NAME}_library)
Expand Down
1 change: 1 addition & 0 deletions rmw_dds_common/docs/FEATURES.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ This package includes:
- A generic [`Context`](rmw_dds_common/include/rmw_dds_common/context.hpp) type to withhold most state needed to implement [ROS nodes discovery](https://github.com/ros2/design/pull/250)
- [Comparison utilities and some C++ operator overloads](rmw_dds_common/include/rmw_dds_common/gid_utils.hpp) for `rmw_gid_t` instances
- [Conversion utilities](rmw_dds_common/include/rmw_dds_common/gid_utils.hpp) between `rmw_dds_common/msg/Gid` messages and `rmw_gid_t` instances
- A function for checking the compatibility of two QoS profiles, [`qos_profile_check_compatible`](rmw_dds_common/include/rmw_dds_common/qos.hpp)
61 changes: 61 additions & 0 deletions rmw_dds_common/include/rmw_dds_common/qos.hpp
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

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?

Copy link
Member Author

@jacobperron jacobperron Feb 19, 2021

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".

Copy link
Member Author

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.

Copy link
Member

@wjwwood wjwwood Feb 23, 2021

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.

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.

* 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_
Loading