Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

VR set position problem - python api

#1
Hello Everyone,
I am trying to set the vr position to my station's origin using the ViewPoseVR() from the special commands mentioned in the python api
https://robodk.com/doc/en/PythonAPI/robo...l-commands

I am not too sure how to do this exactly so if someone can help with an example code it would help a ton.

Thanks in advance.
#2
You can get and set the pose of the VR headset by using the ViewPoseVR command and the functions TxyzRxyz_2_Pose and Pose_2_TxyzRxyz respectively.

The input/output parameter is a string, not a list of values. You should also use the [X,Y,Z,rX,rY',rZ''] Euler format.

You can set the VR pose by using this example:
Code:
result = RDK.Command("VR")  # open the VR view
# Take the view pose from the desktop window (pose of the station with respect to the eye):
vp = RDK.ViewPose()
# Calculate the VR view pose (move 2000 along the Z axis of the eye)
vrp = robomath.transl(0, 0, +2000) * vp)
# Convert the pose to a string using Euler TxyzRxyz:
strpose = str(robomath.Pose_2_TxyzRxyz()[1:-1]
result = RDK.Command("ViewPoseVR", strpose)
if result != "OK":
    RDK.ShowMessage("Problems setting VR view: " + result, False)
    quit()
RDK.ShowMessage("Window view sent to VR headset", False)
You can find more examples in the source code of the View Manager Add-in:
https://github.com/RoboDK/Plug-In-Interf...iewManager
#3
Thank you so much for your reply, I can now successfully set the position of my VR headset inside my station.

I still have one small problem, I am trying now to retrieve my current VR view in my station world coordinate frame but I can't figure out how, as of right now I am using the following script, it retrieves the VR view but in a coordinate frame that I don't know but its definitely not the world frame.

Code:
from robolink import *  # API to communicate with RoboDK

RDK = Robolink()

# Get current VR headset pose as a string "(x,y,z,rx,ry,rz)"
pose_str = RDK.Command("ViewPoseVR")
print("Current VR View Pose (string):", pose_str)

# Optionally parse it into numbers
pose_values = [float(v) for v in pose_str.strip("()").split(',')]
print("Parsed VR Pose:", pose_values)

Thank you in advance.
#4
What issues are you having? The code you shared should work. You may want to convert it to a pose by using the TxyzRxyz_2_Pose.
  




Users browsing this thread:
1 Guest(s)