BUG modifying an existing data processor
When I create a data processor chain using raw gyroscope data as the source, modification of some data processor parameters (e.g. the threshold value of a pulse data processor, or the boundary value of a comparator data processor) is buggy.
MetaMotionR sensor (Firmware 1.5.0, MetaWear iOS SDK 3.4.0).
The data processor chain:
1. Raw gyroscope data, signal retrieved by mbl_mw_gyro_bmi160_get_rotation_data_signal
2. RSS, created by mbl_mw_dataprocessor_rss_create
3. Passthrough, created by mbl_mw_dataprocessor_passthrough_create(rssProcessor, MBL_MW_PASSTHROUGH_MODE_CONDITIONAL, 1)
, needed for the app to disable this chain when certain conditions are met. (I believe this data processor is irrelevant for the bug. Noted here for completeness, and just in case.)
4. Pulse, created by mbl_mw_dataprocessor_pulse_create(MBL_MW_PULSE_OUTPUT_ON_DETECTION, 250, 15)
This works as expected: it doesn't detect tiny movements of the sensor, but it detects a greater rotation and produces output.
However, as soon as I call mbl_mw_dataprocessor_pulse_modify(pulseProcessor, 250, 15)
- notice that I'm using the same threshold
and width
parameters as when creating the data processor - it detects any minuscule movement of the sensor.
I've debugged into mbl_mw_dataprocessor_pulse_create
and mbl_mw_dataprocessor_pulse_modify
to see if there's any visible difference. Here's the relevant line of code in mbl_mw_dataprocessor_pulse_create
: https://github.com/mbientlab/MetaWear-SDK-Cpp/blob/master/src/metawear/processor/cpp/dataprocessor_config.cpp#L593
The value of source->converter
is FirmwareConverter::BMI160_ROTATION
, and scaled_rotation
is 4100
for threshold=250
. (And it works as expected in this case.)
In mbl_mw_dataprocessor_pulse_modify
(https://github.com/mbientlab/MetaWear-SDK-Cpp/blob/master/src/metawear/processor/cpp/dataprocessor_config.cpp#L609) however, pulse->converter
is FirmwareConverter::DEFAULT
and scaled_threshold
is 250
, for threshold=250
.
Probably not correct.
Please advise how to proceed with getting this functionality of the MetaWear SDK working.
Comments
This is a bug in the SDK that we'll fix.
converter should be default for on_detect:
https://github.com/mbientlab/MetaWear-SDK-Cpp/blob/master/src/metawear/processor/cpp/dataprocessor.cpp#L255
but when modifying the processor, it should use its input's converter
There's a corner case where the intended fix does not work with deserialization:
https://github.com/mbientlab/MetaWear-SDK-Cpp/blob/0.18.4/test/test_metawearboard.py#L777
For now, you can manually scale the value passed into
mbl_mw_dataprocessor_pulse_modify
. The actual scale factor will depend what the current gyro data range is.https://github.com/mbientlab/MetaWear-SDK-Cpp/blob/master/src/metawear/sensor/cpp/gyro_bmi160.cpp#L31
Yep, it's what I do now. Please post a note here when I can remove the scale from our end.