MCPcopy Create free account
hub / github.com/ANYbotics/grid_map / readParameters

Method readParameters

grid_map_visualization/src/GridMapVisualization.cpp:37–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35}
36
37bool GridMapVisualization::readParameters()
38{
39 nodeHandle_.param("grid_map_topic", mapTopic_, string("/grid_map"));
40
41 double activityCheckRate;
42 nodeHandle_.param("activity_check_rate", activityCheckRate, 2.0);
43 activityCheckDuration_.fromSec(1.0 / activityCheckRate);
44 ROS_ASSERT(!activityCheckDuration_.isZero());
45
46 // Configure the visualizations from a configuration stored on the parameter server.
47 XmlRpc::XmlRpcValue config;
48 if (!nodeHandle_.getParam(visualizationsParameter_, config)) {
49 ROS_WARN(
50 "Could not load the visualizations configuration from parameter %s,are you sure it"
51 "was pushed to the parameter server? Assuming that you meant to leave it empty.",
52 visualizationsParameter_.c_str());
53 return false;
54 }
55
56 // Verify proper naming and structure,
57 if (config.getType() != XmlRpc::XmlRpcValue::TypeArray) {
58 ROS_ERROR("%s: The visualization specification must be a list, but it is of XmlRpcType %d",
59 visualizationsParameter_.c_str(), config.getType());
60 ROS_ERROR("The XML passed in is formatted as follows:\n %s", config.toXml().c_str());
61 return false;
62 }
63
64 // Iterate over all visualizations (may be just one),
65 for (unsigned int i = 0; i < config.size(); ++i) {
66 if (config[i].getType() != XmlRpc::XmlRpcValue::TypeStruct) {
67 ROS_ERROR("%s: Visualizations must be specified as maps, but they are XmlRpcType:%d",
68 visualizationsParameter_.c_str(), config[i].getType());
69 return false;
70 } else if (!config[i].hasMember("type")) {
71 ROS_ERROR("%s: Could not add a visualization because no type was given",
72 visualizationsParameter_.c_str());
73 return false;
74 } else if (!config[i].hasMember("name")) {
75 ROS_ERROR("%s: Could not add a visualization because no name was given",
76 visualizationsParameter_.c_str());
77 return false;
78 } else {
79 //Check for name collisions within the list itself.
80 for (int j = i + 1; j < config.size(); ++j) {
81 if (config[j].getType() != XmlRpc::XmlRpcValue::TypeStruct) {
82 ROS_ERROR("%s: Visualizations must be specified as maps, but they are XmlRpcType:%d",
83 visualizationsParameter_.c_str(), config[j].getType());
84 return false;
85 }
86
87 if (!config[j].hasMember("name")
88 || config[i]["name"].getType() != XmlRpc::XmlRpcValue::TypeString
89 || config[j]["name"].getType() != XmlRpc::XmlRpcValue::TypeString) {
90 ROS_ERROR("%s: Visualizations names must be strings, but they are XmlRpcTypes:%d and %d",
91 visualizationsParameter_.c_str(), config[i].getType(), config[j].getType());
92 return false;
93 }
94

Callers

nothing calls this directly

Calls 3

getParamMethod · 0.80
isValidTypeMethod · 0.80
getInstanceMethod · 0.80

Tested by

no test coverage detected