Skip to content

Can't set initial parameters when allowing undeclared #730

@chapulina

Description

@chapulina

Bug report

Required Info:

  • Operating System:
    • Ubunto Bionic
  • Installation type:
    • dashing sources
  • Version or commit hash:
    • master

Steps to reproduce issue

Setting to accept undeclared parameters and passing initial parameters:

  std::vector<rclcpp::Parameter> initial_parameters =
      {rclcpp::Parameter("my_string", std::string("str"))};
  rclcpp::NodeOptions node_options;
  node_options.allow_undeclared_parameters(true);
  node_options.initial_parameters(initial_parameters);
  auto node = std::make_shared<Node>("name", "ns", node_options);
  node->get_parameter(param);  // throws

Throws this:

12: terminate called after throwing an instance of 'rclcpp::ParameterTypeException'            
12:   what():  expected [string] got [not set]  

On the other hand, setting the parameters after construction is happy:

  rclcpp::NodeOptions node_options;
  node_options.allow_undeclared_parameters(true);
  auto node = std::make_shared<Node>("name", "ns", node_options);
  node->set_parameters(initial_parameters);
  node->get_parameter(param); // happy

Expected behavior

No throw on both cases

Actual behavior

Throw on first case

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions