The data from the onboard IMU can be accessed through the IMU
object in the Plink
object.
imu = plink.imu
The IMU
object provides the raw IMU data from the gyroscope, accelerometer, and magnetometer.
gyro = imu.gyro
accel = imu.accel
mag = imu.mag
The data is returned as numpy.ndarray
objects, each containing 3 elements corresponding to the x, y, and z axes. The coordinate frame is on the MotorGo board. The gyroscope data is in rad/s, the accelerometer data is in m/s^2, and the magnetometer data is in uT.
In addition to the raw data, the MotorGo Python API filters the IMU data to compute the orientation of the MotorGo relative to the Earth’s gravity vector. You can access the orientation of the Plink board as a quaternion:
orientation = imu.orientation # Returns a numpy.ndarray containing [w, x, y, z]
You can also read the gravity vector, relative to the MotorGo board, as a numpy.ndarray containing [x, y, z]:
gravity_vector = imu.gravity_vector