2323from rclpy .qos_event import SubscriptionEventCallbacks
2424from rclpy .qos_event import UnsupportedEventTypeError
2525from rclpy .utilities import get_rmw_implementation_identifier
26+ from ros2cli .node .strategy import add_arguments as add_strategy_node_arguments
2627from ros2cli .node .strategy import NodeStrategy
2728from ros2topic .api import add_qos_arguments_to_argument_parser
2829from ros2topic .api import get_msg_class
@@ -42,6 +43,8 @@ class EchoVerb(VerbExtension):
4243 """Output messages from a topic."""
4344
4445 def add_arguments (self , parser , cli_name ):
46+ add_strategy_node_arguments (parser )
47+
4548 arg = parser .add_argument (
4649 'topic_name' ,
4750 help = "Name of the ROS topic to listen to (e.g. '/chatter')" )
@@ -88,12 +91,14 @@ def main(args):
8891 depth = args .qos_depth , history = args .qos_history )
8992 with NodeStrategy (args ) as node :
9093 if args .message_type is None :
91- message_type = get_msg_class (node , args .topic_name , include_hidden_topics = True )
94+ message_type = get_msg_class (
95+ node , args .topic_name , include_hidden_topics = True )
9296 else :
9397 message_type = get_message (args .message_type )
9498
9599 if message_type is None :
96- raise RuntimeError ('Could not determine the type for the passed topic' )
100+ raise RuntimeError (
101+ 'Could not determine the type for the passed topic' )
97102
98103 subscriber (
99104 node , args .topic_name , message_type , callback , qos_profile , args .lost_messages )
@@ -110,7 +115,8 @@ def subscriber(
110115 """Initialize a node with a single subscription and spin."""
111116 event_callbacks = None
112117 if report_lost_messages :
113- event_callbacks = SubscriptionEventCallbacks (message_lost = message_lost_event_callback )
118+ event_callbacks = SubscriptionEventCallbacks (
119+ message_lost = message_lost_event_callback )
114120 try :
115121 node .create_subscription (
116122 message_type , topic_name , callback , qos_profile , event_callbacks = event_callbacks )
@@ -136,7 +142,8 @@ def cb(msg):
136142def subscriber_cb_csv (truncate_length , noarr , nostr ):
137143 def cb (msg ):
138144 nonlocal truncate_length , noarr , nostr
139- print (message_to_csv (msg , truncate_length = truncate_length , no_arr = noarr , no_str = nostr ))
145+ print (message_to_csv (msg , truncate_length = truncate_length ,
146+ no_arr = noarr , no_str = nostr ))
140147 return cb
141148
142149
0 commit comments