Skip to content
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

Support remapping arguments to python nodes using argparse #252

Merged
merged 1 commit into from
Jun 21, 2018

Conversation

dhood
Copy link
Member

@dhood dhood commented Jun 21, 2018

Without:

dhood@osrf-esteve:~/ros2_bouncy [ros2_bouncy]$ ros2 run demo_nodes_py listener_qos __ns:=/my_nsusage: listener_qos [-h] [--reliable] [-n NUMBER_OF_CYCLES]
listener_qos: error: unrecognized arguments: __ns:=/my_ns

With:

dhood@osrf-esteve:~/ros2_bouncy [ros2_bouncy]$ ros2 run demo_nodes_py talker_qos __ns:=/my_ns
[INFO] [my_ns.talker_qos]: Best effort talker
[INFO] [my_ns.talker_qos]: Publishing: "Hello World: 0"
dhood@osrf-esteve:~/ros2_bouncy [ros2_bouncy]$ $ ros2 rudemo_nodes_py listener_qos __ns:=/my_ns
[INFO] [my_ns.listener_qos]: Best effort listener
dhood@osrf-esteve:~/ros2_bouncy [ros2_bouncy]$ $ ros2 rulifecycle lifecycle_service_client_py.py get_state lc_talker __node:=my_client
[WARN] [my_client]: Unable to call service lc_talker/get_state

@dhood dhood added the in review Waiting for review (Kanban column) label Jun 21, 2018
@dhood dhood self-assigned this Jun 21, 2018
@dhood dhood added in progress Actively being worked on (Kanban column) and removed in progress Actively being worked on (Kanban column) labels Jun 21, 2018
@dhood dhood merged commit 094ea81 into master Jun 21, 2018
@dhood dhood deleted the support_remapping_argparse branch June 21, 2018 22:34
@dhood dhood removed the in review Waiting for review (Kanban column) label Jun 21, 2018
@wjwwood
Copy link
Member

wjwwood commented Jun 21, 2018

Is this preferable to https://docs.python.org/3.6/library/argparse.html#argparse.ArgumentParser.parse_known_args?

Also, there really should be an rclpy function to remove ros arguments from sys.argv before doing anything (including rclpy.init), so that you could remove them before giving the rest to argparse.

@dhood
Copy link
Member Author

dhood commented Jun 21, 2018

Thanks for mentioning the rclpy function that should exist one day, I forgot to mention this was meant to workaround that.

An advantage of REMAINDER over parse_known_args is that we can then pass just those extra arguments into rclpy (not that passing all of them is currently an issue). however, for the talker/listener_qos, I didn't actually pass it through, so the code is currently in a strange, mixed state. I'll followup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants