Best way to get HMD world position in C++?

Looking more into this, it seems you have to add the HMD position rotated by the player pawn rotation:


FQuat DeviceRotation;
FVector DevicePosition;
FVector FinalPosition;

GEngine->XRSystem->GetCurrentPose(IXRTrackingSystem::HMDDeviceId, DeviceRotation, DevicePosition);

APlayerController *PlayerController = UGameplayStatics::GetPlayerController(GetWorld(), 0);
FinalPosition = PlayerController->GetPawn()->GetActorRotation().RotateVector(DevicePosition) + PlayerController->PlayerCameraManager->GetCameraLocation();

myActor->SetActorLocation(FinalPosition);
myActor->SetActorRotation(DeviceRotation);

However, the results are still not quite correct, as there is some kind of rotation offset. I have the camera set to lock to the HMD, so I’m not sure what else I’m missing here.