how to wrangle an osc_packet message?

Marcel Wierckx's icon

Hey there,

I'm trying to get data from a pair of Rokoko Smartgloves into Max. When I use "udpreceive @outputformat message" I get a stream of errors ('size is not a multiple of 4').

Using "udpreceive @outputformat osc_packet" I get a stream of "osc_packet u123456..." messages but I'm unable to parse or view the json. Tried connecting to osc.codebox to view the data but nothing shows up. Also tried setting Rokoko to send both v3 and v4 but no love.

Anyone here worked with Rokoko stuff before? Or does anybody know how to wrangle "osc_packet" messages into something I can work with?

thanks 🙏

Marcel

TFL's icon

I assume you want to use @outputformat fullpacket instead of @outputformat osc_packet which doesn't exist I think.

From that point I suggest to download the Odot package, and connect a [o.display] to your [udprececive @outputformat fullpacket] to see incoming messages, and [o.route] to to parse them.

Marcel Wierckx's icon

Hi TFL,

thanks for the reply. I failed to mention in my post that my first try was with FullPacket and OSC-Route, but got the error that the FullPacket message was incorrectly formatted. The o.display object showed nothing, and while sadam.udpReceiver gave more output the data itself looked garbled.

When I try udpreceive with no arguments I get a stream of errors:

udpreceive: OSC packet size (130) not a multiple of 4 bytes: dropping
udpreceive: OSC expected type string. Dropping message for address "Mh@n

The only thing I was able to achieve was using @outputformat rawbytes -> route rawbytes -> itoa, which gave me:

{"version":"3,0","fps":30.0,"scene":{"timestamp":13.7569342,"actors":[],"newtons":[],"props":[],"characters":[]}}

I thought maybe this new osc_packet feature would be useful but I can't find any way to extract the information from what looks like a dictionary? When I print the output of udpreceive using @outputformat osc_packet I see

print: osc_packet u483008757

The reference page for the osc_packet message says only TEXT_HERE 🤪

I'm afraid that Rokoko might be sending some kind of obscure proprietary format. I tried every possible setting in their app (JSON v3, JSON v4, VMC, VRChat). Was hoping their OSC implementation was sane but as usual with this kind of gadget it's not. Will investigate further and post results here for anyone else going down this rabbit hole.

Marcel

TFL's icon

My bad for osc_packet format, I completely missed it! As well as the object that comes with it.

It seems that there is no vanilla object that accept osc_packet messages, beside [osc.codebox], [osc.packet] and [udpsend], yet...

What you can try is the following: [udpreceive @outputformat osc_packet] > [osc.packet @oscformat fullpacket] > [o.dict] (from Odot package)

and this would give you a dictionary that you can treat with usual dict.* objects, especially [dict.iter] if you just want to throw everything out of it. But maybe it will just deport the 'size is not a multiple of 4' error to [osc.packet] from [udpreceive], I don't know.

And you were pretty close of another possible option:

[udpreceive @outputformat rawbytes] > [route rawbytes] > [itoa] > [dict.deserialize] which will hopefully give you a usable dictionary.