Skip to content

Commit acb13d9

Browse files
authored
Enable --no-daemon flag for some cli tools (#514)
Fixes #511 Signed-off-by: Dereck Wonnacott <[email protected]>
1 parent 95bfb05 commit acb13d9

File tree

5 files changed

+26
-9
lines changed

5 files changed

+26
-9
lines changed

ros2topic/ros2topic/verb/echo.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from rclpy.qos_event import SubscriptionEventCallbacks
2424
from rclpy.qos_event import UnsupportedEventTypeError
2525
from rclpy.utilities import get_rmw_implementation_identifier
26+
from ros2cli.node.strategy import add_arguments as add_strategy_node_arguments
2627
from ros2cli.node.strategy import NodeStrategy
2728
from ros2topic.api import add_qos_arguments_to_argument_parser
2829
from 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):
136142
def 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

ros2topic/ros2topic/verb/find.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
from ros2cli.node.strategy import add_arguments as add_strategy_node_arguments
1516
from ros2cli.node.strategy import NodeStrategy
1617

1718
from ros2topic.api import get_topic_names_and_types
@@ -23,6 +24,8 @@ class FindVerb(VerbExtension):
2324
"""Output a list of available topics of a given type."""
2425

2526
def add_arguments(self, parser, cli_name):
27+
add_strategy_node_arguments(parser)
28+
2629
arg = parser.add_argument(
2730
'topic_type',
2831
help="Name of the ROS topic type to filter for (e.g. 'std_msg/msg/String')")

ros2topic/ros2topic/verb/info.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
from ros2cli.node.strategy import add_arguments as add_strategy_node_arguments
1516
from ros2cli.node.strategy import NodeStrategy
16-
1717
from ros2topic.api import get_topic_names_and_types
1818
from ros2topic.api import TopicNameCompleter
1919
from ros2topic.verb import VerbExtension
@@ -23,6 +23,7 @@ class InfoVerb(VerbExtension):
2323
"""Print information about a topic."""
2424

2525
def add_arguments(self, parser, cli_name):
26+
add_strategy_node_arguments(parser)
2627
arg = parser.add_argument(
2728
'topic_name',
2829
help="Name of the ROS topic to get info (e.g. '/chatter')")
@@ -54,15 +55,17 @@ def main(self, *, args):
5455
type_str = topic_types[0] if len(topic_types) == 1 else topic_types
5556
print('Type: %s' % type_str, end=line_end)
5657

57-
print('Publisher count: %d' % node.count_publishers(topic_name), end=line_end)
58+
print('Publisher count: %d' %
59+
node.count_publishers(topic_name), end=line_end)
5860
if args.verbose:
5961
try:
6062
for info in node.get_publishers_info_by_topic(topic_name):
6163
print(info, end=line_end)
6264
except NotImplementedError as e:
6365
return str(e)
6466

65-
print('Subscription count: %d' % node.count_subscribers(topic_name), end=line_end)
67+
print('Subscription count: %d' %
68+
node.count_subscribers(topic_name), end=line_end)
6669
if args.verbose:
6770
try:
6871
for info in node.get_subscriptions_info_by_topic(topic_name):

ros2topic/ros2topic/verb/list.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from ros2cli.node.strategy import add_arguments
15+
from ros2cli.node.strategy import add_arguments as add_strategy_node_arguments
1616
from ros2cli.node.strategy import NodeStrategy
1717
from ros2topic.api import get_topic_names_and_types
1818
from ros2topic.verb import VerbExtension
@@ -22,7 +22,8 @@ class ListVerb(VerbExtension):
2222
"""Output a list of available topics."""
2323

2424
def add_arguments(self, parser, cli_name):
25-
add_arguments(parser)
25+
add_strategy_node_arguments(parser)
26+
2627
parser.add_argument(
2728
'-t', '--show-types', action='store_true',
2829
help='Additionally show the topic type')

ros2topic/ros2topic/verb/type.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
from ros2cli.node.strategy import add_arguments as add_strategy_node_arguments
1516
from ros2cli.node.strategy import NodeStrategy
1617

1718
from ros2topic.api import get_topic_names_and_types
@@ -23,6 +24,8 @@ class TypeVerb(VerbExtension):
2324
"""Print a topic's type."""
2425

2526
def add_arguments(self, parser, cli_name):
27+
add_strategy_node_arguments(parser)
28+
2629
arg = parser.add_argument(
2730
'topic_name',
2831
help="Name of the ROS topic to get type (e.g. '/chatter')")

0 commit comments

Comments
 (0)