IMU Data API Reference
IMUDataSubscriber
Constructor:
IMUDataSubscriber(ip, port=8002, hwm=1, conflate=True, verbose=False)Parameters:
ip(str): iPhone's IP addressport(int): Port number (default: 8002, fixed for IMU data)hwm(int): High water mark (default: 1, keeps only latest message)conflate(bool): Message conflation (default: True)verbose(bool): Print connection info (default: False)
Usage:
# Create IMU subscriber
sub = IMUDataSubscriber("192.168.1.100")
# Continuously receive IMU data
for data in sub:
print(data.accelerometer)
print(data.gyroscope)
# Close when done
sub.close()Main Methods:
Method
Returns
Description
get()
IMUFrame or None
Get latest IMU data frame
get_timestamp()
float or None
Get timestamp only
get_accelerometer()
np.ndarray or None
Get accelerometer only
get_gyroscope()
np.ndarray or None
Get gyroscope only
get_magnetometer()
np.ndarray or None
Get magnetometer only
get_gravity()
np.ndarray or None
Get gravity vector only
get_user_acceleration()
np.ndarray or None
Get user acceleration only
get_attitude()
np.ndarray or None
Get attitude quaternion only
close()
None
Close connection
Note:
The subscriber is iterable, so you can use
for data in sub:to receive frames continuously.All
get_*()methods accept an optionaltimeoutparameter (default: 1000ms).
IMUFrame
Data object returned by get() or when iterating. For data format details and physical meanings, see IMU Data Format Reference above.
Properties:
Property
Type
Description
timestamp
float
Unix timestamp in seconds
accelerometer
np.ndarray
Accelerometer $[a_x, a_y, a_z]$ in G
gyroscope
np.ndarray
Gyroscope $[\omega_x, \omega_y, \omega_z]$ in rad/s
magnetometer
np.ndarray
Magnetometer $[m_x, m_y, m_z]$ in μT
gravity
np.ndarray
Gravity $[g_x, g_y, g_z]$ in G
user_acceleration
np.ndarray
User acceleration $[u_x, u_y, u_z]$ in G
attitude
np.ndarray
Attitude quaternion $[q_x, q_y, q_z, q_w]$
Helper Properties:
Property
Type
Description
has_accelerometer
bool
Check if accelerometer data exists
has_gyroscope
bool
Check if gyroscope data exists
has_magnetometer
bool
Check if magnetometer data exists
has_gravity
bool
Check if gravity data exists
has_user_acceleration
bool
Check if user acceleration exists
has_attitude
bool
Check if attitude data exists
Last updated
Was this helpful?