How to extract data from diagnostics_msgs/DiagnosticArray ROS message type in Simulink?
8 views (last 30 days)
Show older comments
Indraneel Patil
on 5 Jul 2018
Commented: MathWorks Robotics and Autonomous Systems Team
on 9 Aug 2018
Dear Mathworks community, I need to extract data from diagnostics_msgs/DiagnosticArray ROS message type in my Simulink model. The message definition in ROS and Matlab matches and is the following :
std_msgs/Header header
uint32 seq
time stamp
string frame_id
diagnostic_msgs/DiagnosticStatus[] status
byte OK=0
byte WARN=1
byte ERROR=2
byte STALE=3
byte level
string name
string message
string hardware_id
diagnostic_msgs/KeyValue[] values
string key
string value
end
I am interested in the string value array inside the KeyValue[] values bus. In Simulink this element is detected as a bus element in an array of sub-buses. I have tried many combinations of Selector blocks and Bus Selector blocks but I havent been successful in extracting this data and exporting it to the Matlab workspace.So far I have tried the following :
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/191689/image.png)
Any help would be greatly appreciated! Thanks in advance.
0 Comments
Accepted Answer
MathWorks Robotics and Autonomous Systems Team
on 9 Aug 2018
Hi Sorry for the delayed response.
I was able to create this, it is indeed a bit tricky with Simulink buses and able to extract the data.
>> msg =
ROS DiagnosticArray message with properties:
MessageType: 'diagnostic_msgs/DiagnosticArray'
Header: [1×1 Header]
Status: [16×1 DiagnosticStatus]
Please note the three images attached, (1) The Simulink model using "Selector" + "Bus Selector" blocks in tandem, (2) The Default array sizes for the variable sized buses which are defined in the Simulink > Tools > ROS > Manage array sizes for the model.
Thanks
Robotics Team @ MathWorks
Setting for Diagnostic Array: </matlabcentral/answers/uploaded_files/128352/2018-08-09_12-11-52.png>
Setting for Diagnostic Status: </matlabcentral/answers/uploaded_files/128353/2018-08-09_12-12-11.png>
1 Comment
MathWorks Robotics and Autonomous Systems Team
on 9 Aug 2018
The link would take you to:
https://www.mathworks.com/matlabcentral/answers/</matlabcentral/answers/uploaded_files/128353/2018-08-09_12-12-11.png
Make sure to update them to:
https://www.mathworks.com/matlabcentral/answers/uploaded_files/128353/2018-08-09_12-12-11.png
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!