ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
2

How to publish raw data to /diagnostics topic?

asked 2021-11-14 06:47:41 -0600

Kevin1719 gravatar image

Hi, I have been reading about Diagnostics tools in ROS and knew how to setup to analyze the raw data from robot hardware. But I'm wondering how to publish those data to /diagnostics topic, so that I can use them to analyze and re-publish to /diagnostics_agg topic?

Can anyone explain the process of getting raw data from robot hardware and how to config it to use in ROS? Thank you so much.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2021-11-20 21:07:27 -0600

Kevin1719 gravatar image

I figured out that first you need a code to read port signals (e.g. battety current or motor temperature), then publish those data to relevant topics. Once you have raw data in the system, you need a node to subscribe for those data and then reformat it to diagnostic_msgs/DiagnosticArray type to republish them to /diagnostics topic so you can use it with the diagnostic package tools.

There is a really good example for filling the fields in DiagnosticArray type here.

edit flag offensive delete link more
2

answered 2021-11-14 18:00:13 -0600

Geoff gravatar image

You need to publish diagnostic information from your robot using the messages and services defined in diagnostic_msgs. You should make a node that reads the raw data from the robot hardware and fills in these messages, then publishes them to the diagnostics topic.

There is a good tutorial on setting up the aggregator available here.

For a real example, see the PR2 power board node, which publishes diagnostic information for the power distribution board.

edit flag offensive delete link more

Comments

Thank you for your answer. But I have to be honest, I'm not really good in coding, I got lost in the code you gave and didn't know where to start with. The only problem I have now is how to convert raw data to diagnostic_msgs/DiagnosticArray, will I have to do it manually or is there a tool for the job? Since it quite an exhausting process.

Kevin1719 gravatar image Kevin1719  ( 2021-11-15 04:06:27 -0600 )edit

I can't tell you how to convert the raw data because I do not know what format it is in.

If you are struggling to understand the code, then I think you might be better off learning coding better first.

Geoff gravatar image Geoff  ( 2021-11-15 16:51:31 -0600 )edit

For example, I received battery_voltage value from the hardware, so I want to re-format it as a DiagnosticArray message, with the 'name' field is "battery_voltage", and the 'value' field is the value of the battery voltage recieved, shoud I do it by re-format the data for every type of raw data, or is there another way to do it faster?

Kevin1719 gravatar image Kevin1719  ( 2021-11-15 21:03:39 -0600 )edit

That's how you have to do it.

Geoff gravatar image Geoff  ( 2021-11-16 17:49:10 -0600 )edit

Okay, thanks for your enthusiasm.

Kevin1719 gravatar image Kevin1719  ( 2021-11-20 20:57:01 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2021-11-14 06:47:41 -0600

Seen: 541 times

Last updated: Nov 20 '21