I am starting to work with the Qwiic IMU icm20948 and using the python code example on the GitHub page. The part of the code that displays the readings is shown below. Either I need to cast the raw data to a different type, or there is an issue with the readings because they don’t make physical sense.
In the library for the sensor, there are functions and comments about taking the 16 bit unsigned integer values and changing them to 32 bit signed integers for python. Is this the print out format I’m seeing (example attached)? How to I convert to physical real-world values?
The columns are raw Ax, Ay, Az, Gx, Gy, Gz, Mx, My, Mz, and Temperature
**** Example code snippet *****
while True:
if IMU.dataReady():
IMU.getAgmt() # read all axis and temp from sensor, note this also updates all instance variables
print(\
‘{: 06d}’.format(IMU.axRaw)\
, ‘\t’, ‘{: 06d}’.format(IMU.ayRaw)\
, ‘\t’, ‘{: 06d}’.format(IMU.azRaw)\
, ‘\t’, ‘{: 06d}’.format(IMU.gxRaw)\
, ‘\t’, ‘{: 06d}’.format(IMU.gyRaw)\
, ‘\t’, ‘{: 06d}’.format(IMU.gzRaw)\
, ‘\t’, ‘{: 06d}’.format(IMU.mxRaw)\
, ‘\t’, ‘{: 06d}’.format(IMU.myRaw)\
, ‘\t’, ‘{: 06d}’.format(IMU.mzRaw)\
, ‘\t’, ‘{: 06d}’.format(IMU.tmpRaw)\
)
time.sleep(0.03)