This commit is contained in:
Hartmut Seichter 2025-06-30 22:10:49 +02:00
parent de9a4990e5
commit ec4728ed2a
2 changed files with 55 additions and 45 deletions

22
VRPN.gd
View file

@ -4,7 +4,6 @@ class_name VRPN
const magic_cookie_start : String = "vrpn: ver." const magic_cookie_start : String = "vrpn: ver."
static func marshall_block(data : PackedByteArray) -> void: static func marshall_block(data : PackedByteArray) -> void:
# need to fix that # need to fix that
@ -27,7 +26,7 @@ static func marshall_block(data : PackedByteArray) -> void:
var message_type := header.get_32() as int # type of message (payload) var message_type := header.get_32() as int # type of message (payload)
var sequence_num := header.get_32() as int # inofficial sequence number (padding) var sequence_num := header.get_32() as int # inofficial sequence number (padding)
if true: if false:
print("length '%d'" % length) print("length '%d'" % length)
print("time_sec '%d'" % time_sec) print("time_sec '%d'" % time_sec)
print("time_msec '%d'" % time_msec) print("time_msec '%d'" % time_msec)
@ -36,8 +35,10 @@ static func marshall_block(data : PackedByteArray) -> void:
print("sequence_num '%d'" % sequence_num) print("sequence_num '%d'" % sequence_num)
# print # print
print("block_offset:{0} header_size:{1} length:{2}".format([block_offset,header_size,length]))
print("sender_id:{0} message_type:{1} block_offset:{2} header_size:{3} length:{4}".format([sender_id, message_type, block_offset,header_size,length]))
# directly hand over marshalling for body
marshall_body(data.slice(block_offset+header_size,block_offset+length),message_type) marshall_body(data.slice(block_offset+header_size,block_offset+length),message_type)
# next datablock # next datablock
@ -49,13 +50,13 @@ static func marshall_body(data : PackedByteArray,message_type : int):
body.data_array = data body.data_array = data
body.big_endian = true body.big_endian = true
# sender description # sender description
match message_type: match message_type: # message_type_ids are supposedly dynamic
-1,-2: -1,-2:
# get length of string # get length of string
var body_length = body.get_32() var body_length = body.get_32()
# get string # get string
var sender_name = body.get_string(body_length) var sender_name = body.get_string(body_length)
print("sender name is %s:" % sender_name) print("sender name is '%s'" % sender_name)
#print(body.data_array) #print(body.data_array)
4: # quat pos 4: # quat pos
# get id # get id
@ -68,7 +69,16 @@ static func marshall_body(data : PackedByteArray,message_type : int):
var quat_y = body.get_double() var quat_y = body.get_double()
var quat_z = body.get_double() var quat_z = body.get_double()
var quat = Quaternion(quat_x,quat_y,quat_z,quat_w) var quat = Quaternion(quat_x,quat_y,quat_z,quat_w)
print("sensor id {0} {1} {2}".format([sensor_id,pos,quat])) #print("sensor id {0} {1} {2}".format([sensor_id,pos,quat]))
18:
var num_buttons = body.get_32()
var buttons = {}
for i in num_buttons:
var button_id = body.get_32()
var button_state = body.get_32()
buttons[button_id] = button_state
#print("sensor with {0} buttons".format([buttons]))
_: _:
print("unhandled message type {0}".format([message_type])) print("unhandled message type {0}".format([message_type]))

View file

@ -66,7 +66,7 @@ vrpn_Tracker_Spin Tracker0 1 200.0 0.0 1.0 0.0 0.1
# int number_of_buttons # int number_of_buttons
# float rate_at_which_the_buttons_toggle (transitions/second) # float rate_at_which_the_buttons_toggle (transitions/second)
#vrpn_Button_Example Button0 2 2.0 vrpn_Button_Example Button0 2 2.0
################################################################################ ################################################################################
# Example Dial server. This is a "device" that reports constant rotations for # Example Dial server. This is a "device" that reports constant rotations for
@ -1533,19 +1533,19 @@ vrpn_Tracker_Spin Tracker0 1 200.0 0.0 1.0 0.0 0.1
############################################################################## ##############################################################################
# PhaseSpace Impulse system. This device type is not compiled by default, since # PhaseSpace Impulse system. This device type is not compiled by default, since
# it uses a proprietary library. However, you can get it to compile by # it uses a proprietary library. However, you can get it to compile by
# defining VRPN_INCLUDE_PHASESPACE and including the appropriate libraries # defining VRPN_INCLUDE_PHASESPACE and including the appropriate libraries
# and headers when compiling (See vrpn_Configure.h). # and headers when compiling (See vrpn_Configure.h).
# #
# Arguments: # Arguments:
# char tracker_name[] # Tracker0, Tracker1, ... etc # char tracker_name[] # Tracker0, Tracker1, ... etc
# [Additional lines specifying tracker configuration] # [Additional lines specifying tracker configuration]
# #
# The section following the Tracker declaration is a tag delimited set of # The section following the Tracker declaration is a tag delimited set of
# lines which specify system configuration and vrpn sensors. The section begins # lines which specify system configuration and vrpn sensors. The section begins
# with an <owl> tag and ends with a </owl> tag. Each tag must be on a separate # with an <owl> tag and ends with a </owl> tag. Each tag must be on a separate
# line. (see below) # line. (see below)
# #
# Each line in the specification section is a white-space separated set of # Each line in the specification section is a white-space separated set of
# key-value pairs. At most one sensor is defined per line. The sensor and type # key-value pairs. At most one sensor is defined per line. The sensor and type
# keys are mandatory. Other keys are are required based on the type. # keys are mandatory. Other keys are are required based on the type.
@ -1553,8 +1553,8 @@ vrpn_Tracker_Spin Tracker0 1 200.0 0.0 1.0 0.0 0.1
# Comments can be embedded with the '#' character. # Comments can be embedded with the '#' character.
# #
# Example: # Example:
# #
# vrpn_Tracker_PhaseSpace Tracker0 # vrpn_Tracker_PhaseSpace Tracker0
# <owl> # <owl>
# device="192.168.1.1" # device="192.168.1.1"
# frequency=960 # frequency=960
@ -1577,7 +1577,7 @@ vrpn_Tracker_Spin Tracker0 1 200.0 0.0 1.0 0.0 0.1
# ====================== # ======================
# #
# device # device
# A string specifying the IP address of the Impulse server to connect to. # A string specifying the IP address of the Impulse server to connect to.
# #
# frequency # frequency
# A floating-point number specifying the system streaming frequency. # A floating-point number specifying the system streaming frequency.
@ -1592,7 +1592,7 @@ vrpn_Tracker_Spin Tracker0 1 200.0 0.0 1.0 0.0 0.1
# An integer. Set to zero to disable. Specifying 1 for drop_frames will # An integer. Set to zero to disable. Specifying 1 for drop_frames will
# cause the server to drop frames in order to get the most recent data on # cause the server to drop frames in order to get the most recent data on
# every run through the mainloop. This may be desirable for most VR # every run through the mainloop. This may be desirable for most VR
# applications and for slower machines. # applications and for slower machines.
# #
# debug # debug
# An integer. Zero to disable. Specifying 1 for debug will cause the server # An integer. Zero to disable. Specifying 1 for debug will cause the server
@ -1607,7 +1607,7 @@ vrpn_Tracker_Spin Tracker0 1 200.0 0.0 1.0 0.0 0.1
# #
# type # type
# A string which specifies what type the sensor is. Required if sensor is # A string which specifies what type the sensor is. Required if sensor is
# specified. The following types are supported: # specified. The following types are supported:
# point # point
# rigid # rigid
# rigid_body (deprecated) # rigid_body (deprecated)
@ -1619,23 +1619,23 @@ vrpn_Tracker_Spin Tracker0 1 200.0 0.0 1.0 0.0 0.1
# led # led
# An integer which specifies the led id of a sensor. # An integer which specifies the led id of a sensor.
# Required if type is "point". # Required if type is "point".
# #
# pos # pos
# An optional comma-separated list of three floating-point numbers specifying # An optional comma-separated list of three floating-point numbers specifying
# the 3D position of a marker on a rigid body. No spaces. Valid if type is # the 3D position of a marker on a rigid body. No spaces. Valid if type is
# "point". Specifying positions is only valid if the tracker number is set # "point". Specifying positions is only valid if the tracker number is set
# to a rigid body. The units MUST be in millimeters, regardless of scale # to a rigid body. The units MUST be in millimeters, regardless of scale
# setting. # setting.
# #
# init # init
# An optional comma-separated list of four floating-point numbers specifying # An optional comma-separated list of four floating-point numbers specifying
# kalman parameters for a rigid body. Valid if type is "rigid_body". # kalman parameters for a rigid body. Valid if type is "rigid_body".
# #
# #
# For support, questions, comments, or bug reports please send emails # For support, questions, comments, or bug reports please send emails
# to: support@phasespace.com # to: support@phasespace.com
# #
#vrpn_Tracker_PhaseSpace Tracker0 #vrpn_Tracker_PhaseSpace Tracker0
#<owl> #<owl>
#device="192.168.1.230" #device="192.168.1.230"
#frequency=480 #frequency=480
@ -2454,8 +2454,8 @@ vrpn_Tracker_Spin Tracker0 1 200.0 0.0 1.0 0.0 0.1
#vrpn_Tracker_FilterOneEuro Filter0 *Tracker0 2 1.15 1.0 1.2 1.5 5.0 1.2 #vrpn_Tracker_FilterOneEuro Filter0 *Tracker0 2 1.15 1.0 1.2 1.5 5.0 1.2
################################################################################ ################################################################################
# Sensics zSight HMD with built-in tracker. This is an inertial tracker that # Sensics zSight HMD with built-in tracker. This is an inertial tracker that
# gives orientation information, but no position (the tracker reports # gives orientation information, but no position (the tracker reports
# (0, 0, 0) for position). # (0, 0, 0) for position).
# #
# Arguments: # Arguments:
@ -2531,19 +2531,19 @@ vrpn_Tracker_Spin Tracker0 1 200.0 0.0 1.0 0.0 0.1
# To access Polhemus G4 on Windows using the Polhemus PDI library, # To access Polhemus G4 on Windows using the Polhemus PDI library,
# use vrpn_Tracker_G4. # use vrpn_Tracker_G4.
# #
# The vrpn_Tracker_G4 tracker definition requires the tracker name and # The vrpn_Tracker_G4 tracker definition requires the tracker name and
# the vrpn server name for the tracker, followed by an optional Server Poll rate, # the vrpn server name for the tracker, followed by an optional Server Poll rate,
# and on the next line, the file path to the .g4c configuration file: # and on the next line, the file path to the .g4c configuration file:
# #
# vrpn_Tracker_G4 G4 \ # vrpn_Tracker_G4 G4 \
# C:\filepath\source_config_file.g4c # C:\filepath\source_config_file.g4c
# #
# The Server Poll Rate is optional. # The Server Poll Rate is optional.
# If it is not specified, the VRPN server will poll for new data at a rate of 120 frames per second. # If it is not specified, the VRPN server will poll for new data at a rate of 120 frames per second.
# (120 frames per second is the default output rate of G4 hardware.) # (120 frames per second is the default output rate of G4 hardware.)
# #
# If you wish to poll at a slower rate than the tracker, you may specify any number. For example, if # If you wish to poll at a slower rate than the tracker, you may specify any number. For example, if
# you wish to poll 20 times per second, then specify a poll rate of 20. # you wish to poll 20 times per second, then specify a poll rate of 20.
# #
# The '\' at the end of the first line, after the server name, is optional and # The '\' at the end of the first line, after the server name, is optional and
# will be disregarded. A '\' on a subsequent line means that further commands # will be disregarded. A '\' on a subsequent line means that further commands
@ -2774,30 +2774,30 @@ vrpn_Tracker_Spin Tracker0 1 200.0 0.0 1.0 0.0 0.1
# To access Polhemus FasTrak on Windows using the Polhemus PDI library, # To access Polhemus FasTrak on Windows using the Polhemus PDI library,
# use vrpn_Tracker_FastrakPDI. # use vrpn_Tracker_FastrakPDI.
# #
# The vrpn_Tracker_FastrakPDI tracker definition requires the tracker name and # The vrpn_Tracker_FastrakPDI tracker definition requires the tracker name and
# the vrpn server name for the tracker, followed by an optional Server Poll rate: # the vrpn server name for the tracker, followed by an optional Server Poll rate:
# #
# vrpn_Tracker_FastrakPDI myFastrak4 30\ <-valid # vrpn_Tracker_FastrakPDI myFastrak4 30\ <-valid
# vrpn_Tracker_FastrakPDI myFastrak2 60\ <-valid # vrpn_Tracker_FastrakPDI myFastrak2 60\ <-valid
# vrpn_Tracker_FastrakPDI myFastrak1 \ <-valid # vrpn_Tracker_FastrakPDI myFastrak1 \ <-valid
# #
# The Server Poll Rate is optional. # The Server Poll Rate is optional.
# If it is not specified, the VRPN server will poll for new data at a rate of 120 frames per second. # If it is not specified, the VRPN server will poll for new data at a rate of 120 frames per second.
# (120 frames per second is the default output rate of FasTrak hardware with ONE sensor connected.) # (120 frames per second is the default output rate of FasTrak hardware with ONE sensor connected.)
# #
# For FasTrak trackers the update rate depends on the number of sensors connected to the device: # For FasTrak trackers the update rate depends on the number of sensors connected to the device:
# Number of Sensors Update Rate # Number of Sensors Update Rate
# ----------------- ----------- # ----------------- -----------
# 1 120 frames/sec # 1 120 frames/sec
# 2 60 frames/sec # 2 60 frames/sec
# 3 40 frames/sec # 3 40 frames/sec
# 4 30 frames/sec # 4 30 frames/sec
# #
# If you wish to poll at the same rate as the tracker output, then you must specify the poll rate # If you wish to poll at the same rate as the tracker output, then you must specify the poll rate
# to match the update rate in the table above. # to match the update rate in the table above.
# #
# If you wish to poll at a slower rate than the tracker, you may specify any number. For example, if # If you wish to poll at a slower rate than the tracker, you may specify any number. For example, if
# you wish to poll 20 times per second, then specify and update rate of 20. # you wish to poll 20 times per second, then specify and update rate of 20.
# #
# The '\' at the end of the first line, after the server name, is optional and will be disregarded. # The '\' at the end of the first line, after the server name, is optional and will be disregarded.
# a '\' on a subsequent line means that further commands are to be input. The format is to have # a '\' on a subsequent line means that further commands are to be input. The format is to have
@ -2870,7 +2870,7 @@ vrpn_Tracker_Spin Tracker0 1 200.0 0.0 1.0 0.0 0.1
# -collects a second single pno to confirm this removal (P) and # -collects a second single pno to confirm this removal (P) and
# -finally returns to binary mode before passing control to VRPN (F1<>). # -finally returns to binary mode before passing control to VRPN (F1<>).
# The trackers name is TrackerJoe. # The trackers name is TrackerJoe.
# The server poll rate is 120 Hz. # The server poll rate is 120 Hz.
# vrpn_Tracker_FastrakPDI TrackerJoe 120\ # vrpn_Tracker_FastrakPDI TrackerJoe 120\
# PDIStylus 1\ # PDIStylus 1\
@ -2892,7 +2892,7 @@ vrpn_Tracker_Spin Tracker0 1 200.0 0.0 1.0 0.0 0.1
# To access Polhemus Liberty or Patriot on Windows using the Polhemus PDI library, # To access Polhemus Liberty or Patriot on Windows using the Polhemus PDI library,
# use vrpn_Tracker_LibertyPDI. # use vrpn_Tracker_LibertyPDI.
# #
# The vrpn_Tracker_LibertyPDI tracker definition requires the tracker name and # The vrpn_Tracker_LibertyPDI tracker definition requires the tracker name and
# the vrpn server name for the tracker, followed by an optional Server Poll rate: # the vrpn server name for the tracker, followed by an optional Server Poll rate:
# #
# vrpn_Tracker_LibertyPDI MyLiberty 240\ <-valid # vrpn_Tracker_LibertyPDI MyLiberty 240\ <-valid
@ -2901,16 +2901,16 @@ vrpn_Tracker_Spin Tracker0 1 200.0 0.0 1.0 0.0 0.1
# #
# Note that "Tracker_LibertyPDI" is used for both Polhemus Patriot and Liberty tracker hardware! # Note that "Tracker_LibertyPDI" is used for both Polhemus Patriot and Liberty tracker hardware!
# #
# The Server Poll Rate is optional. # The Server Poll Rate is optional.
# If it is not specified, the VRPN server will poll for new data at a rate of 60 frames per second. # If it is not specified, the VRPN server will poll for new data at a rate of 60 frames per second.
# (60 frames per second is the default output rate of Patriot tracker hardware.) # (60 frames per second is the default output rate of Patriot tracker hardware.)
# #
# For Liberty trackers, the default rate is 240 frames per second. If you wish for the server to poll # For Liberty trackers, the default rate is 240 frames per second. If you wish for the server to poll
# at this rate, then you must specify 240! # at this rate, then you must specify 240!
# #
# If you wish to poll at a slower rate than the tracker, you may specify any number. For example, if # If you wish to poll at a slower rate than the tracker, you may specify any number. For example, if
# you wish to poll 20 times per second, then specify and update rate of 20. # you wish to poll 20 times per second, then specify and update rate of 20.
# #
# The '\' at the end of the first line, after the server name, is optional and will be disregarded. # The '\' at the end of the first line, after the server name, is optional and will be disregarded.
# a '\' on a subsequent line means that further commands are to be input. The format is to have # a '\' on a subsequent line means that further commands are to be input. The format is to have
# one command per line. Each line that isn't the final line must end in a '\'. The final line should not # one command per line. Each line that isn't the final line must end in a '\'. The final line should not
@ -2929,7 +2929,7 @@ vrpn_Tracker_Spin Tracker0 1 200.0 0.0 1.0 0.0 0.1
# #
# Note: The R command is used to set the Liberty tracker update rate. This command has no effect on Patriot. # Note: The R command is used to set the Liberty tracker update rate. This command has no effect on Patriot.
# For Liberty, if you use the R command to change the update rate, remember to change the Server Poll Rate # For Liberty, if you use the R command to change the update rate, remember to change the Server Poll Rate
# specification in the tracker definition (like "MyPolhemus" example above). # specification in the tracker definition (like "MyPolhemus" example above).
# Command Syntax: # Command Syntax:
# Every command, except P (gather single pno frame), requires a carriage return on the end. Carriage # Every command, except P (gather single pno frame), requires a carriage return on the end. Carriage
@ -3003,7 +3003,7 @@ vrpn_Tracker_Spin Tracker0 1 200.0 0.0 1.0 0.0 0.1
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# Finally the default config below: # Finally the default config below:
# -May be used for a Liberty or a Patriot tracker # -May be used for a Liberty or a Patriot tracker
# -Polls the tracker 60 times per second # -Polls the tracker 60 times per second
# -Sets tracker output to ASCII # -Sets tracker output to ASCII
# -Queries the tracker for WhoAmI information # -Queries the tracker for WhoAmI information
# -Sets the output back to Binary # -Sets the output back to Binary
@ -3159,7 +3159,7 @@ vrpn_Tracker_Spin Tracker0 1 200.0 0.0 1.0 0.0 0.1
#vrpn_Tracker_DeadReckoning_Rotation Tracker1 *Tracker0 2 0.0333 #vrpn_Tracker_DeadReckoning_Rotation Tracker1 *Tracker0 2 0.0333
################################################################################ ################################################################################
# OSVR Hacker Dev Kit inertial measurement unit. This is an inertial tracker that # OSVR Hacker Dev Kit inertial measurement unit. This is an inertial tracker that
# gives orientation information, but no position. Position values are always # gives orientation information, but no position. Position values are always
# 0. Version 1 of this device sends only poses. Version 2 also sends velocity # 0. Version 1 of this device sends only poses. Version 2 also sends velocity
# reports. # reports.
@ -3170,7 +3170,7 @@ vrpn_Tracker_Spin Tracker0 1 200.0 0.0 1.0 0.0 0.1
#vrpn_Tracker_OSVRHackerDevKit Tracker0 #vrpn_Tracker_OSVRHackerDevKit Tracker0
################################################################################ ################################################################################
# Oculus Rift DK1 and DK2. There are two versions of the DK2 driver, which use the # Oculus Rift DK1 and DK2. There are two versions of the DK2 driver, which use the
# same hardware but in two different modes. # same hardware but in two different modes.
# #
# vrpn_Oculus_DK2_inertial: Oculus DK2 inertial measurement unit only. This # vrpn_Oculus_DK2_inertial: Oculus DK2 inertial measurement unit only. This