How do I use Stream Input block to parse ASCII encoded data received via UDP, TCP or Serial with Simulink Desktop Real-Time?

6 Ansichten (letzte 30 Tage)
I would like to read UDP packets sent from a KUKA robot in a Simulink Desktop Real-Time (SLDRT) application.
The UDP packets include 120 Byte ASCII encoded data in XML format containing position information of the robot, e.g.:
<Rob Type="KUKA"><RIst X="-18.3" Y="260.3" Z="25.0" A="18.6" B="1.4" C="-1.1"/><Delay D="0"/><IPOC>9420422</IPOC></Rob>
My aim is to process the values for X, Y, Z, A, B, and C. How can I parse the XML data from the UDP packets in a Simulink Desktop Real-Time application?

Akzeptierte Antwort

MathWorks Support Team
MathWorks Support Team am 13 Nov. 2025 um 0:00
Bearbeitet: MathWorks Support Team am 13 Nov. 2025 um 10:20
Use a Stream Input block from the Simulink Desktop Real-Time library with the following settings:
  • Block output data types: 
    '6*double'
  • Format string:
    '<Rob Type=\"KUKA\"><RIst X=\"%f\" Y=\"%f\" Z=\"%f\" A=\"%f\" B=\"%f\" C=\"%f\"/>'
  • Message termination:
    '</Rob>'
In this way, we can read 6 double values X, Y, Z, A, B, and C, that are placed at the positions marked by %f placeholders. Note the escaped double quotes (preceded by a backslash).

Weitere Antworten (0)

Kategorien

Mehr zu Model Preparation for Real-Time Simulation finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by