Showing results for 
Search instead for 
Did you mean: 

Touch Controller Position relative to tracking camera location

Honored Guest

We are working on a project where we want to use the Oculus Camera to track the touch controllers, However. the camera will not be able to see the headset, we are going to mount the camera on the headset pointing outward to track the touch controllers. We need the positions of the touch controllers in the reference frame of the Tracking Camera. It appears that the Oculus SDK/UE4 integration seems to assume you always give the position relative to the headset. Is there any way to get the raw sensor data before the positions and orientations of the Touch Controllers are converted to headset-relative values?

Honored Guest
I figured it out, I think I just had a brainfart. Just in case anyone else wants to get the position & rotation of anything tracked relative to a sensor instead of the headset here is how I did it in C++ (Note make sure the tracking origin is set to floor instead of eye (otherwise you need to subtract the eye height somewhere) 😞

UFUNCTION(BlueprintCallable, Category = "Custom Tracking")
bool GetTouchPositionClean(int32 sensorIndex, FVector &HandOnePosition, FRotator &HandOneRotator, FVector &HandTwoPosition, FRotator &HandTwoRotator)
IOculusRiftPlugin& OculusRiftPlugin = IOculusRiftPlugin::Get();

ovrTrackingState OvrTrackingState;

const bool bOvrGCTRes = OculusRiftPlugin.GetCurrentTrackingState(&OvrTrackingState);

if (GEngine != nullptr)
float notNeeded = 0;

FQuat sensorQ;
FVector sensorPosition;

bool foundSensor = GEngine->HMDDevice->GetTrackingSensorProperties(sensorIndex, sensorPosition, sensorQ, notNeeded, notNeeded, notNeeded, notNeeded, notNeeded, notNeeded, notNeeded);

FRotator sensorRotation = sensorQ.Rotator();
sensorRotation.Pitch = 0.0f;
sensorRotation.Roll = 0.0f;

FQuat hand1Quat;
FQuat hand2Quat;

//left touch controller
OculusRiftPlugin.PoseToOrientationAndPosition(OvrTrackingState.HandPoses[0].ThePose, hand1Quat, HandOnePosition);

//right touch controller
OculusRiftPlugin.PoseToOrientationAndPosition(OvrTrackingState.HandPoses[1].ThePose, hand2Quat, HandTwoPosition);

HandOneRotator = hand1Quat.Rotator();
HandTwoRotator = hand2Quat.Rotator();

HandOnePosition -= sensorPosition;
HandTwoPosition -= sensorPosition;

HandOnePosition = sensorRotation.UnrotateVector(HandOnePosition);
HandTwoPosition = sensorRotation.UnrotateVector(HandTwoPosition);

HandOneRotator = HandOneRotator + sensorRotation.GetInverse();
HandTwoRotator = HandTwoRotator + sensorRotation.GetInverse();


return true;

Honored Guest
Is there a solution to this if i want to get touch position relative to the camera in the Oculus SDK without Unreal?