OpenVR recorder TCP/UDP/OSC connection

74 views
Skip to first unread message

Amir Jaberzadeh

unread,
Mar 30, 2023, 5:30:50 PM3/30/23
to Brekel
Hi Brekel,
I have an openvr-recorder and trying to wirte a python code to get tracker Euler data from Brekel. When I use TCP/IP to transfer I can see data flowing in Ip 127.0.0.1 and the port I specified but can't decode the stream of information. When I use UDP, my python code can't connect to the ip, I tried 127.0.0.1 and 0.0.0.0 ips. I also check the tick for OSC on and off with the ip of 0.0.0.0 with no success. I also asked my question on Discord channel, sorry for duplication.

This is my code in python:

import socket TCP_IP = '127.0.0.1' TCP_PORT = 8889 BUFFER_SIZE = 1024 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((TCP_IP, TCP_PORT)) while True: # # s.send(MESSAGE) data = s.recv(BUFFER_SIZE) print("received data:", data) s.close()

Brekel

unread,
Mar 31, 2023, 6:09:03 AM3/31/23
to Brekel
This is the data structure for the TCP/UDP stream:

struct network_dataPacket
{
int packetSize = 0; // size of current data packet
int num_devices = 0; // number of devices found
int isValid[vr::k_unMaxTrackedDeviceCount]; // 1 for valid device, 0 for invalid device
int deviceTypes[vr::k_unMaxTrackedDeviceCount]; // DeviceType
float timestamps[vr::k_unMaxTrackedDeviceCount];
matrix44f_c transforms[vr::k_unMaxTrackedDeviceCount];
int buttons[vr::k_unMaxTrackedDeviceCount][NUM_BUTTONS];
vector2f axis[vr::k_unMaxTrackedDeviceCount][vr::k_unControllerStateAxisCount];

int hand_L_is_valid, hand_R_is_valid;
float hand_L_timestamp, hand_R_timestamp;
int hand_L_device_id, hand_R_device_id;
matrix44f_c hand_L_wrist, hand_R_wrist;
matrix44f_c hand_L_thumb[4], hand_R_thumb[4];
matrix44f_c hand_L_index[5], hand_R_index[5];
matrix44f_c hand_L_middle[5], hand_R_middle[5];
matrix44f_c hand_L_ring[5], hand_R_ring[5];
matrix44f_c hand_L_pinky[5], hand_R_pinky[5];
};



vr::k_unMaxTrackedDeviceCount = 64
vr::k_unControllerStateAxisCount = 5
NUM_BUTTONS = 14

(these are defined by the OpenVR SDK and could change with future releases)

cml::matrix44f_c is a 4x4 transform matrix comprising of 16 floats each
cml::vector2f is a 2D vector comprising of 2 floats each

enum DeviceType
{
DeviceType_Invalid, // the ID was not valid.
DeviceType_HMD, // Head-Mounted Displays
DeviceType_Controller, // Tracked controllers
DeviceType_GenericTracker, // Generic trackers, similar to controllers
DeviceType_TrackingReference, // Camera and base stations that serve as tracking reference points
DeviceType_DisplayRedirect // Accessories that aren't necessarily tracked themselves, but may redirect video output from other tracked devices
};


Op donderdag 30 maart 2023 om 23:30:50 UTC+2 schreef amirhossein...@gmail.com:

Brekel

unread,
Mar 31, 2023, 6:16:01 AM3/31/23
to Brekel
(as posted on Discord earlier)

Op vrijdag 31 maart 2023 om 12:09:03 UTC+2 schreef Brekel:
Reply all
Reply to author
Forward
0 new messages