Puck.js accelerometer/gyro to Touchdesigner

Posted on
  • Hi everyone,I'm new to programming with Puck.js and i was wandering if there is a way to send the accelerometer/gyro data to the Touchdesigner software.
    Touchdesigner is an interactive design software which can take data trough Websockets, Serial ports, OSC and more, no Bluetooth tho,as far as i know.
    I was trying to establish a connection between my Puck.js and Touchdesigner using a Websocket to be able to control the position in a 3d space of a bunch of 3D models with the Puck.js movements.
    While I implemented the touchdesigner websocket and the server part and made them work,i'm not able to connect the Puck.js to the server to send the data coming from the accelerometer/gyro.
    Is there a way to do it? all i get from the Web IDE is the error: "Websocket is not defined" but i don't get how to solve this problem. Is a websocket the correct way to do something like this? and if not,how should I approach to this problem in the most convenient way?
    Thanks so much to everyone who will answer.
    R.

  • If touchdesigner doesn't support getting data from Bluetooth, as you say you're going to have to have something inbetween to forward the data to it. You won't be able to do it direct from the Web IDE but you'll need to make a webpage that uses Web Bluetooth to get data from the Puck and then forward it to Touchdesigner.

    As a start, maybe look at https://www.espruino.com/Web+Bluetooth#two-way-communications
    which shows you how to use the light value from the Puck. Instead of setInterval(function(){Bluetooth.println(Puck.light());},100); for the light instead do: Puck.accelOn();Puck.on("accel", e=>Bluetooth.println(JSON.stringify(e))) to send the accel data out.

    And then in function onLine(v) do something like:

    try {
      var obj = JSON.parse(v);
      // do something with obj here to pass it to the WebSocket connection
    } catch (e) {
      // if something else got printed by the puck JSON.parse will fail but we just ignore it
    }
    

    There's also something similar where a Bangle.js is used as well at https://www.espruino.com/Bangle.js+Data+Streaming - but no websockets used there either so you'd have to figure that bit out

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Puck.js accelerometer/gyro to Touchdesigner

Posted by Avatar for user159272 @user159272

Actions