42 Aggregator::Aggregator() :
44 analyzer_group_(NULL),
45 other_analyzer_(NULL),
55 bool other_as_errors =
false;
56 nh.
param(
"other_as_errors", other_as_errors,
false);
62 ROS_ERROR(
"Analyzer group for diagnostic aggregator failed to initialize!");
76 if (diag_msg->header.stamp.toSec() != 0)
79 string stamp_warn =
"No timestamp set for diagnostic message. Message names: ";
80 vector<diagnostic_msgs::DiagnosticStatus>::const_iterator it;
81 for (it = diag_msg->status.begin(); it != diag_msg->status.end(); ++it)
83 if (it != diag_msg->status.begin())
85 stamp_warn += it->name;
99 bool analyzed =
false;
102 boost::mutex::scoped_lock lock(
mutex_);
103 for (
unsigned int j = 0; j < diag_msg->status.size(); ++j)
127 boost::mutex::scoped_lock lock(
mutex_);
128 ROS_WARN(
"Bond for namespace %s was broken", bond_id.c_str());
129 std::vector<boost::shared_ptr<bond::Bond> >::iterator elem;
131 if (elem ==
bonds_.end()){
132 ROS_WARN(
"Broken bond tried to erase a bond which didn't exist.");
138 ROS_WARN(
"Broken bond tried to remove an analyzer which didn't exist.");
146 boost::mutex::scoped_lock lock(
mutex_);
152 diagnostic_msgs::AddDiagnostics::Response &res)
154 ROS_DEBUG(
"Got load request for namespace %s", req.load_namespace.c_str());
156 if (req.load_namespace[0] !=
'/')
158 res.message =
"Requested load from non-global namespace. Private and relative namespaces are not supported.";
166 boost::mutex::scoped_lock lock(
mutex_);
170 res.message =
"Requested load from namespace " + req.load_namespace +
" which is already in use";
179 "/diagnostics_agg/bond" + req.load_namespace, req.load_namespace,
185 bonds_.push_back(req_bond);
190 res.message =
"Successfully initialised AnalyzerGroup. Waiting for bond to form.";
196 res.message =
"Failed to initialise AnalyzerGroup.";
204 diagnostic_msgs::DiagnosticArray diag_array;
206 diagnostic_msgs::DiagnosticStatus diag_toplevel_state;
207 diag_toplevel_state.name =
"toplevel_state";
208 diag_toplevel_state.level = -1;
211 vector<boost::shared_ptr<diagnostic_msgs::DiagnosticStatus> > processed;
213 boost::mutex::scoped_lock lock(
mutex_);
216 for (
unsigned int i = 0; i < processed.size(); ++i)
218 diag_array.status.push_back(*processed[i]);
220 if (processed[i]->level > diag_toplevel_state.level)
221 diag_toplevel_state.level = processed[i]->level;
222 if (processed[i]->level < min_level)
223 min_level = processed[i]->level;
226 vector<boost::shared_ptr<diagnostic_msgs::DiagnosticStatus> > processed_other;
228 boost::mutex::scoped_lock lock(
mutex_);
231 for (
unsigned int i = 0; i < processed_other.size(); ++i)
233 diag_array.status.push_back(*processed_other[i]);
235 if (processed_other[i]->level > diag_toplevel_state.level)
236 diag_toplevel_state.level = processed_other[i]->level;
237 if (processed_other[i]->level < min_level)
238 min_level = processed_other[i]->level;