Real-time export data to simulink
Hello,
I'm seeking a solution to output position and orientation data to another computer running Simulink in real time. Does anybody have any experience? Thanks! |
Can Simulink read data coming over a network socket? If so, you can use the Python socket module to send data over the network.
|
I found a UDP Receive block in Simulink. It requires the other end of the communication, which is vizard, to specify the port that receives data. I'm not sure how to do it. I think my code only specifies the port that sends data. Am I missing something?
Code:
import viz |
This post shows how to send and receive data on UDP sockets using different ports.
|
I'm confused, in the sample code, there is only one port 4999, which is "#The port to send/receive data on". Why does it show using different ports? Thanks.
|
So far I'm sure simulink on computer B can receive data from specified IP address and port over UDP. Then my question is, how do I specify the port that the remote computer B accepts data from in vizard on this computer A? Thanks.
|
I just got them communicated successfully. PORT = xxxx seems to be used to specify the remote port to receive from. Please forget my previous question.
My next problem is I would like to send two values from vizard to simulink every 0.05 second. My code would be like this: Code:
import viz Thanks a lot. |
When sending data using the socket module, the data needs to be a string containing the raw byte data. Have a look at the Python struct module for packing Python integer/float values into raw byte data. The following example shows how to generate raw byte data from 2 integer values:
Code:
import struct |
Thanks a lot. That really helps.
|
All times are GMT -7. The time now is 12:19 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC