Skip to content

Stream IMU Data

Neon +1.1.2

Data generated by the IMU can be received using the device.receive_imu_datum method. It returns a UTC timestamp in seconds, the head pose as a quaternion, gyro data, and accelerometer data as follows.

IMUData(
    gyro_data=Data3D(x=-0.1659393310546875, y=-0.1964569091796875, z=0.1735687255859375),
    accel_data=Data3D(x=-0.02880859375, y=-0.224609375, z=1.0068359375),
    quaternion=Quaternion(x=-0.06114135682582855, y=-0.090116947889328, z=0.8700147271156311, w=0.48084819316864014),
    timestamp_unix_seconds=1744297102.1941311
)
IMUData

IMUData

Bases: NamedTuple

Data from the Inertial Measurement Unit (IMU).

Contains gyroscope, accelerometer, and rotation data from the IMU sensor.

Attributes:

accel_data instance-attribute

accel_data: Data3D

Accelerometer data in m/s².

datetime property

datetime: datetime

Get timestamp as a datetime object.

gyro_data instance-attribute

gyro_data: Data3D

Gyroscope data in deg/s.

quaternion instance-attribute

quaternion: Quaternion

Rotation represented as a quaternion.

timestamp_unix_nanoseconds property

timestamp_unix_nanoseconds: int

Get timestamp in nanoseconds since Unix epoch.

Deprecated

This class property is deprecated and will be removed in future versions. Use timestamp_unix_ns() instead.

timestamp_unix_ns property

timestamp_unix_ns: int

Get timestamp in nanoseconds since Unix epoch.

timestamp_unix_seconds instance-attribute

timestamp_unix_seconds: float

Timestamp in seconds since Unix epoch.

Check the whole example code here
stream_imu.py
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
from pupil_labs.realtime_api.simple import discover_one_device

# Look for devices. Returns as soon as it has found the first device.
print("Looking for the next best device...")
device = discover_one_device(max_search_duration_seconds=10)
if device is None:
    print("No device found.")
    raise SystemExit(-1)

# device.streaming_start()  # optional, if not called, stream is started on-demand
try:
    while True:
        print(device.receive_imu_datum())
except KeyboardInterrupt:
    pass
finally:
    print("Stopping...")
    # device.streaming_stop()  # optional, if not called, stream is stopped on close
    device.close()  # explicitly stop auto-update