[ROS2] How to get multiple nodes under same namespace in yaml config file?

asked 2022-01-13 07:42:25 -0500

bvaningen gravatar image

updated 2022-01-13 07:56:59 -0500

Hello,

I have a config yaml that looks as follows:

sensor_set_1:
  depth_camera:
    ros__parameters:
      usb_port_id: '2-1.4.1'
sensor_set_1:
  rgb_camera:
    ros__parameters:
      usb_port_id: '2-1.4.2'

When launching both nodes depth_camera and rgb_camera in the namespace sensor_set_1 when supply the above yaml file, the usb_port_id gets load correctly for both nodes. The problem is that when I run the pre-commit hook containing a yaml check, i get the following error:

- hook id: check-yaml
- exit code: 1

while constructing a mapping
  in "src/bot_bringup/config/sensor_sets.yaml", line 1, column 1
found duplicate key "sensor_set_1" with value "{}" (original value: "{}")
  in "src/bot_bringup/config/sensor_sets.yaml", line 5, column 1

However when I use the following format:

sensor_set_1:
  depth_camera:
    ros__parameters:
      usb_port_id: '2-1.4.1'
  rgb_camera:
    ros__parameters:
      usb_port_id: '2-1.4.2'

The parameter for rgb_camera no longer gets loaded! I think it looks cleaner to use the above yaml instead of the first one since the indentation indicates that depth and rgb camera are in the sensor_set_1 namespace.

How do I format the yaml properly in order to get this to work? Or is my intended approach not usable for ROS2?

Thanks in advance!

edit retag flag offensive close merge delete

Comments

would fully qualifying the namespace (sensor_set_1 -> /sensor_set_1) in the yaml help the latter param file? I remember reading something about ROS2's name matching about strange behavior when the names aren't fully qualified, but I'm not sure if that would apply here.

shonigmann gravatar image shonigmann  ( 2022-01-13 12:52:08 -0500 )edit

Also it may help if you edit your question to include an excerpt from your launch file to show how you are launching the nodes

shonigmann gravatar image shonigmann  ( 2022-01-13 12:54:46 -0500 )edit