Connect "Senso Glove" to TouchDesigner

Hi,

I need to establish a communication between “Senso Glove” to the TouchDesigner using JSON. The Senso Glove has vibration abilities in each finger. My goal is basically to make the glove’s fingers vibrating, using TouchDesigner.
I know that I need to use a client TCP/IP DAT with the address/port parameters to set Senso’s server.
I also realized the vibration packet written in JSON:

{
  "dst": "Device MAC address",
  "type": "vibration",
  "data": {
    "type": "thumb/index/middle/third/little",
    "dur": <int 0-65536>,
    "str": <int 0-10>
  }
}

My questions is how actually can I make this vibration happen? what exactly should I write in the TCP/IP DAT componnent to establish this connection?
If you can attach pictures describing the code it’ll be wonderful.
I hope I clarified myself as well. If you have any questions, please ask.

Thanks a lot!

Hi @Gilad767,

Welcome to the Community.

I think there are a couple steps to achieve this. In the end though you would want to make use of the TCP/IP DATs’ python send Method to publish this json to the glove.

For testing I would just use a Text DAT, right click on it and hit run but later on use Extensions to build a more integrated system.

First though you would want to build out a python dictionary which then can be converted to JSON before being send to the glove:

# import the python json library
import json

# path to my tcp/ip dat
tcpDat = op('tcpip1')

# the values to be send to the glove
macAddress = 'someStringThatIsTheDeviceMacAddress'
command = 'vibration'
finger = 'thumb'
duration = 1000
strength = 10

# build up a python dict to send to the glove
sendDict = {
    'dst':  macAddress,
    'type': command,
    'data': {
        'type': finger,
        'dur': duration,
        'str': strength
    }
}

# convert the python dict to json
jsonStr = json.dumps(sendDict)

# send the jsonStr via the tcp/ip dat to whatever is connected
tcpDat.send(jsonStr)

This would be the theory, but I have no access to such glove so there are some things that might have to be changed - or example it’s not clear what line endings the glove server expects but the send Method does allow for specifying a terminator.

Cheers
Markus

Hi,

First of all thank you very much for answering.
I did the following steps:

  1. Created Text Dat componnent and wrote there the script you wrote above.
  2. Created TCP/IP DAT componnent for the server (TCPIP1), the touchdesigner.
  3. Created TCP/IP DAT componnent for the client (TCPIP2), the glove.

When I run the program, I can see in the TCPIP2 the values of the parameters I wrote in the Text Dat, but still - no vibration feedback from the glove.
I attach a screenshot of what I did. I probably missed something.
Hope you could help me.

Thanks again

You shouldn’t have a TCP/IP DAT server in TouchDesigner. The Senso TCP server, Senso BLE Server, is run externally through the driver.

See here: https://senso.me/docs/

Are you able to get their provided Senso client app working with the Senso BLE Server?

You want to recreate what they’re doing in that Senso client app, so once you have it working there, use the same address/port in your TCP/IP client DAT in TouchDesigner. If you’re running it locally the address will be localhost (ie. 127.0.0.1) and in the docs it says the default port is 9872.

The Sense client app is working with BLE server:

I removed the TCP/IP DAT server as you said, and created only TCP/IP DAT client.
The network address now is the localhost (127.0.0.1) and the port is 9872 (Screenshot is attached on the next reply).

Still, I don’t get any vibration feedback from the glove.
I really feel I’m almost there. Any additional ideas from you?

Much appreciated!

I believe Senso packets require a newline terminator. You can add that to the TCP/IP send method as a keyword:

tcpDAT.send(jsonStr, terminator='\n')