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

how to set user-defined argument in launchfile ?

asked 2023-06-29 09:55:25 -0500

SébastienL gravatar image

ros2 run let the user specify its own argument, i'd like to know if it is possible to use a user-defined argument in launch file ?

ros2 run my_pkg my_node --my_param=my_val --ros-args -p node_param:=value


- node:
    pkg: "my_pkg"
    exec: "my_node"
      - name: "node_param"
        value: "value"

alternatively, I cannot define a node parameter in my node (python). I used rclpy.parameter.Parameter (before rclpy.init), it makes command line run without error, but not value is set in the variable.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2023-06-29 11:06:21 -0500

sampreets3 gravatar image

You can have dedicated parameters stored in a yaml file, and specify in the launch instructions that you want to use the particular parameters file. See here for more information:

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2023-06-29 09:55:25 -0500

Seen: 110 times

Last updated: Jun 29 '23