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

Projects
None yet
3 participants
@dhood
Copy link
Member

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 label Jun 21, 2018

@dhood dhood self-assigned this Jun 21, 2018

@dhood dhood added in progress and removed in progress labels Jun 21, 2018

@dhood dhood merged commit 094ea81 into master Jun 21, 2018

@dhood dhood deleted the support_remapping_argparse branch Jun 21, 2018

@dhood dhood removed the in review label Jun 21, 2018

@wjwwood

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

Copy link
Member Author

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
You can’t perform that action at this time.