1

While I was looking for a solution, I came across a solution for ROS2 crystal on this post How to launch a node with a parameter in ROS2?.

Unfortunately, that does not seem to work under ROS2 dashing. I created a fork of the ROS2 realsense driver (https://github.com/AndreasAZiegler/ros2_intel_realsense/tree/serial_no_param/realsense_ros2_camera) and my goal is to be able to pass the serial number via a parameter. With

ros2 run realsense_ros2_camera realsense_ros2_camera  __params:=/paht/to/config/parameters.yaml

passing the parameter works fine but when I start the node with the launch python file

ros2 launch realsense_ros2_camera ros2_intel_realsense.launch.py

it ignores the parameter. The path to the parameters.yaml is correct (I print it in the launch python script).

Andreas Ziegler
  • 347
  • 2
  • 12

1 Answers1

1

In your launch file, you change the node name to: node_name='realsense_ros2_camera'

However the default name of the node and also the name you use in the config file is RealSenseCameraNode which is why it works when you're running it from the cmd-line (not passing a new name).

# RealSense parameters
---

RealSenseCameraNode_ns:
    RealSenseCameraNode:
      ros__parameters:
        serial_no: 845112070204

Change it to

# RealSense parameters
---

RealSenseCameraNode_ns:
  realsense_ros2_camera:
    ros__parameters:
      serial_no: 845112070204

And it should work (or keep the default name in the launch file as well). Minor thing: I change the yaml config to only be 2 spaces for each new row, not sure it matters.

Andreas Klintberg
  • 440
  • 1
  • 11
  • 29