question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Run arguments do not get passed to node executable

See original GitHub issue

When attempting to pass command line arguments to a node using the ros2 run [pkg] [exec] syntax, the arguments get processed by the ros2 executable rather than the node executable being launched.

Example:

$ ros2 run ros1_bridge dynamic_bridge --help
usage: ros2 run [-h] package_name executable_name [argv [argv ...]]

Run a package specific executable

positional arguments:
  package_name     Name of the ROS package
  executable_name  Name of the executable
  argv             Pass arbitrary arguments to the executable (use '--' before
                   these arguments to ensure they are not handle by this
                   command)

optional arguments:
  -h, --help       show this help message and exit

Expected output:

$ ./install/lib/ros1_bridge/dynamic_bridge --help
Usage:
 -h, --help: This message.
 --show-introspection: Print output of introspection of both sides of the bridge.
 --print-pairs: Print a list of the supported ROS 2 <=> ROS 1 conversion pairs.
 --bridge-all-topics: Bridge all topics in both directions, whether or not there is a matching subscriber.
 --bridge-all-1to2-topics: Bridge all ROS 1 topics to ROS 2, whether or not there is a matching subscriber.
 --bridge-all-2to1-topics: Bridge all ROS 2 topics to ROS 1, whether or not there is a matching subscriber.

Although I’m sure you get the picture, here’s another example:

$ ros2 run ros1_bridge dynamic_bridge --bridge-all-topics
usage: ros2 [-h] Call `ros2 <command> -h` for more detailed usage. ...
ros2: error: unrecognized arguments: --bridge-all-topics

Add one passing just a flag:

$ ros2 run ros1_bridge dynamic_bridge -f
usage: ros2 [-h] Call `ros2 <command> -h` for more detailed usage. ...
ros2: error: unrecognized arguments: -f

Arguments that are not prefixed with one or more dashes do allow the node to get executed (although I don’t have evidence at the moment that they successfully get passed to the node).

E.g., (I don’t have a master running, but it runs the bridge)

$ ros2 run ros1_bridge dynamic_bridge this_is_an_argument another arg3
[ERROR] [1499788917.336544285] [/ros_bridge]: [registerPublisher] Failed to contact master at [localhost:11311].  Retrying...

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
dhoodcommented, Jul 11, 2017

if you’re the third person to run into this or miss the help, then we need to do something different so it’s more obvious or so that it works as people expect it should, avoiding the surprise.

+1. I added a quick mention to the wiki for now (it’s linked to from release notes). https://github.com/ros2/ros2/wiki/Introspection-with-command-line-tools

1reaction
wjwwoodcommented, Jul 11, 2017

Apologies for not doing a good enough job searching through the issues…or reading the help…

No worries. As I pointed out, if you’re the third person to run into this or miss the help, then we need to do something different so it’s more obvious or so that it works as people expect it should, avoiding the surprise.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pass arguments to “node” executable when running “yarn run”
For older versions of Yarn (or even NPM), there are a couple of options. First, you can use the NODE_OPTIONS environment variable to...
Read more >
How To Handle Command-line Arguments in Node.js Scripts
In this article, you will learn how to use arguments in your Node.js scripts and then you will recreate the script with the...
Read more >
How do I pass command line arguments to a Node.js program?
We can pass any number of command-line arguments while invoking a Node.js application by typing them in after the name of the file,...
Read more >
Handling Command Line Argument in Node.js - KnowledgeHut
If you are new to NPM and do not know much about it, this article will help you handle node command-line arguments. Here...
Read more >
How To Pass Command-Line Arguments in Node.js (2022)
The second element will be the path to the JavaScript file being executed. The remaining elements will be any additional command-line arguments. Let's...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found