Open apurv1305 opened 3 years ago
Hi, to change the rotation of the controller, you need to add the following to the GetPos function: If you are using Euler angles:
inline vr::HmdQuaternion_t EulerAngleToQuaternion(double Yaw, double Pitch, double Roll)
{
vr::HmdQuaternion_t q;
// Abbreviations for the various angular functions
double cy = cos(Yaw * 0.5);
double sy = sin(Yaw * 0.5);
double cp = cos(Pitch * 0.5);
double sp = sin(Pitch * 0.5);
double cr = cos(Roll * 0.5);
double sr = sin(Roll * 0.5);
q.w = cr * cp * cy + sr * sp * sy;
q.x = sr * cp * cy - cr * sp * sy;
q.y = cr * sp * cy + sr * cp * sy;
q.z = cr * cp * sy - sr * sp * cy;
return q;
}
pose.qRotation = EulerAngleToQuaternion(yourRoll, -yourYaw, yourPitch);
If you are using quaternions, then simply assign the quaternion.
To change the position, change the values (X, Y, Z):
pose.vecPosition[0] = 0.02;
pose.vecPosition[1] = 0.001;
pose.vecPosition[2] = 0.001;
Thanks for your explanation of the OpenVR architecture, it's really very helpful.
I was trying to write a sample driver inspired by your explanation to the OpenVR APIs. I am trying to write a driver for a custom VR controller and want to write Rotational and Positional data for the same by reading the serial port.
My Question was how could I write both positional and rotational data for the controller in the driver.
Thank You.