WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Interface between Matlab and Vizard (https://forum.worldviz.com/showthread.php?t=5052)

Shweta 06-01-2014 08:16 AM

Interface between Matlab and Vizard
 
Hello,
I am new to Vizard and have some experience with MATLAB.
I want to create an interface between MATLAB and Vizard.
I went through a few forums which state that I can create such an interface using PyMat.
Can someone elaborate on this?
Also, can I use TCP/IP or UDP to achieve this?

Any kind of help is greatly appreciated.

Thanks and Regards,
Shweta.

Jeff 06-01-2014 10:24 PM

You could try using Vizard's networking support to communicate with Matlab over UDP. There's sample code that shows how to send and receive raw byte data in Vizard.

Shweta 06-17-2014 08:51 AM

Thank you for the reply.
However I am unable to create a proper serialization between matlab and vizard.
Could someone please elaborate a bit more on this?

Thanks

Jeff 06-19-2014 06:31 AM

Vizard can receive raw byte network packets via UDP. If matlab can send the data via UDP then you should be able to get it in Vizard.

First you need to establish a connection with the machine running MatLab. You can either specify the machine name or IP address:

Code:

myNetwork = viz.addNetwork('machineName')
Then you create a callback function for the network event:

Code:

def onNetwork(e):
    if isinstance(e,viz.RawNetworkEvent):
        print e.raw_data

viz.callback(viz.NETWORK_EVENT,onNetwork)

Vizard sends/receives network data over UDP port 4950 by default. To receive data over a different port (e.g. 4960) use the following:

Code:

viz.net.addPort(4960)

Shweta 06-20-2014 08:35 AM

Hello Jeff,

Thanks for all the help.
I really appreciate it.
A small query, udp has worked fine but is there any other way to communicate between MATLAB and Vizard?

Kind Regards,
Shweta.

Jeff 06-23-2014 03:39 AM

There are add-on packages for Python available to interface with matlab. I have not installed or tested any of these myself but hope to do so in the future. Vizard 4 uses Python 2.7 so the add-on must be compatible with 2.7. Here a few libraries you can look into:

Pymatbridge -
http://arokem.github.io/python-matlab-bridge/

mlabwrap -
http://mlabwrap.sourceforge.net/

pymatlab -
https://pypi.python.org/pypi/pymatlab

Can you describe the kind of data you're looking to send over and why the networking method is not meeting your needs?

Shweta 06-23-2014 10:52 AM

Hello Jeff,

This method does meet my needs. Only problem is that I was told by one of my colleagues that UDP may be unsafe.

My main task is to send a transform matrix from MATLAB to Vizard to change the viewpoint (I will mostly use setPosition(); Euler and scaling for this)

Using UDP I could display some text in Vizard through MATLAB. So I am currently working on establishing a server client relation between MATLAB and Vizard where MATLAB sends the transformation matrix with 6 DOF and on receiving this Vizard sends some acknowledgement to MATLAB and one more after executing the transformation after which MATLAB sends the next command and this continues till the process is terminated either through MATLAB or on receiving a stop status from Vizard.

I shall go through the links suggested by you.

Thanks once again.

Kind Regards,
Shweta.

Shweta 06-23-2014 02:27 PM

Hello,

I have another query which is not related to the interface between MATLAB and Vizard.
I need to create a cloud of triangles.
I was thinking of using viz.TRIANGLES for this purpose.
My question is, is there a way to select the size of the triangles and their location? For location can I use random?
I would really appreciate if someone can elaborate a bit on this.

Thanks and Regards,
Shweta.

Jeff 06-30-2014 09:40 AM

Please create a new thread for questions that are not related to the thread topic.


All times are GMT -7. The time now is 07:19 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC