02-22-2023, 09:23 AM
You can measure the pose of a tracker using the RoboDK API and MeasurePose. The following function can help you better understand how to use it as you can also read the button state and take the averaged measurement (helps reduce noise).
You can read the state of the buttons using a bitmask.
Also, you can trigger the identification of a tracker to assign it as a Handheld probe, Generic tracker or robot tool by calling the IdentifyTracker command:
Code:
TARGET_TYPE_NONE=-1 # The same as TARGET_TYPE_PROBE
TARGET_TYPE_BASE=0 # Static reference used for world positionning (measurements reference)
TARGET_TYPE_TOOL=1 # Robot tool for robot calibration purposes
TARGET_TYPE_REFERENCE=2 # Moving reference (held by hand)
TARGET_TYPE_PROBE=3 # Generic HTC Vive Tracker used with a probe
TARGET_TYPE_GENERIC=4 # Generic HTC Vive Tracker marked as generic
TARGET_TYPE_CONTROLLER=5 # HTC Vive Controller
...
def MeasurePoseSpecial(target, time_avg_ms=500):
"""Measure a pose of something that moves. target variable must be set to TARGET_TYPE_REFERENCE or TARGET_TYPE_CONTROLLER."""
pose, data = RDK.MeasurePose(target, time_avg_ms)
ntargets = int(数据[0])
buttons = int(data[1]) # important!
#time = int(data[2])
if buttons < 0 or ntargets <= 0:
RDK.ShowMessage("Unable to see target id %s." % str(target), False)
pause(0.5) # gives time to read msg
return None, [-1,-1]
errors = data[2:4]
return pose, errors
You can read the state of the buttons using a bitmask.
Also, you can trigger the identification of a tracker to assign it as a Handheld probe, Generic tracker or robot tool by calling the IdentifyTracker command:
Code:
RDK.Command("IdentifyTracker")