Skip to content

Support passing parameters as command line arguments  #460

@hidmic

Description

@hidmic

Feature request

Feature description

Currently, the only way to pass node parameters over the command line is via a YAML file. To improve usability, we'd like to be be able to pass key value pairs directly, as ROS1 rosrun does. Grounds for this have to be established here and then leveraged in downstream client libraries (e.g. rclpy and rclcpp).

As a proposal for a syntax and since ROS1 syntax e.g. _name:=value would be parsed as a ROS2 remapping rule, we could make use of a dotted '.' equivalent .name:=value (credits to @sloretz for it). For a usage example, consider:

ros2 run demo_nodes_cpp talker \
  .bool_param:=true \
  .int_param:=1 \
  .float_param:=1.2 \
  .str_param:='...' \
  .bool_array_param:="[true, false, true]" \
  .int_array_param:="[1, 2, 3]" \
  .float_array_param:="[1.0, 2.0, 3.0]" \
  .str_array_param:="['a', 'b', 'c']" \
  .nested.int_param:=0 \
  .nested:="{str_param: '...'}"

which would roughly equate to the following YAML file:

bool_param: true
int_param: 1
float_param: 1.2
str_param: '...'
bool_array_param: [true, false, true]
int_array_param: [1, 2, 3]
float_array_param: [1.0, 2.0, 3.0]
str_array_param: ['a', 'b', 'c']
nested:
  int_param: 0
  str_param: '...'

Implementation considerations

As a likely prerequisite, #246 has to be implemented first.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions