1212# See the License for the specific language governing permissions and
1313# limitations under the License.
1414
15- from rclpy .qos import QoSDurabilityPolicy
16- from rclpy .qos import QoSLivelinessPolicy
17- from rclpy .qos import QoSReliabilityPolicy
18-
1915from ros2cli .node .direct import DirectNode
2016from ros2topic .api import get_topic_names_and_types
2117from ros2topic .api import TopicNameCompleter
2218from ros2topic .verb import VerbExtension
2319
2420
25- def print_topic_endpoint_info (topic_name , get_topic_endpoint_info_func ):
26- for info in get_topic_endpoint_info_func (topic_name ):
27- print ('Node name: %s' % info ['node_name' ])
28- print ('Node namespace: %s' % info ['node_namespace' ])
29- print ('Topic type: %s' % info ['topic_type' ])
30- print ('GID: %s' % '.' .join (format (x , '02x' ) for x in info ['gid' ]))
31- print ('QoS profile:' )
32- qos_profile = info ['qos_profile' ]
33- print (' Reliability: %s' % QoSReliabilityPolicy (qos_profile ['reliability' ]).name )
34- print (' Durability: %s' % QoSDurabilityPolicy (qos_profile ['durability' ]).name )
35- print (' Lifespan: %d nanoseconds' % qos_profile ['lifespan' ].nanoseconds )
36- print (' Deadline: %d nanoseconds' % qos_profile ['deadline' ].nanoseconds )
37- print (' Liveliness: %s' % QoSLivelinessPolicy (qos_profile ['liveliness' ]).name )
38- print (' Liveliness lease duration: %d nanoseconds\n ' %
39- qos_profile ['liveliness_lease_duration' ].nanoseconds )
40-
4121class InfoVerb (VerbExtension ):
4222 """Print information about a topic."""
4323
@@ -46,7 +26,9 @@ def add_arguments(self, parser, cli_name):
4626 'topic_name' ,
4727 help = "Name of the ROS topic to get info (e.g. '/chatter')" )
4828 parser .add_argument (
49- '--verbose' , '-v' , action = 'store_true' ,
29+ '--verbose' ,
30+ '-v' ,
31+ action = 'store_true' ,
5032 help = 'Prints detailed information like the node name, node namespace, topic type, '
5133 'GUID and QoS Profile of the publishers and subscribers to this topic' )
5234 arg .completer = TopicNameCompleter (
@@ -74,13 +56,15 @@ def main(self, *, args):
7456 print ('Publisher count: %d' % node .count_publishers (topic_name ), end = lineend )
7557 if args .verbose :
7658 try :
77- print_topic_endpoint_info (topic_name , node .get_publishers_info_by_topic )
59+ for info in node .get_publishers_info_by_topic (topic_name ):
60+ print (info , end = lineend )
7861 except NotImplementedError as e :
7962 return str (e )
8063
8164 print ('Subscription count: %d' % node .count_subscribers (topic_name ))
8265 if args .verbose :
8366 try :
84- print_topic_endpoint_info (topic_name , node .get_subscriptions_info_by_topic )
67+ for info in node .get_subscriptions_info_by_topic (topic_name ):
68+ print (info , end = lineend )
8569 except NotImplementedError as e :
8670 return str (e )
0 commit comments