Puck.js onAccel callback speed is slow #4175
Replies: 1 comment
-
Posted at 2023-04-13 by mc9311 Sorry I forgot to attach my code for reference. Please find below.
Posted at 2023-04-17 by @gfwilliams Hi - I noticed you already posted this as an 'issue' on GitHub and I saw that first, so see the answer on there: espruino/Espruino#2349 But for anyone else looking at this: Bluetooth LE itself can't send data that fast (the fastest 'connection interval' supported is 7.5ms) so you'll instead have to batch up multiple samples into one transmission. Once that is done you should be ok to go a lot faster - but 1kHz may still be quite optimistic. Some friends have a company doing VR hand controllers and they're finding that 200Hz works more than well enough for them at the moment. Posted at 2023-04-17 by @fanoush Apart from batching maybe it would also help to not to have so many characteristics with string values but have one with e.g. 16 or 32bit binary triplet for xyz (3x16 or 3x32 bits). Not sure how many notifications/packets your single Typical BLE packet without MTU increase can have 20 bytes so your string values won't fit into single one making it much slower to send (and receive). EDIT: Posted at 2023-04-18 by mc9311 Hi Gordon, thanks a lot for your reply. I will try it out. Much appreciated Posted at 2023-04-18 by mc9311 Thanks for your input! Yes, I think I may try Posted at 2023-04-18 by mc9311 Also for others who may stumble upon this...I found out after reading the datasheets of the accelerometer and digging into the Espruino code for acceleration on the puck and it seems to be that the Puck's accelerometer is being put into low-power consumption mode which has a max polling rate of only 52Hz, but by doing the following two lines after
It should put the accelerometer chip into "high-performance operating mode enabled" which can allow up to 6.66kHz, but the max the puck can handle (based on documentation) is 1.66Hz. Note that battery consumption will be more, however. I believe this happens here in the Espruino code: https://github.com/espruino/Espruino/blob/3fbcd63bc327de67c88bf19efd9e4776249ebd3e/libs/puckjs/jswrap_puck.c#L528-L542 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2023-04-13 by mc9311
Hello,
I was trying to use a Puck.js v2.1 to broadcast accelerometer and gyro data to a mobile phone app at around 1kHz, but I can only get 50Hz. I am trying to double-integrate acceleration to get the world-frame to pose (position and orientation). I tried setting this function to 6600
Puck.accelOn(6600);
which matched one of the data rates supported by the accelerometer, but it still was around 45-50Hz which is not desired. How can I either increase the data rate through Javascript OR modify the existing firmware C code and reflash the Puck.js? If I want to modify the existing firmware what are the steps to do this? I believe the code base is here? https://github.com/espruino/Espruino. How would building binaries/installing the code work?Beta Was this translation helpful? Give feedback.
All reactions