Passing an array of vectors via nodehandle
I have a requirement to pass an array of vectors from a config file (linked to the rosnode) via nodehandle
The structure of my data in the config file is:
Points:
- [0.0, 0.0, 0.0]
- [0.0, 1.0, 0.0]
- [0.0, 1.0, 1.0]
- [0.0, 0.0, 1.0]
Inside my node, I am trying to get this data as follows:
std::vector<std::vector<double>> Points;
nodehandle.getParam("Points", Points);
However, I get the following error:
My_node.cpp:284: error: no matching function for call to 'ros::NodeHandle::getParam(const char [14], std::vector<std::vector<double> >&)'
nh.getParam("Point", Point);
When I checked the NodHandle docs, there is no similar options available to receive an array of vectors. Are there any workarounds, rather than receiving each vector in the array separately by calling nodehandle.getParam() for each vectors? ^
Other ROS packages that store or communicate a matrix (with known size) often use one vector to store all the values. For example the 6x6 matrix in PoseWithCovariance use a
float[36]
datatype to store the values. Is this an option for you?The example config files from robot_localization also have flat vectors/arrays. In the file they format the values to make them more readable.
Thanks. Unless I get some way to explicitly group the elements inside the vector, this will be my last resort. I did not go by this method initially as it is just a large array of elements rather than a group of elements.