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;
96 bool analyzed =
false;
99 boost::mutex::scoped_lock lock(
mutex_);
100 for (
unsigned int j = 0; j < diag_msg->status.size(); ++j)
124 boost::mutex::scoped_lock lock(
mutex_);
125 ROS_WARN(
"Bond for namespace %s was broken", bond_id.c_str());
126 std::vector<boost::shared_ptr<bond::Bond> >::iterator elem;
128 if (elem ==
bonds_.end()){
129 ROS_WARN(
"Broken bond tried to erase a bond which didn't exist.");
135 ROS_WARN(
"Broken bond tried to remove an analyzer which didn't exist.");
143 boost::mutex::scoped_lock lock(
mutex_);
149 diagnostic_msgs::AddDiagnostics::Response &res)
151 ROS_DEBUG(
"Got load request for namespace %s", req.load_namespace.c_str());
153 if (req.load_namespace[0] !=
'/')
155 res.message =
"Requested load from non-global namespace. Private and relative namespaces are not supported.";
163 boost::mutex::scoped_lock lock(
mutex_);
167 res.message =
"Requested load from namespace " + req.load_namespace +
" which is already in use";
176 "/diagnostics_agg/bond" + req.load_namespace, req.load_namespace,
182 bonds_.push_back(req_bond);
187 res.message =
"Successfully initialised AnalyzerGroup. Waiting for bond to form.";
193 res.message =
"Failed to initialise AnalyzerGroup.";
201 diagnostic_msgs::DiagnosticArray diag_array;
203 diagnostic_msgs::DiagnosticStatus diag_toplevel_state;
204 diag_toplevel_state.name =
"toplevel_state";
205 diag_toplevel_state.level = -1;
208 vector<boost::shared_ptr<diagnostic_msgs::DiagnosticStatus> > processed;
210 boost::mutex::scoped_lock lock(
mutex_);
213 for (
unsigned int i = 0; i < processed.size(); ++i)
215 diag_array.status.push_back(*processed[i]);
217 if (processed[i]->level > diag_toplevel_state.level)
218 diag_toplevel_state.level = processed[i]->level;
219 if (processed[i]->level < min_level)
220 min_level = processed[i]->level;
223 vector<boost::shared_ptr<diagnostic_msgs::DiagnosticStatus> > processed_other;
225 boost::mutex::scoped_lock lock(
mutex_);
228 for (
unsigned int i = 0; i < processed_other.size(); ++i)
230 diag_array.status.push_back(*processed_other[i]);
232 if (processed_other[i]->level > diag_toplevel_state.level)
233 diag_toplevel_state.level = processed_other[i]->level;
234 if (processed_other[i]->level < min_level)
235 min_level = processed_other[i]->level;