Imu#
- class pyCGM2.IMU.imu.Imu(freq: int, accel: ndarray | None, angularVelocity: ndarray | None, mag: ndarray | None)#
The IMU class represents an Inertial Measurement Unit (IMU) sensor.
- Parameters:
freq (int) – Sampling frequency of the IMU data.
accel (Optional[np.ndarray]) – Acceleration data from the IMU, represented as a NumPy array.
angularVelocity (Optional[np.ndarray]) – Angular velocity data from the IMU, represented as a NumPy array.
mag (Optional[np.ndarray]) – Magnetometer data from the IMU, represented as a NumPy array.
- __init__(freq: int, accel: ndarray | None, angularVelocity: ndarray | None, mag: ndarray | None)#
Initializes the Imu class with the specified frequency, acceleration data, angular velocity data, and magnetometer data.
Methods
__init__(freq, accel, angularVelocity, mag)Initializes the Imu class with the specified frequency, acceleration data, angular velocity data, and magnetometer data.
downsample([freq])Downsample IMU data to a specified frequency.
getAcceleration([axis])Returns acceleration data.
getAngleAxis([axis])Returns angle axis (equivalent to global angle) data.
getAngularVelocity([axis])Returns angular velocity data.
getMagnetometer([axis])Returns magnetometer data.
getMotion([index])Returns motion data.
getMotionValues([type])Return the orientation of the IMU over time.
Returns quaternion data representing the orientation of the IMU.
reInit()Restore initial values of IMU sensor data.
update(newAccelValues, newOmegaValues, ...)Update IMU with new data.
- downsample(freq: int = 400)#
Downsample IMU data to a specified frequency.
- Parameters:
freq (int, optional) – Target frequency for downsampling. Defaults to 400 Hz.
- getAcceleration(axis=None)#
Returns acceleration data.
- Parameters:
axis (Optional[str], optional) – Specific axis (‘X’, ‘Y’, or ‘Z’) for which acceleration data is required. Defaults to None.
- Returns:
np.ndarray – Acceleration data for the specified axis or all axes.
- getAngleAxis(axis=None)#
Returns angle axis (equivalent to global angle) data.
- Parameters:
axis (Optional[str], optional) – Specific axis (‘X’, ‘Y’, or ‘Z’) for which angle axis data is required. Defaults to None.
- Returns:
np.ndarray – Angle axis data for the specified axis or all axes.
- getAngularVelocity(axis=None)#
Returns angular velocity data.
- Parameters:
axis (Optional[str], optional) – Specific axis (‘X’, ‘Y’, or ‘Z’) for which angular velocity data is required. Defaults to None.
- Returns:
np.ndarray – Angular velocity data for the specified axis or all axes.
- getMagnetometer(axis=None)#
Returns magnetometer data.
- Parameters:
axis (Optional[str], optional) – Specific axis (‘X’, ‘Y’, or ‘Z’) for which magnetometer data is required. Defaults to None.
- Returns:
np.ndarray – Magnetometer data for the specified axis or all axes.
- getMotion(index: int | None = None)#
Returns motion data. If an index is provided, returns the motion data at the specified index.
- Parameters:
index (Optional[int], optional) – Index for which motion data is required. Defaults to None.
- Returns:
List[Frame] or Frame – Motion data for all frames or a specific frame at the given index.
- getMotionValues(type='rotationMatrix') ndarray#
Return the orientation of the IMU over time.
- Parameters:
type (str, optional) – Representation of the orientation:
"rotationMatrix"(9 columns),"quaternion"(4 columns) or"angleAxis". Defaults to"rotationMatrix".- Returns:
np.ndarray – Orientation values (one row per frame).
- getQuaternions()#
Returns quaternion data representing the orientation of the IMU.
- Returns:
np.ndarray – Quaternion data for each frame.
- reInit()#
Restore initial values of IMU sensor data.
- update(newAccelValues: ndarray, newOmegaValues: ndarray, newMagValues: ndarray)#
Update IMU with new data.
- Parameters:
newAccelValues (np.ndarray) – New acceleration data.
newOmegaValues (np.ndarray) – New angular velocity data.
newMagValues (np.ndarray) – New magnetometer data.