MLC device settings
for MLC target, based on ST Edge AI Core Technology 2.2.0
Overview
With the generate
command, ST Edge AI Core
offers the possibility of either extracting features from data logs
(emulating MLC computations) or generating the final sensor
configuration; this is done by specifying the
--gen-type
argument with the keyword
features
for the former, or config
for the
latter. Additionally, the command also requires the user to provide
an MLC device settings file with the
--settings
argument that contains common information
for both features and sensor configuration generation, and specific
information required only to do one of the two.
Note: The same MLC device settings file can be used both for extracting the features and generating the sensor configuration, fields that are not needed for one of the two operations are simply ignored.
MLC generation script format
Fields for features and configuration generation
name: MLC-compatible device name
{ "name": "LSM6DSV16X" }
mlc_odr: MLC output rate (Hz) (see Device-specific settings)
{ "mlc_odr": "30 Hz" }
input_type: MLC input type (see Device-specific settings)
{ "input_type": "accelerometer_only" }
<input_name>_fs: Sensor full-scale range (see Device-specific settings)
{"accelerometer_fs": "8 g" }
<input_name>_odr: Sensor output data rate (Hz) (see Device-specific settings)
{ "accelerometer_odr": "30 Hz" }
<ext_name>_sensitivity (optional): External sensor sensitivity written as a 4-digits hex value (<ext_unit>/LSB) (see Device-specific settings)
{ "ext_sensitivity": "3C00" }
Note: this value represents a half-precision floating-point number:
SEEEEEFFFFFFFFFF
(S
: 1 sign bit;E
: 5 exponent bits;F
: 10 fraction bits)decision_tree_count: Number of decision trees (#trees) (see Device-specific settings)
{ "decision_tree_count": 1 }
window_length: Buffer length for features computation (#samples), choose a value between 1 and 255
{ "window_length": 60 }
filters (optional): List of filter objects, each specifying the following fields:
- filter_id: Unique filter name to be used as suffix to feature input field. Must be in the form “filter_<num>” where num is the identifier of the filter.
- filter_type: Filter type name.
- input: Filter input name in the form <input_name>_<axis_name> (see Device-specific settings).
{ "filters": [ { "filter_id": "filter_1", "filter_type": "BP", "input": "Acc_V2", "a2": "-1.66", "a3": "0.81", "gain": "0.09" }, "..." ] }
Note: Depending on the filter_type value, filter objects may require extra fields (see Device-specific settings)
features: List of feature objects, each specifying the following fields:
- feature_name: Feature name (see Device-specific settings).
- input: Feature input name in the form <input_name>_<axis_name> to use raw input data or <input_name>_<axis_name>_<filter_id> to use filtered input data (see Device-specific settings).
- signed: Boolean flag to specify feature signedness.
{ "features": [ { "feature_name": "MEAN", "input": "Acc_V2" }, { "feature_name": "MEAN", "input": "Acc_V2_filter_1" }, { "feature_name": "VARIANCE", "input": "Acc_V2" }, { "feature_name": "VARIANCE", "input": "Acc_V2_filter_1" }, { "feature_name": "ENERGY", "input": "Acc_V2" }, { "feature_name": "ENERGY", "input": "Acc_V2_filter_1" }, { "feature_name": "PEAK_TO_PEAK", "input": "Acc_V2" }, { "feature_name": "PEAK_TO_PEAK", "input": "Acc_V2_filter_1" }, "..." ] }
Note: Depending on the feature_name value, feature objects may require extra fields (see Device-specific settings)
Fields for features generation only
datalogs: List of data log objects, each specifying the following fields:
- filename: Input path of data log file.
- label: Class name (multiple logs may share the same value).
{ "datalogs": [ { "filename": "path/to/workspace/data/stationary.csv", "label": "stationary" }, { "filename": "path/to/workspace/data/walking.csv", "label": "walking" }, { "filename": "path/to/workspace/data/cycling.csv", "label": "cycling" }, { "filename": "path/to/workspace/data/running.csv", "label": "running" }, "..." ] }
features_output_filename: Output file path for computed features in .arff format
{ "features_output_filename": "/path/to/workspace/features.arff" }
Fields for configuration generation only
dectree_features (optional): An ordered list of custom feature names used by the decision trees corresponding to the hardware ones configured in the features field. Note that if not specified, it is assumed that decision trees will use feature names defined in the .arff file generated before.
{ "dectree_features": [ "F1_MEAN_ACC_V2", "F2_MEAN_ACC_V2_FILTER_1", "F3_VARIANCE_ACC_V2", "F4_VARIANCE_ACC_V2_FILTER_1", "F5_ENERGY_ACC_V2", "F6_ENERGY_ACC_V2_FILTER_1", "F7_PEAK_TO_PEAK_ACC_V2", "F8_PEAK_TO_PEAK_ACC_V2_FILTER_1", "..." ] }
dectrees: A list of decision tree objects, each specifying the following fields:
- filename: Input file path of decision tree in Weka format.
- results: Mappings of class names to integer values.
- metaclassifier: List of metaclassifier end counter thresholds.
{ "dectrees": [ { "filename": "/path/to/workspace/dectree.txt", "results": [ { "label": "stationary", "value": 1 }, { "label": "walking", "value": 4 }, { "label": "cycling", "value": 8 }, { "label": "running", "value": 12 }, ], "metaclassifier": [ 2, 2, 2, 2 ] }, "..." ] }
config_output_filename: Output file path for sensor configuration in .json format
{ "config_output_filename": "/path/to/workspace/mlc_conf.json" }
Device-specific settings
Depending on the specific MLC-compatible device, specifications
and settings may vary quite a lot. In order to use the
generate
command and create a valid configuration for a
given device, the user must be aware of the available settings to
properly write the MLC device settings file.
For more information please follow the link corresponding to the target MLC-compatible device below:
- MLC settings for ASM330LHB
- MLC settings for ASM330LHBG1
- MLC settings for ASM330LHHX
- MLC settings for ASM330LHHXG1
- MLC settings for IIS2DULPX
- MLC settings for IIS2ICLX
- MLC settings for ISM6HG256X
- MLC settings for ISM330BX
- MLC settings for ISM330DHCX
- MLC settings for LIS2DUX12
- MLC settings for LIS2DUXS12
- MLC settings for LSM6DSO32X
- MLC settings for LSM6DSOX
- MLC settings for LSM6DSRX
- MLC settings for LSM6DSV16BX
- MLC settings for LSM6DSV16X
- MLC settings for LSM6DSV32X
- MLC settings for LSM6DSV80X
- MLC settings for LSM6DSV320X
- MLC settings for ST1VAFE3BX
- MLC settings for ST1VAFE6AX
Complete example
{
"datalogs": [
{ "filename": "/path/to/workspace/data/stationary.csv", "label": "stationary" },
{ "filename": "/path/to/workspace/data/walking.csv", "label": "walking" },
{ "filename": "/path/to/workspace/data/cycling.csv", "label": "cycling" },
{ "filename": "/path/to/workspace/data/running.csv", "label": "running" },
"..."
],
"name": "LSM6DSV16X",
"mlc_odr": "30 Hz",
"input_type": "accelerometer_only",
"accelerometer_fs": "8 g",
"accelerometer_odr": "30 Hz",
"decision_tree_count": 1,
"window_length": 60,
"filters": [
{ "filter_id": "filter_1", "filter_type": "BP", "input": "Acc_V2", "a2": "-1.66", "a3": "0.81", "gain": "0.09" },
"..."
],
"features": [
{ "feature_name": "MEAN", "input": "Acc_V2" },
{ "feature_name": "MEAN", "input": "Acc_V2_filter_1" },
{ "feature_name": "VARIANCE", "input": "Acc_V2" },
{ "feature_name": "VARIANCE", "input": "Acc_V2_filter_1" },
{ "feature_name": "ENERGY", "input": "Acc_V2" },
{ "feature_name": "ENERGY", "input": "Acc_V2_filter_1" },
{ "feature_name": "PEAK_TO_PEAK", "input": "Acc_V2" },
{ "feature_name": "PEAK_TO_PEAK", "input": "Acc_V2_filter_1" },
"..."
],
"dectree_features": [
"F1_MEAN_ACC_V2",
"F2_MEAN_ACC_V2_FILTER_1",
"F3_VARIANCE_ACC_V2",
"F4_VARIANCE_ACC_V2_FILTER_1",
"F5_ENERGY_ACC_V2",
"F6_ENERGY_ACC_V2_FILTER_1",
"F7_PEAK_TO_PEAK_ACC_V2",
"F8_PEAK_TO_PEAK_ACC_V2_FILTER_1",
"..."
],
"dectrees": [
{
"filename": "/path/to/workspace/dectree.txt",
"results": [
{ "label": "stationary", "value": 1 },
{ "label": "walking", "value": 4 },
{ "label": "cycling", "value": 8 },
{ "label": "running", "value": 12 },
],
"metaclassifier": [ 2, 2, 2, 2 ]
},
"..."
],
"features_output_filename": "/path/to/workspace/features.arff",
"config_output_filename": "/path/to/workspace/mlc_conf.json"
}