Contact information

How do I get the contact information from the sensel? Every time I touch it I can get the frame and get the force_data from the frame but whenever I try to get the n_contacts it says it is 0 and the contacts array is empty. I’m not sure how that can be so when there is force data. I am trying to obtain this information in Unity. I am working on a project and I need to be able to use the morph to detect several different touch interactions(finger down, finger up, swipe, drag, pinch in/out) but I am struggling to even obtain proper information from the API. I also will need the amount of pressure/force for each contact.

Hello and thank you for contacting us. You can find more about how to use our API at http://guide.sensel.com/api/, but you can enable forces and contact information by using the senselSetFrameContent function (http://guide.sensel.com/sensel_h/index.html#senselSetFrameContent) and passing in FRAME_CONTENT_CONTACTS_MASK | FRAME_CONTENT_PRESSURE_MASK.

You can also see a Unity example created by another developer using an older version of our API here: https://github.com/Stereoarts/sensel-unity

In Unity the function that gets called for setting the frame content is
[DllImport(“LibSensel”)]
public extern static int senselSetFrameContent(IntPtr handle, byte content);
In the example, in your link the visualizer passes a 1 for the content, which seems to get the pressure/force data. Unity can’t seem to find SenselDevice, which, according to this C# example, is where FRAME_CONTENT_CONTACTS_MASK is. I can’t seem to find the SenselDevice file anywhere. I have tried passing both 0 and 2 for the content byte, but still it tells me n_contacts is 0.

The Unity example used an older version of our API, which did not have the SenselDevice abstraction layer. In the Unity example, all you need to do is pass 5 into Sensel.senselSetFrameContent and you can get forces and contacts. The call is a bitmask, where 1 is pressure, 2 is labels, 4 is contacts so you can activate one or all of the data types.

Thank you. I can get the contact information now. I am noticing though that the x and y positions for contacts seem super sensitive(it reports a slightly different value every frame even when I don’t think my finger is really moving) and for whatever reason the delta x and delta y are always 0 despite me moving my finger back and forth.

Great to hear it worked. To turn on delta x and delta y, you need to enable it by using senselSetContactsMask, using the bitmask values. If you would like to receive all values, please send 0x0F. By default, the Morph sends the basic values (x,y,pressure, area, state and ellipse data).

Hi alex. I believe I have an older version of the api. I have whatever version is in your unity example link. That version does not appear to have senselSetContactsMask. Do you know what function/how to get all of the contact information in that version? Also I was looking at the api’s repo. If I choose to update my project to use the latest version of the API do I just need to build the LibSensel dll? Currently, my version of the api I am using in Unity has two dlls with a x86 version and a x86_64 version. The dlls are named LinSensel and LibSenselDecompressed. I only see the one LibSensel project in the latest stuff from the repo. Thank you so much for your help btw.