Thread Subject: Continuously read from workspace using Real-time workshop

Subject: Continuously read from workspace using Real-time workshop

From: Leo Steenson

Date: 20 Sep, 2010 12:57:04

Message: 1 of 5

I have built a control system for a robot using matlab simulink and the real-time workshop, which all works great. However I have a C++ program which does our vision processing and I would like to get the processed data into the matlab real-time system.

One approach I am trying at the minute is to use the Matlab engine library to send the variables from the C++ program into the matlab workspace. This currently works, but I don't know how to then read the variables from the workspace into the real-time system continuously (not just at the beginning). I have tried using the 'from workspace' block without success.

Is what I am attempting possible or am I going the completely wrong way around this problem?

The basic objective is to stream data from a C++ program into the matlab real-time system while it is running, so if there are better methods of doing this I would appreciate the advice.

Thanks in advance.
Leo

Subject: Continuously read from workspace using Real-time workshop

From: Walter Roberson

Date: 20 Sep, 2010 19:16:28

Message: 2 of 5

On 10-09-20 07:57 AM, Leo Steenson wrote:
> I have built a control system for a robot using matlab simulink and the
> real-time workshop, which all works great. However I have a C++ program
> which does our vision processing and I would like to get the processed
> data into the matlab real-time system.
>
> One approach I am trying at the minute is to use the Matlab engine
> library to send the variables from the C++ program into the matlab
> workspace. This currently works, but I don't know how to then read the
> variables from the workspace into the real-time system continuously (not
> just at the beginning). I have tried using the 'from workspace' block
> without success.
> Is what I am attempting possible or am I going the completely wrong way
> around this problem?
>
> The basic objective is to stream data from a C++ program into the matlab
> real-time system while it is running, so if there are better methods of
> doing this I would appreciate the advice.

I seem to recall there is a Simulink UDP or TCP block that can be used with RTW.

Subject: Continuously read from workspace using Real-time workshop

From: Leo Steenson

Date: 21 Sep, 2010 08:48:04

Message: 3 of 5

Walter Roberson <roberson@hushmail.com> wrote in message <i78c2q$3ai$2@canopus.cc.umanitoba.ca>...
> On 10-09-20 07:57 AM, Leo Steenson wrote:
> > I have built a control system for a robot using matlab simulink and the
> > real-time workshop, which all works great. However I have a C++ program
> > which does our vision processing and I would like to get the processed
> > data into the matlab real-time system.
> >
> > One approach I am trying at the minute is to use the Matlab engine
> > library to send the variables from the C++ program into the matlab
> > workspace. This currently works, but I don't know how to then read the
> > variables from the workspace into the real-time system continuously (not
> > just at the beginning). I have tried using the 'from workspace' block
> > without success.
> > Is what I am attempting possible or am I going the completely wrong way
> > around this problem?
> >
> > The basic objective is to stream data from a C++ program into the matlab
> > real-time system while it is running, so if there are better methods of
> > doing this I would appreciate the advice.
>
> I seem to recall there is a Simulink UDP or TCP block that can be used with RTW.


Any recommendations as to how to send UDP packets using C++? The Matlab receiving side seems straight forward enough but the examples I find online for the C++ side all seem overly sophisticated for all I need.

All I need to do is pass four integers over from C++ to matlab RTT. Thanks again.

Subject: Continuously read from workspace using Real-time workshop

From: Walter Roberson

Date: 23 Sep, 2010 03:23:58

Message: 4 of 5

On 21/09/10 3:48 AM, Leo Steenson wrote:
> Walter Roberson <roberson@hushmail.com> wrote in message

>> I seem to recall there is a Simulink UDP or TCP block that can be used
>> with RTW.

> Any recommendations as to how to send UDP packets using C++? The Matlab
> receiving side seems straight forward enough but the examples I find
> online for the C++ side all seem overly sophisticated for all I need.

It has been several years since I last did that kind of thing. It
involves several steps.

Generally speaking, UDP packets can be sent with fewer calls than are
needed for TCP, but if you send UDP using those short-cuts then I
believe the UDP has to be received with the same kind of short-cuts; as
it seems unlikely to me that Mathworks would have implemented both kinds
of receiving, it seems more probable that you would have to go through
the more detailed steps, a sequence that would look nearly identical to
the set up required for TCP.

The work is less if you use a numeric IP address rather than looking up
a host name... but of course using a numeric IP address is less flexible
in the long run.

The O'Reilly TCP/UDP book is pretty good.

Subject: Continuously read from workspace using Real-time workshop

From: Boris Skopljak

Date: 14 Feb, 2011 20:56:04

Message: 5 of 5

Hi Leo,

Did you find the solution for you problem. I am actually trying to do the same thing. I am trying to send some numerical variables from C++ to UDP and import them in Matlab in real time. I cannot find good c++ examples. I would appreciate if you could give me an advice how to solve this issue.

Thanks,

Boris

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
realtime workshop Leo Steenson 20 Sep, 2010 08:59:35
c Leo Steenson 20 Sep, 2010 08:59:35
opencv Leo Steenson 20 Sep, 2010 08:59:35
interprocess co... Leo Steenson 20 Sep, 2010 08:59:35
from workspace Leo Steenson 20 Sep, 2010 08:59:35
robot Leo Steenson 20 Sep, 2010 08:59:35
auv Leo Steenson 20 Sep, 2010 08:59:35
rssFeed for this Thread

Contact us at files@mathworks.com