Calling Panda3D from Matlab

Has anyone tried, or does anyone know if/how well it would work to call Panda3D functions from Matlab? Sorry if this is a silly question; I’m totally new to Panda3D.

Longer story for those interested in background. I’m trying to evaluate Panda3D for the development of scientific experiments in vision research, using a head-tracked VR setup. The two primary requirements are real-time execution, and ease of code development. From what I understand, the former should not be a problem. And if students could access Panda3D from Matlab this would help with the latter issue.

Please advise. Thanks!

I don’t know anything about Matlab. I imagine it has its own language, with its own system for bindings? And that it’s possible to make calls out to C-library functions?

It all depends on the nature of Matlab’s callout mechanism. But presumably you can’t just automatically create C++ objects within Matlab without first running the C++ code through a program like SWIG or interrogate. If this is the case, then it is possible to make Panda work with Matlab, just as it is possible to make it work with any interpreted language that can do callouts. However, it would be a lot of effort. We’ve already done the effort to make it work with Python, but we don’t have any plans to add support for additional languages right now–you’d have to do that work yourself, and be prepared to maintain it as well.

On the other hand, if Matlab can call Python functions, you’re golden.

David

I’ll admit I don’t use matlab, can’t stand the monster, and hence am speculating to some extent, but a lot of people in my group use it, hence I’m not entirely shooting in the dark. But its easy enough to see what options are available:

  1. If there is a tool to call python from matlab then maybe you can embed it - this is the ‘obvious’ approach, but from what I understand such a tool probably doesn’t exist. There would also be potential persistence issues. Under Windows you would also need to get panda into the normal python install or matlab to use panda’s python install, though that is quite doable.

  2. I know tools to call matlab from python exist (pymat) - they would import into panda without problem and you could then have panda drive the system, calling matlab to get the relevant data. This is probably the easiest solution and certainly the only one that doesn’t involve jumping through some serious hoops. But it might not work depending on what matlab is doing.

  3. Get down and dirty and setup an explicit communication channel - probably sockets - to interface the two over a network. Handling sockets in python is easy, and I presume there exists a library to do it in matlab. From a development view this makes things harder, and slower, but from a runtime view its the approach I would prefer, as matlab and panda would be in separate threads and could make use of a multi core processors, or even run on different machines if it became necessary. It also makes further tricks such as multiple viewers for one data source easy to setup. Could all be nicely encapsulated to.

  4. Both python and matlab can call c, you could potentially pass data via a c program. It would be different instances of the program however, so really that is just another way of doing the above. It just makes a single language implementation of the communication channel possible, which could be convenient if it was going to be changed often.

  5. Taking c again you could interface with panda via its c++ interface, and basically create an interface to panda that is directly imported into matlab - a lot of work, though once done you should have a very neat programming model for interfacing the two. Probably not justified for a single project however.

Those are the options, couldn’t get more specific without more information really, but none of those are exactly beginners stuff. Good luck with whatever you do!