-
Notifications
You must be signed in to change notification settings - Fork 263
Implement functions to get publisher and subcription informations like QoS policies from topic name #454
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
Merged
ivanpauno
merged 24 commits into
ros2:master
from
aws-ros-dev:jaisontj/impl_qos_in_topic_info
Feb 14, 2020
Merged
Implement functions to get publisher and subcription informations like QoS policies from topic name #454
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
d724c74
- Added and implemented get_publishers_info_by_topic and get_subscrip…
jaisontj f3c9d33
Informative error message when the underlying rmw_implementation has not
jaisontj 585b41a
Fixed code formatting issues.
jaisontj 95bee0b
- Better assertion for qos equality
jaisontj 292e38e
Skipping get_info_by_topic test for implementations other than rmw_fa…
jaisontj 40d054c
Rearranged assert_qos_equal
jaisontj ae24ed4
- Refactor to call the correct rmw_topic_info_array* functions.
jaisontj 98fe926
- Minor comment modifications
jaisontj 704fb5c
- Removed unnecessary temporary variable definitions
jaisontj f985c41
address PR comments
mm318 128ef54
address more PR comments
mm318 4995c34
rename *topic_info* to *topic_endpoint_info*
mm318 e18a15f
fix formatting
mm318 214c113
fix doc strings
mm318 c768a53
replace use of PyExc_RuntimeError with RCLError
mm318 f126ec5
address more PR comments
mm318 5933310
fix bad return value comparison types
mm318 327554c
implement and use TopicEndpointInfo object
mm318 536620a
change comparison order to (literal == variable)
mm318 6a4486f
fix pep257 issue
mm318 1723927
update docstring
mm318 b34b127
add topic name remapping
mm318 1ac4677
address PR comments
mm318 96946b7
fix CI build failures
mm318 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,174 @@ | ||
| # Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| # | ||
| # 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. | ||
|
|
||
| from enum import IntEnum | ||
|
|
||
| from rclpy.qos import QoSPresetProfiles, QoSProfile | ||
|
|
||
|
|
||
| class TopicEndpointTypeEnum(IntEnum): | ||
| """ | ||
| Enum for possible types of topic endpoints. | ||
|
|
||
| This enum matches the one defined in rmw/types.h | ||
| """ | ||
|
|
||
| INVALID = 0 | ||
| PUBLISHER = 1 | ||
| SUBSCRIPTION = 2 | ||
|
|
||
|
|
||
| class TopicEndpointInfo: | ||
| """Information on a topic endpoint.""" | ||
|
|
||
| __slots__ = [ | ||
| '_node_name', | ||
| '_node_namespace', | ||
| '_topic_type', | ||
| '_endpoint_type', | ||
| '_endpoint_gid', | ||
| '_qos_profile' | ||
| ] | ||
|
|
||
| def __init__(self, **kwargs): | ||
| assert all('_' + key in self.__slots__ for key in kwargs.keys()), \ | ||
| 'Invalid arguments passed to constructor: %r' % kwargs.keys() | ||
|
|
||
| self.node_name = kwargs.get('node_name', '') | ||
| self.node_namespace = kwargs.get('node_namespace', '') | ||
| self.topic_type = kwargs.get('topic_type', '') | ||
| self.endpoint_type = kwargs.get('endpoint_type', TopicEndpointTypeEnum.INVALID) | ||
| self.endpoint_gid = kwargs.get('endpoint_gid', []) | ||
| self.qos_profile = kwargs.get('qos_profile', QoSPresetProfiles.UNKNOWN.value) | ||
|
|
||
| @property | ||
| def node_name(self): | ||
| """ | ||
| Get field 'node_name'. | ||
|
|
||
| :returns: node_name attribute | ||
| :rtype: str | ||
| """ | ||
| return self._node_name | ||
|
|
||
| @node_name.setter | ||
| def node_name(self, value): | ||
| assert isinstance(value, str) | ||
| self._node_name = value | ||
|
|
||
| @property | ||
| def node_namespace(self): | ||
| """ | ||
| Get field 'node_namespace'. | ||
|
|
||
| :returns: node_namespace attribute | ||
| :rtype: str | ||
| """ | ||
| return self._node_namespace | ||
|
|
||
| @node_namespace.setter | ||
| def node_namespace(self, value): | ||
| assert isinstance(value, str) | ||
| self._node_namespace = value | ||
|
|
||
| @property | ||
| def topic_type(self): | ||
| """ | ||
| Get field 'topic_type'. | ||
|
|
||
| :returns: topic_type attribute | ||
| :rtype: str | ||
| """ | ||
| return self._topic_type | ||
|
|
||
| @topic_type.setter | ||
| def topic_type(self, value): | ||
| assert isinstance(value, str) | ||
| self._topic_type = value | ||
|
|
||
| @property | ||
| def endpoint_type(self): | ||
| """ | ||
| Get field 'endpoint_type'. | ||
|
|
||
| :returns: endpoint_type attribute | ||
| :rtype: TopicEndpointTypeEnum | ||
| """ | ||
| return self._endpoint_type | ||
|
|
||
| @endpoint_type.setter | ||
| def endpoint_type(self, value): | ||
| if isinstance(value, TopicEndpointTypeEnum): | ||
| self._endpoint_type = value | ||
| elif isinstance(value, int): | ||
| self._endpoint_type = TopicEndpointTypeEnum(value) | ||
| else: | ||
| assert False | ||
|
|
||
| @property | ||
| def endpoint_gid(self): | ||
| """ | ||
| Get field 'endpoint_gid'. | ||
|
|
||
| :returns: endpoint_gid attribute | ||
| :rtype: list | ||
| """ | ||
| return self._endpoint_gid | ||
|
|
||
| @endpoint_gid.setter | ||
| def endpoint_gid(self, value): | ||
| assert all(isinstance(x, int) for x in value) | ||
| self._endpoint_gid = value | ||
|
|
||
| @property | ||
| def qos_profile(self): | ||
| """ | ||
| Get field 'qos_profile'. | ||
|
|
||
| :returns: qos_profile attribute | ||
| :rtype: QoSProfile | ||
| """ | ||
| return self._qos_profile | ||
|
|
||
| @qos_profile.setter | ||
| def qos_profile(self, value): | ||
| if isinstance(value, QoSProfile): | ||
| self._qos_profile = value | ||
| elif isinstance(value, dict): | ||
| self._qos_profile = QoSProfile(**value) | ||
| else: | ||
| assert False | ||
|
|
||
| def __eq__(self, other): | ||
| if not isinstance(other, TopicEndpointInfo): | ||
| return False | ||
| return all( | ||
| self.__getattribute__(slot) == other.__getattribute__(slot) | ||
| for slot in self.__slots__) | ||
|
|
||
| def __str__(self): | ||
| result = 'Node name: %s\n' % self.node_name | ||
| result += 'Node namespace: %s\n' % self.node_namespace | ||
| result += 'Topic type: %s\n' % self.topic_type | ||
| result += 'Endpoint type: %s\n' % self.endpoint_type.name | ||
| result += 'GID: %s\n' % '.'.join(format(x, '02x') for x in self.endpoint_gid) | ||
| result += 'QoS profile:\n' | ||
| result += ' Reliability: %s\n' % self.qos_profile.reliability.name | ||
| result += ' Durability: %s\n' % self.qos_profile.durability.name | ||
| result += ' Lifespan: %d nanoseconds\n' % self.qos_profile.lifespan.nanoseconds | ||
| result += ' Deadline: %d nanoseconds\n' % self.qos_profile.deadline.nanoseconds | ||
| result += ' Liveliness: %s\n' % self.qos_profile.liveliness.name | ||
| result += ' Liveliness lease duration: %d nanoseconds' % \ | ||
| self.qos_profile.liveliness_lease_duration.nanoseconds | ||
| return result |
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.
Uh oh!
There was an error while loading. Please reload this page.