ROS2 How to get an array from get_parameter? [closed]
Hello, I would like to know how to get an array from a YAML file in ROS2.
I currently have the following YAML file:
node:
ros__parameters:
ros_st: "hello"
ros_i: 2
ros_vec: [1,2]
I can declare and get parameters from YAML for 'ros_st' and 'ros_i' easily by:
this->declare_parameter("ros_st", "Hello");
this->declare_parameter("ros_i", 0);
this->get_parameter("ros_st", _st);
this->get_parameter("ros_i", _n);
But, I have no idea how to declare 'ros_vec' and get the parameters. None of these commands work:
this->declare_parameter("ros_vec", {1,2});
this->declare_parameter("ros_vec", [1,2]);
I tried to declare empty and then get values, but I also get errors:
this->declare_parameter("ros_vec");
this->get_parameter("ros_vec", x);
this->get_parameters("ros_vec", x);