ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
2

How to pass arguments (incl. rosparams, remapppings and setting node name) to ros2 components?

asked 2019-01-02 15:42:11 -0600

koenlek gravatar image

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 equivalently ros2 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 that composition::Listener implements rosparam topic_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?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-02-16 15:27:59 -0600

divserge gravatar image

Perhaps, you could try using the following functions from rcl/remap.h: rcl_remap_node_name rcl_remap_topic_name

edit flag offensive delete link more

Question Tools

3 followers

Stats

Asked: 2019-01-02 15:42:11 -0600

Seen: 671 times

Last updated: Jan 02 '19