Skip to content

Commit

Permalink
Merge pull request #47 from paulijosey/fix/imuData
Browse files Browse the repository at this point in the history
fix IMU data properties
  • Loading branch information
dourvaris authored Apr 19, 2024
2 parents 56ce44b + 8c70349 commit bd2f12b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/pupil_labs/realtime_api/streaming/imu.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import datetime
import logging
import typing as T

Expand All @@ -24,9 +25,16 @@ class IMUData(T.NamedTuple):
gyro_data: Data3D
accel_data: Data3D
quaternion: Quaternion
timestamp_unix_nanoseconds: float
timestamp_unix_seconds: float

@property
def datetime(self):
return datetime.datetime.fromtimestamp(self.timestamp_unix_seconds)

@property
def timestamp_unix_ns(self):
return int(self.timestamp_unix_seconds * 1e9)


def IMUPacket_to_IMUData(imu_packet: ImuPacket) -> IMUData:
gyro_data = Data3D(
Expand All @@ -49,7 +57,6 @@ def IMUPacket_to_IMUData(imu_packet: ImuPacket) -> IMUData:
gyro_data=gyro_data,
accel_data=accel_data,
quaternion=quaternion,
timestamp_unix_nanoseconds=imu_packet.tsNs,
timestamp_unix_seconds=imu_packet.tsNs / 1e9,
)
return imu_data
Expand Down

0 comments on commit bd2f12b

Please sign in to comment.