How to pass arguments (incl. rosparams, remapppings and setting node name) to ros2 components?
In response to this questions I had a few follow up questions.
I noticed that I couldn't remap topic names when trying the ROS2 composition tutorial. I wanted to remap the topic name of composition::Listener from chatter to chatter2, which seems impossible. This seems like a huge loss of flexibility to me (compared to ROS1). ROS provides setting namespaces and remappings at runtime to avoid recompiling of software, right?
As @wjwwood suggested here ros2 param solution could work, but I have some doubts:
- How would I be able to change the node name of the component (to avoid naming conflicts)? Seems impossible through ros2 params.
- Usually, you want to set a param before or when the node launches. ROS1 allows you to do that through yaml files or arguments at runtime, either from command line (rosrun) or using roslaunch xmls. As far as I know, this would still be impossible for running components through
api_composition_cli
(or equivalentlyros2 service call /load_node composition/LoadNode
). Would you suggest to manually set the params before running the component? E.g.ros2 param set /listener topic_name chatter2; ros2 run composition api_composition_cli composition composition::Listener
? Of course that is assuming thatcomposition::Listener
implements rosparamtopic_name
, which it doesn't currently...
I also noticed that setting argv is possible when using the manual_composition
example, e.g.:
ros2 run composition manual_composition talker:__node:=my_talker my_talker:chatter:=chatter2 listener:chatter:=chatter2
So wouldn't it make sense to expose a similar functionality to the api_composition_cli
node and/or composition/LoadNode
service?