Incorrect data when donwloading logging data
Hello Laura,
I want to log gyroscope and accelerometer from multiple MMC at 800Hz at maximum resolution (16g, 2000rad/s). But when I download the data, the data is obviously wrong. Because the accelerometer does not measure ~1g but another value (often only 0.3g on the z-axis and 0 on all other axis, if it is on a tabel). It is also very often the case that both sensors deliver the same data or every second measuring point is the same. When downloading with the mobile phone app, it works without any problems. This is the code for downloading:
def download_data(device, loggers, logger):
if not device.is_connected:
s_connect(device, logger)
logger.info(f'{device.address} | Downloading data')
t_acc = []
data_acc = []
t_gyro = []
data_gyro = []
e = Event()
def progress_update_handler(context, entries_left, total_entries):
if (entries_left == 0):
e.set()
def data_logger_acc(p):
t_acc.append(p.contents.epoch)
data_acc.append(parse_value(p))
def data_logger_gyro(p):
t_gyro.append(p.contents.epoch)
data_gyro.append(parse_value(p))
callback_acc = FnVoid_VoidP_DataP(lambda ctx, p: data_logger_acc(p))
callback_gyro = FnVoid_VoidP_DataP(lambda ctx, p: data_logger_gyro(p))
fn_wrapper = FnVoid_VoidP_UInt_UInt(progress_update_handler)
download_handler = LogDownloadHandler(context = None,
received_progress_update = fn_wrapper,
received_unknown_entry = cast(None, FnVoid_VoidP_UByte_Long_UByteP_UByte),
received_unhandled_entry = cast(None, FnVoid_VoidP_DataP))
try:
time_start = time.perf_counter()
libmetawear.mbl_mw_logger_subscribe(loggers[0], None, callback_acc)
libmetawear.mbl_mw_logger_subscribe(loggers[1], None, callback_gyro)
libmetawear.mbl_mw_logging_download(device.board, 0,
byref(download_handler))
e.wait()
except ArgumentError as err:
logger.error(f'{device.address} | ArgumentError: {err}')
debug_reset(device, logger)
return (None, None, None, None)
download_time = round(time.perf_counter() - time_start, 5)
logger.info(f'{device.address} | Downloaded data : {download_time}s')
debug_reset(device, logger)
e.clear()
return (t_acc, data_acc, t_gyro, data_gyro)
Comments
What does your setup code look like? Did you setup the 800Hz and correct G range?
This is the code for the setup of the logger. I have also added the code to start and stop.
I am sure I have found the error. The data is still correct in the download hander but as soon as it is finished the data is corrupted. I don't know why, but here is the code: