Most ros2cli commands use --timeout to specify a maximum wait time in seconds, but ros2 topic pub uses --max-wait-time-secs and ros2 param list only accepts --service-timeout.
Modify the following files to accept --timeout as an alias:
ros2topic/ros2topic/verb/pub.py
ros2param/ros2param/verb/list.py
Example: How to add the alias
Keep the existing option name first (so the args attribute name stays the same) and add '--timeout':
# Before (in ros2topic/ros2topic/verb/pub.py):
parser.add_argument(
'--max-wait-time-secs',
dest='max_wait_time_secs', type=positive_float, default=None,
help=...)
# After:
parser.add_argument(
'--max-wait-time-secs', '--timeout',
dest='max_wait_time_secs', type=positive_float, default=None,
help=...)
Example: How to add a test
Add a test in ros2topic/test/ (and ros2param/test/test_verb_list.py) to check that --timeout sets the expected attribute:
import argparse
from ros2topic.verb.pub import PubVerb
def test_pub_timeout_alias():
parser = argparse.ArgumentParser()
verb = PubVerb()
verb.add_arguments(parser, 'ros2 topic pub')
args = parser.parse_args(['/chatter', 'std_msgs/msg/String', '--timeout', '2.5'])
assert args.max_wait_time_secs == 2.5
Most
ros2clicommands use--timeoutto specify a maximum wait time in seconds, butros2 topic pubuses--max-wait-time-secsandros2 param listonly accepts--service-timeout.Modify the following files to accept
--timeoutas an alias:ros2topic/ros2topic/verb/pub.pyros2param/ros2param/verb/list.pyExample: How to add the alias
Keep the existing option name first (so the
argsattribute name stays the same) and add'--timeout':Example: How to add a test
Add a test in
ros2topic/test/(andros2param/test/test_verb_list.py) to check that--timeoutsets the expected attribute: