Phantom Omni with Unity

Hello everybody, i’m trying to develop some scripts in order to use the Phantom Omni haptic device (http://www.sensable.com/haptic-phantom-omni.htm) in Unity.
So I have put the DLL of the API given with the Phantom Omni in the folder Assets/Plugins, and then i’m trying to call functions from this DLL with DllImport like this :

[DllImport("hd32")]
public static extern int hdInitDevice(string pConfigName);

I’m new in Unity so maybe there is something that i’m missing but actually this doesn’t work : when I try to call the function hdInitDevice in my script, I always get a DllNotFoundException and I really don’t understand why because my DLL seems to be in the good folder.

Does someone know why I get this error ?

I’m using Windows 7 64 bits.

Hello…Were you able to call the Phantom Omni using the DLL available?

Hello,i am a french engineering student and i am currently doing an internship in Tokyo. I also want to connect the Phantom to Unity with dll writing in C++ but my function are not correctly recognize by unity.
i use this :

sing UnityEngine;
using System.Collections;
using System;
using System.Runtime.InteropServices;

public class test : MonoBehaviour {

public float x,y,z;
public float magnitude;

delegate void loopFunc();

[DllImportAttribute(@“C:\Users\demo\Desktop\unitytest\Assets\plugins\simpleDLL”, EntryPoint = “init”)]
public static extern void init();

[DllImportAttribute(@“C:\Users\demo\Desktop\unitytest\Assets\plugins\simpleDLL”, EntryPoint =“position”)]
public static extern IntPtr position();

[DllImport(@“C:\Users\demo\Desktop\unitytest\Assets\plugins\simpleDLL”)]
public static extern void CallbackPosition(loopFunc hapticRendering);

and i have a problem with the last import.
If someone can help me?
Thanks

Hi
I try to use Phantom device in Unity 3D. I would appreciate that if I know you could make this connection?
Thank you in advance.
Mahdi

Hi there,

I have develop a simple haptic plugin for unity using openhaptics.

It is available here:

Enjoy.

Matt.

1 Like

Dr. Poyade,

I’d like to use your plugin in my academic project. I’ve encountered two problems:

  1. I’ve installed Open Haptics Toolkit v 3.0 (Academic Edition) and I can’t find the DLLs you mentioned in read-me PDF. Can you specify the exact location of these files?
  2. Regardless of the above, I’ve tried to run one of your scenes in my Unity project. Besides of the errors “can’t find DLL file”, there is “License error. This plugin is only supported in Unity Pro!”. I’m using free edition of Unity 4.5.5f. Is this plugin only for Pro version (can’t find that info in read-me or on Asset Store) or is this connected to the missing of the above mentioned DLLs?

Thank you very much for your response!

Hi,

  1. The openhaptics DLLs are not included in the project. You have to copy and paste them from your OpenHaptics 3.0 package into the indicated folder (See page 6 of the Manual). The only DLL file which is included is that of the Plugin.
  2. I have only tried the Plugin on Unity pro, which is the one I have on my professional PC. However, I do not see why it should not work on the academic version of Unity.

I hope this will be helpful.

Matt.

Hi Matt,

I’ve also tried to use the simple haptic plugin for a project we’re working on, and it does not seem to be connecting to unity properly on Windows 7.
I have Unity Pro on Windows 7 and XP computers, and while the plugin is working fine on our XP machine, connecting to Windows 7 throws the error “DllNotFoundException: ASimpleHapticPlugin” for all the examples that came with the haptic plugin.

We put all the required DLL’s in the root folder, for both XP and 7 machines, and we are sure the Phantom Omnis are working using the configuration tool provided by Geomagic.

Would you have any idea why this problem exists/how to solve the problem?

Thanks,

Adam

Hi Adam,

Sorry for my late answer :frowning:

I have developed the plugin on Window 7. if you have downloaded the plugin from the asset store, please ensure that you have copied the plugin folder (which includes the plugin) into your assets folder (not the root folder of your project). The rest of the haptic DLL will go in the root folder of your project. (Watch out this is a 32 bits development).

Keep me up to date.

BR

Matt.

Hi there,

I would like to post a conversation I had about the possibility to add in real time haptic object.

Please find the conversation below.

From P.
Hi,

I’ll take just a moment. When I’m instantiating a new object with haptic properities at a run-time (it works OK when called from Start()), I can’t touch it (my touching object goes through it). I believe i need to somehow update the haptic workspace, but I quite don’t get it.

I’m using slightly modified GenericFunctionsClass (I’ve modified GetTouchedObject() for my needs, that is - creating & destroing FixedJoints instead of direct manipulation on transform - but there is UpdateHapticObjectMatrixTransform() still present). The other script for my dummy is SimpleShapeManipulationAndPhysics (unmodified).

Which function and where should I call to enable touch for dynamically created objects (through Instantiate)? Thank you very much for your help.

Regards,

P.

I have answered the following:

Hi P.,

There is the function SetHapticGeometry() in the script myGenericFunctionsClass, which traverses all the object tagged as “Touchable”. I have moved this function from the start to the update method of my main script (e.g. SimpleContact Script) and I was able to add dynamically a new object. It is working fine.

So, when you want to assign a new haptic object, just tag this object as “Touchable” (and maybe for the sake of optimization, you can launch some kind of event to allow the execution of SetHapticGeometry() in your update method (for instance) only in that frame).

I hope this is useful.

BR

Matt.

\

Thank you so much for the reply.

So we’ve followed you’re advice, and now the plugin is starting up on Unity. The scene loads fine on unity, and the pen is movable in the environment, however, when the pen is about to come into contact with a surface, unity either freezes or throws a runtime error. I’ve attached a screenshot of unity throwing the error.

If let me know if you’ve encountered any errors like this before.
Thanks again for your help,

Adam

hi Adam,

I am afraid, I never had this error on Unity - To me and the people who test it here, it appeared to be quite stable. Some of our partners abroad tried it, they did not report any issues so far.

what version of OpenHaptics do you have (I have compiled it using OH 3.0 - I cannot guarantee normal functioning with lower versions)? Does this happen with all the scenes? Did you modify any of the scripts - especially the GenericFunctionClass, or you are running the examples as they are? You told me you have also been able to run the examples on XP, do you have the same error in XP?

Matt.

Hi Matt,

Sorry for the late response, we were getting new hardware for our lab. So we used another windows 7 computer and changed our FireWire PCI’s, and now it works!

You guys did awesome work on the plugin!

Thanks so much for your help again.

Adam

For those who use free version of Unity and would like to use Matt’s plug-in: all you have to do is follow the instructions in read-me, but additionally you should move the SimpleHapticsPlugin.dll from Plugin folder to the main folder of your project. Everything works great and you won’t get license error.

I am Working on unity3d and try to use Phantom device in Unity 3D for our surgical simulation projects.
I have already downloaded the “Unity Haptic Plugin for Geomagic OpenHaptics” project from asset store.
But it shows an error"NotFoundException: ASimpleHapticPlugin"
I would appreciate that if I know how you could make this connection between Phantom device and Unity 3D?
How to get this plugins like

  1. glu32.dll
  2. glut32.dll
  3. hd.dll
  4. hl.dll
  5. opengl32.dll
  6. PhantomLib42.dll
    Thank you in advance for your help.

Hi,

Sorry for my late answer.

The mistake you have got is due to the fact that Unity does not find your plugin dll file. You must paste your plugin file in the correct folder as indicated in the documentation or above in this forum.

You can find the dll files you mention in your openhaptic folders. I think the PhantomLib42.dll is not required so no worry if you cannot find it.

Best Regards

Matt.

Hello,

I have been working on a training simulation, and I have run into a problem. My program works just fine when I run it in the Unity editor, but when I build it and run the .exe file, the program has a tendency to freeze. This problem is exaggerated when I touch an object or run a program with a large number of objects. It happens even on the sample programs that came with the plugin, and I do not know what the problem is. I would greatly appreciate your help on this matter.

Hi d_brick,

I do not really understand why the simultation runs fine in editor mode but not when the project has been built.

I just can give you the advice to have a look at the number of vertices your objects have. Try to simplify your objects, or render haptically a simplified version of your scene.

This development is a relatively basic (and quick) implementation I have done for my students to be able to develop quicky some basic games on Unity.

BR

Matt.

Hi Matt,

I am a grad student and have found your plugin extremely helpful. Based on my present use of your plugin, it has been extremely useful and easy to use. I love how easily I can implement haptic properties to elements of the user interface for a realistic experience. But I am developing a game for my thesis research which requires the use of two haptic devices, therefore I was wondering if your plugin allows an easy modification to allow for this. Please let me know if you have any idea about my concern as I would like to continue to use your plugin and Unity to complete my research.

Thanks in advance for all your assistance.

Hi,

Sorry for my late answer. It is actually not possible for the plugin to recognize two haptic devices because it is not designed to do so. I am currently working on my free time to make a plugin which would be able to recognize X devices.

How every you eventually try to use two computers, each with an haptic device and pass to each other through network the modifications done by each device.

Regards

Matt.