How to get head position and orientation from Nreal Light

How to access Imu data from nreal light. we are trying to get head position and orientation as it moves.

1 Like

For the current head pose, you can use the following:

var headPose = NRFrame.HeadPose;
var position = headPose.position;
var rotation = headPose.rotation;

Thanks a lot mgrayson. that answers the query.

is there any documentation which covers all this?

1 Like

Hi, the IMU data cannot be accessed in the current NRSDK. Sorry about it.

is NRFrame.HeadPose enough for getting the head rotation information in the range of [0,360] ? or that information can only be received from imu?

Hey @shivlal12345 HeadPose is all you need to get the head rotation. IMU data not required. Docs are here:
NRSDK Coordinate Systems - NRSDK (gitbook.io)

@anyone
Does NRFrame.HeadPose work with 3DoF Nreal Air or is it for 6DoF Nreal Light only?

@XREAL-dev
Will NRFrame.HeadPose be avialable in Windows SDK?
Does Nebula have to be running on Windows in order to use NRFrame.HeadPose or is it sufficient just to install the SDK and create own app independent of Nebula?

Hi nrealdev,

we are using HeadPos.rotation to rotate unity object with head movement. but its rotating continuously without moving head/glasses. how do set rotation to rotate unity object with head?

Maybe you can just set the Object as child of NRCameraRig, then it will follow the rotation and movement of the head.

Hi,

setting object as child of nrcamerarig is one way of doing it. I was able to do it by without making it a child of camera in microsoft hololens. why can’t I use camera rotation as offset and use it to rotate object? is nreal more advanced than microsoft hololens? please stick to what I asked. i am aware of parent and child node.

1 Like

OK, sorry for not giving the answer you wanted. Maybe you can use the following codes to realize that on your Object:

public class FollowCamera : MonoBehaviour
{
[SerializeField] private Transform _cameraTransform;
[SerializeField] private float _speed = 2f;
[SerializeField] private float _distance = 1f;

private void Update()
{
    Vector3 direction = Vector3.ProjectOnPlane(_cameraTransform.forward, Vector3.up).normalized;
    Vector3 targetPosition = _cameraTransform.position + (direction * _distance);
    Quaternion targetRotation = Quaternion.LookRotation(direction);

    float t = Time.deltaTime * _speed;
    Vector3 position = Vector3.Lerp(transform.position, targetPosition, t);
    Quaternion rotation = Quaternion.Lerp(transform.rotation, targetRotation, t);
    transform.SetPositionAndRotation(position, rotation);
}

}

Hi,

Thanks for the code.
Can we use NRFrame.HeadPose.rotation in place of target rotation in the following line of code? does headpos.rotation returns the same value?
Quaternion rotation = Quaternion.Lerp(transform.rotation, targetRotation, t);

The Quaternion returns different values. The HeadPose returns the device pose (the NRCameraRig object). Please try to print the real-time values of HeadPose.rotation and check if the values change a lot when the glass doesn’t move.

Hi,

public class FollowCamera : MonoBehaviour
{
[SerializeField] private Transform _cameraTransform;
[SerializeField] private float _speed = 2f;
[SerializeField] private float _distance = 1f;

private void Update()
{
    Vector3 direction = Vector3.ProjectOnPlane(_cameraTransform.forward, Vector3.up).normalized;
    Vector3 targetPosition = _cameraTransform.position + (direction * _distance);
    Quaternion targetRotation = Quaternion.LookRotation(direction);

    float t = Time.deltaTime * _speed;
    Vector3 position = Vector3.Lerp(transform.position, targetPosition, t);
    Quaternion rotation = Quaternion.Lerp(transform.rotation, targetRotation, t);
    transform.SetPositionAndRotation(position, rotation);
}

}

this code is not working. object is always stationary. our idea was rotate it independently using headpos.rotation as offset. we are doing it like this.

our initial object rotation matrix parameters are (90,0, 0) and we are setting target transform rotation like this.
transform.eulerAngles = new Vector3(90, headpos.rotation.y, 0);

the above method was working on other hololens.