How to properly configure a diagnostics analyzer plugin in ROS [closed]

asked 2016-02-15 04:47:06 -0500

juls gravatar image

updated 2016-02-15 04:58:33 -0500

ahendrix gravatar image

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/Tutor... . Inside the ROS package home folder the plugin.xml(sample_analyzer_plugin.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 myrmex_safety_reporter 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 diagnostic_aggregator, diagnostic_msgs, 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 sample_analyzer_load.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.

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by tfoote
close date 2017-12-05 16:50:19.293789

Comments

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

ahendrix gravatar image ahendrix  ( 2016-02-15 05:01:40 -0500 )edit