getParam a nested std::map
I am writing a node that will read a YAML file (loaded from roslaunch) with the following structure:
home:
1:
"x": 0.0
"y": 0.0
"z": 0.0
"qx": 0.0
"qy": 0.0
"qz": 0.0
"qw": 0.0
2:
"x": 0.0
"y": 0.0
"z": 0.0
"qx": 0.0
"qy": 0.0
"qz": 0.0
"qw": 0.0
This is the relevant code on the node side:
class RouteParserNode
{
public:
RouteParserNode() :
nh_private_("~")
{
nh_private_.getParam("home", route_home);
};
~RouteParserNode();
private:
std::map<int, std::map<std::string, double>> route_home;
ros::NodeHandle nh_private_;
};
However, the above node cannot be compiled and gives the following error:
error: no matching function for call to ‘ros::NodeHandle::getParam(const char
[5], std::map<int, std::map<std::basic_string<char>, double> >&)’
nh_private_.getParam("home", route_home);
which I assume is because getParam does not work for nested std::maps.
I am currently on ROS Indigo.
Is there a workaround for this, or another way for me to parse the file? My ultimate goal is to supply a list of goals (geometry_msgs/PoseStamped, but only primitive types were allowed for the std::map method hence the above yaml structure).
#q197304 is very similar but the answer doesn't provide a good code example.