dylanmckay / psvr-protocol

Breakdown of the PlayStation VR communication protocols for programmers
Creative Commons Attribution 4.0 International
12 stars 2 forks source link

Document the sensor readout timestamp fields #11

Open dylanmckay opened 6 years ago

dylanmckay commented 6 years ago

As described on the PSVRFramework Wiki (Ctrl+F "time").

Each sensor frame stores timestamps from sensors.

Document them.

m-7761 commented 6 years ago

I could not find a link to the page, the commit changed.... I looked GitHub up and down on the Commit's page.

I navigated to it manually. If this is a request for information. Then uint8_t unknown[4]; is the timestamp. What else could it be? It's a 32-bit number, that never exceeds 16777215. So, it overflows approximately every 16.777216 seconds.

Edited/Off-topic: just now I alerted TrinusPSVR's developer to this effort (http://oddsheepgames.com/?topic=can-we-discuss-psvrpc-without-trinus-here-few-resources-for-it-exist/#post-7804)

dylanmckay commented 6 years ago

I navigated to it manually. If this is a request for information. Then uint8_t unknown[4]; is the timestamp. What else could it be? It's a 32-bit number, that never exceeds 16777215. So, it overflows approximately every 16.777216 seconds.

This is a request for information.

How confident are you that the unknown[4] field is the timestamp? What you've said makes a lot of sense.

I wish we had USB sniffer dumps!

m-7761 commented 6 years ago

Well... I assumed it is so, but I've been using PSVRToolbox's UDP feature to get the timestamps... so I assumed it's so, but looking again:

---First sensor group---

16: integer, Timestamp1 (in micro-seconds, rolls back at 0x00FFFFFF)
19: byte, padding (0x00 seen)

This shows, byte 16 is the timestamp. So that's probably the case. The 19th byte that is mentioned, is the 00 in 0x00FFFFFF. It's a little ambiguous, but I would say that it's a 32-bit value that doesn't go over this maximum. (So unknown[4] may not be the timestamp, since byte 16 is before the gyroscope/accelerometer measurements.)

EDITED: Although I should add, that the timestamp is broken in the PSVRToolbox release that is up on its GitHub account. And it could well be that it's so because the wiki there is wrong/out-of-date. I will make a point to look at the working source code.

m-7761 commented 6 years ago

Below is code from PSVR.cs, from PSVRToolbox/PSVRFramework's project.

            sensor.Buttons = (HeadsetButtons)data[0];
            sensor.Volume = data[2];

            sensor.Worn = (data[8] & 0x1) == 0x1 ? true : false;//confirmed
            sensor.DisplayActive = (data[8] & 0x2) == 0x2 ? false : true;
            sensor.Muted = (data[8] & 0x8) == 0x8 ? true : false;//confirmed

            sensor.EarphonesConnected = (data[8] & 0x10) == 0x10 ? true : false;//confirmed

            sensor.Timestamp1 = getUIntFromUInt32(data, 16);

            sensor.RawGyroYaw1 = getIntFromInt16(data, 20);
            sensor.RawGyroPitch1 = getIntFromInt16(data, 22);
            sensor.RawGyroRoll1 = getIntFromInt16(data, 24);

            sensor.RawMotionX1 = getAccelShort(data, 26);
            sensor.RawMotionY1 = getAccelShort(data, 28);
            sensor.RawMotionZ1 = getAccelShort(data, 30);

            sensor.Timestamp2 = getUIntFromUInt32(data, 32);

            sensor.RawGyroYaw2 = getIntFromInt16(data, 36);
            sensor.RawGyroPitch2 = getIntFromInt16(data, 38);
            sensor.RawGyroRoll2 = getIntFromInt16(data, 40);

            sensor.RawMotionX2 = getAccelShort(data, 42);
            sensor.RawMotionY2 = getAccelShort(data, 44);
            sensor.RawMotionZ2 = getAccelShort(data, 46);

            sensor.CalStatus = data[48];
            sensor.Ready = data[49];

            sensor.A = data[50];
            sensor.B = data[51];
            sensor.C = data[52];

            sensor.VoltageValue = data[53];
            sensor.VoltageReference = data[54];
            sensor.IRSensor = getIntFromInt16(data, 55);

            sensor.D = data[58];
            sensor.E = data[59];
            sensor.F = data[60];
            sensor.G = data[61];
            sensor.H = data[62];

            sensor.PacketSequence = data[63];

EDITED: Just for fun, IRSensor reads heat coming off your forehead, I guess. It's the third eye inside the set. I doubt it's for playing games.... probably detecting if the device is worn or not. I don't know. I'd be interested in theories. (In theory it can detect when the scope is telescoped out, but it's range doesn't extend all the way up to the face.)