corobot_analyzer.h
Go to the documentation of this file.
00001 /*********************************************************************
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Copyright (c) 2009, Willow Garage, Inc.
00005  *  All rights reserved.
00006  *
00007  *  Redistribution and use in source and binary forms, with or without
00008  *  modification, are permitted provided that the following conditions
00009  *  are met:
00010  *
00011  *   * Redistributions of source code must retain the above copyright
00012  *     notice, this list of conditions and the following disclaimer.
00013  *   * Redistributions in binary form must reproduce the above
00014  *     copyright notice, this list of conditions and the following
00015  *     disclaimer in the documentation and/or other materials provided
00016  *     with the distribution.
00017  *   * Neither the name of the Willow Garage nor the names of its
00018  *     contributors may be used to endorse or promote products derived
00019  *     from this software without specific prior written permission.
00020  *
00021  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032  *  POSSIBILITY OF SUCH DAMAGE.
00033  *********************************************************************/
00034 
00035 #ifndef COROBOT_ANALYZER_H
00036 #define COROBOT_ANALYZER_H
00037 
00038 #include <map>
00039 #include <ros/ros.h>
00040 #include <vector>
00041 #include <string>
00042 #include <sstream>
00043 #include <boost/shared_ptr.hpp>
00044 #include <boost/regex.hpp>
00045 #include <pluginlib/class_list_macros.h>
00046 #include "diagnostic_msgs/DiagnosticStatus.h"
00047 #include "diagnostic_msgs/KeyValue.h"
00048 #include "diagnostic_aggregator/analyzer.h"
00049 #include "diagnostic_aggregator/status_item.h"
00050 #include "diagnostic_aggregator/generic_analyzer_base.h"
00051 #include "XmlRpcValue.h"
00052 #include "std_msgs/String.h"
00053 
00054 #undef DEBUG
00055 
00056 namespace diagnostic_aggregator
00057 {
00064 inline bool getParamVals(XmlRpc::XmlRpcValue param, std::vector<std::string> &output)
00065 {
00066   XmlRpc::XmlRpcValue::Type type = param.getType();
00067   if (type == XmlRpc::XmlRpcValue::TypeString)
00068   {
00069     std::string find = param;
00070     output.push_back(find);
00071     return true;
00072   }
00073   else if (type == XmlRpc::XmlRpcValue::TypeArray)
00074   {
00075     for (int i = 0; i < param.size(); ++i)
00076     {
00077       if (param[i].getType() != XmlRpc::XmlRpcValue::TypeString)
00078       {
00079         ROS_ERROR("Parameter is not a list of strings, found non-string value. XmlRpcValue: %s", param.toXml().c_str());
00080         output.clear();
00081         return false;
00082       }
00083 
00084       std::string find = param[i];
00085       output.push_back(find);
00086     }
00087     return true;
00088   }
00089 
00090   ROS_ERROR("Parameter not a list or string, unable to return values. XmlRpcValue:s %s", param.toXml().c_str());
00091   output.clear();
00092   return false;
00093 }
00094 
00095 
00198 struct processErrors
00199 {
00200     std::string processName;
00201     std::string error;
00202     int level;
00203 };
00204 
00205 
00206 class CorobotAnalyzer : public GenericAnalyzerBase
00207 {
00208 public:
00212   CorobotAnalyzer();
00213   
00214   virtual ~CorobotAnalyzer();
00215 
00216   // Move to class description above
00224   bool init(const std::string base_path, const ros::NodeHandle &n);
00225 
00231   virtual std::vector<boost::shared_ptr<diagnostic_msgs::DiagnosticStatus> > report();
00232 
00237   virtual bool match(const std::string name);
00238 
00239 private:
00240   std::vector<std::string> chaff_; 
00241   std::vector<std::string> expected_;
00242   std::vector<std::string> startswith_;
00243   std::vector<std::string> contains_;
00244   std::vector<std::string> name_;
00245   std::vector<boost::regex> regex_; 
00246   std::vector<struct processErrors> processErrorsList;
00247   
00248   ros::Publisher removeError_pub, newError_pub;
00249 
00250   void processLCD(boost::shared_ptr<diagnostic_msgs::DiagnosticStatus> processed);
00251 };
00252 
00253 }
00254 #endif //COROBOT _ANALYZER_H
00255 


corobot_diagnostics
Author(s):
autogenerated on Wed Aug 26 2015 11:09:34