-
Notifications
You must be signed in to change notification settings - Fork 329
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
[image_tools] Use ROS parameters instead of regular CLI arguments #398
Conversation
Using of ROS parameters make the code a little tidier, though a little more verbose on the command-line. IMO, it seems like a good way to demonstrate best practices as well. Signed-off-by: Jacob Perron <jacob@openrobotics.org>
How does a user get a similar help than what was provided by |
Good question, I guess there's no equivalent to Maybe this is a good example for a feature/tool that is lacking for ROS parameters. $ ros2 param list
/showimage:
depth
history
reliability
show_image
use_sim_time In addition it would be nice if we could see the types/constraints on these params (ros2/ros2cli#362). And even better (equivalent to $ ros2 run image_tools showimage --ros-args --help
Node: name_of_node
Parameters:
<list of parameters and descriptors>
Publishers:
<list of publisher types and topics>
Subscriptions:
<list of subscription types and topics>
... etc for services and actions.
Node: another_node
... etc I suppose this kind of introspection feature needs a lot more thought and discussion to make it happen. |
Not relevant in this case where the node is implemented in C++. But in the case of Python nodes using |
Display a help message and exit if the non-ros flag '-h' or '--help' is given. Signed-off-by: Jacob Perron <jacob@openrobotics.org>
I've added back an option for help ( |
Really, the 'execute' method is doing initialization. Signed-off-by: Jacob Perron <jacob@openrobotics.org>
Avoid blocking on construction by using a timer for the main loop. This resolves an issue where we are unable to query parameters from the command line. I've also moved initialization logic into it's own method, similar to showimage. Signed-off-by: Jacob Perron <jacob@openrobotics.org>
Use Node actions and parameters. Signed-off-by: Jacob Perron <jacob@openrobotics.org>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was hoping the nodes would declare their parameters and --help
would then call a generic function which get those descriptors and renders the usage.
Since the usage text was hard coded before it is certainly good enough for this PR to also hard code them.
The one inline comment doesn't need to be addressed - the same was already the case before this PR.
std::find(args.begin(), args.end(), "-h") != args.end()) | ||
{ | ||
std::stringstream ss; | ||
ss << "Usage: cam2image [-h] [--ros-args [-p param:=value] ...]" << std::endl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: each std::endl
also flushes the stream which doesn't seem necessary on each line.
It seemed easier to do something like was done before to ensure formatting looked okay. |
Using of ROS parameters make the code a little tidier, though a little more verbose on the command-line.
IMO, it seems like a good way to demonstrate best practices as well.
Example usage:
Connects to #390