Unexpected bytes recieved when using Python client

NatNet, VRPN, TrackD, and Plugins
Post Reply
brettfeltmate
Posts: 2
Joined: Tue Oct 31, 2023 11:21 am

Unexpected bytes recieved when using Python client

Post by brettfeltmate »

Hi,

I am recieving data that should not be present within the stream. I'm still in the process of seeing exactly where and when this occurs, but I can point to one.

Setup details:
- Motive version 4.1
- Using PythonSample.py
- Changes made to NatNetClient.py
- sent request for MODELDEF
- slipping a file write into the start of __unpack_definitions to write the passed data to a binary file.

The problem:

When requesting model definitions, there are four bytes that appear between data_type and name. This is occuring when unpacking rigid body descriptions, though possibly it occurs later on as well, but the parsing process errors out before reaching them. Example byte array:

Code: Select all

# python
arr = bytes([
	# Offset 0x00000000 to 0x00000013
	0x0F, 0x00, 0x00, 0x00, # dataset count
	0x01, 0x00, 0x00, 0x00, # data type
	0x72, 0x00, 0x00, 0x00, # unexpected, first two bytes intepreted as body name
	0x54, 0x72, 0x69, 0x61, 0x6E, 0x67, 0x6C, 0x65 # actual body name
	]
)
Parsing this gives me:
- 0-4: Dataset count = 15 (correct)
- 5-8: DataType = 1 (rigid body; correct)
- 8-null: Name = 'r' (incorrect)

Name should be "triangle", but bytes 8-12 (x72, x00, x00, x00; decoded as 'r'), which should not be there, are interpreted as the model name. This causes parsing to unravel, as now bytes 10 - 14 are now taken to be the ID (some 10digit int), same issue for Parent ID, for position I get an absurd value of [0, -17e+39, 0] which implies that that rigid body is outside the observable universe, so thats probably inaccurate. Chaos ensues from there.

Any ideas what is causing this? As this is occuring when using the code provided by NatPoint, I'm a bit stumped on what to do. If I find out it is consistent in when/where it appears I can skip over it, but identifying junk data (if it is junk) by eye is tedious af.
brettfeltmate
Posts: 2
Joined: Tue Oct 31, 2023 11:21 am

Re: Unexpected bytes recieved when using Python client

Post by brettfeltmate »

Fix: in the various __unpack_[data_type]_description methods, initializing offset as 4 (0 originally) resolves the issue.

Edit: I suspect that the extra bytes specify the packet size (which is the case for frame data), but I haven't had a moment to confirm as this would be irrelevant for my use-case even if they were.
Post Reply