Robotics StackExchange | Archived questions

How to properly configure a diagnostics analyzer plugin in ROS

Hello to everyone, i am new to ROS and i have the following problem:

I want to create an Analyzer plugin so as to process messages posted in the /diagnostics topic.

The Analyzer class has been implemented exactly as it is described in the http://wiki.ros.org/diagnostics/Tutorials/Creating%20a%20Diagnostic%20Analyzer. Inside the ROS package home folder the plugin.xml(sampleanalyzerplugin.xml in my case) file it is defined as follows:

<library path="lib/libsample_analyzer"><class name="SampleAnalyzer" type="diagnostic_aggregator::SampleAnalyzer" base_class_type="diagnostic_aggregator::Analyzer"><description>
      SampleAnalyzer is tutorial for writing diagnostic analyzers.
    </description></class></library>

where myrmexsafetyreporter the ROS package name. And is exported in the package.xml as follows:

<export><!-- Other tools can request additional information be placed here 
--><diagnostic_aggregator plugin="${prefix}/sample_analyzer_plugin.xml"/></export>

In the package's CMakeLists.txt catkin dependencies to diagnosticaggregator, diagnosticmsgs, pluginlib and the following are added:

add_library(sample_analyzer src/sample_analyzer.cpp ${ANALYZER_HEADERS})
target_link_libraries(sample_analyzer ${catkin_LIBRARIES})

 target_link_libraries(sample_analyzer
   myrmex_safety_reporter
 )

And after the build the libsample_analyzer.so is properly created.

I have implemented a publisher in python exactly as it is described in the ROS paradigm, and it works fine. I have created the following launch file, called base.launch so as to load my plugin to the diagnostics_aggregator:

 <launch>
      <node pkg="diagnostic_aggregator" type="aggregator_node" name="diagnostic_aggregator">
        <rosparam command="load" file="$(find myrmex_safety_reporter)/param/sample_analyzer_load.yaml"/>
      </node>
    </launch> 

the sampleanalyzerload.yaml is defined as follows (exactly like the ROS example):

pub_rate: 1.0 # Optional, defaults to 1.0
analyzers:
  Motors:
    type: SampleAnalyzer
    power_board_name: Power board 1000

I have overriden the Analyzer's report method so as to return only specific fields of the message and not the entire message in the /diagnostics_agg as follows:

vector<boost::shared_ptr<diagnostic_msgs::DiagnosticStatus> > SampleAnalyzer::report()
{
  boost::shared_ptr<diagnostic_msgs::DiagnosticStatus> eth_stat = eth_master_item_->toStatusMsg(path_);
    ROS_INFO("Overrided Analyzer report function");
  // If we have power data, and runstop is hit, we'll suppress errors
  if (has_eth_data_ && has_power_data_ && runstop_hit_)
  {
    eth_stat->level = diagnostic_msgs::DiagnosticStatus::OK;
  }

  vector<boost::shared_ptr<diagnostic_msgs::DiagnosticStatus> > output;
  boost::shared_ptr<diagnostic_msgs::DiagnosticStatus> processed_msg (new diagnostic_msgs::DiagnosticStatus);
  processed_msg->name=eth_stat->name;
  processed_msg->level=eth_stat->level;
  output.push_back(processed_msg);
  return output;
}

Now after launching the diagnostic aggregator with:

roslaunch myrmex_safety_reporter base.launch

I see that in the diagnostics_agg topic the entire messages are published, instead of specific fields that i defined in the Analyzer report method.

This means that the Analyzer's report method is not overriden or that my SampleAnalyzer is not loaded!!! How can i load my own analyzer in the diagnostic_aggregator??? Any suggestions it would be useful!!! Thank you in Advance.

Asked by juls on 2016-02-15 05:47:06 UTC

Comments

Is your match() function being called? Does it return true for the status item you're interested in?

Asked by ahendrix on 2016-02-15 06:01:40 UTC

Answers