This directory contains examples demonstrating how to use the EXAMPLE-SHM package.
To install the package built using poetry, follow these steps:
poetry buildThis will create a .whl file in the dist/ directory,
e.g., dist/cp_sens-0.1.0-py3-none-any.whl.
python -m venv .venv
source .venv/bin/activate # On Linux/macOS
.\.venv\Scripts\Activate.ps1 # On Windowspip install example_shm-<version>-py3-none-any.whlReplace <version> with the version number found in the .whl
filename. (e.g 0.1.0).
There are 5 examples.
-
acceleration_readings demonstrates the use of
Accelerometerclass to extract accelerometer measurements from MQTT data stream. -
aligning_readings demonstrates the use of
Alignerclass to collect and align accelerometer measurements from multiple MQTT data streams. -
run_pyoma demonstrates the use of
sys_idwith 3 cases:- oma-and-plot: plots natural frequencies.
- oma-and-print: prints OMA results to console.
- oma-and-publish: publishes OMA results via MQTT to the config given under [sysid] config.
-
mode_tracking demonstrates the use of
mode_trackwith 2 cases:- mode-tracking-with-local-sysid: gets the pyOMA results by runing sysid locally, then runs the mode track.
- mode-tracking-with-remote-sysid: gets pyOMA results by subscribing, then runs the mode track.
-
updating_paramteres demonstrates the use of model-update. Gets the mode track output, then uses it to run update model and get updated system parameters.
To run the examples with the default config, use:
python .\src\examples\example.py accelerometers
python .\src\examples\example.py align-readings
python .\src\examples\example.py oma-and-print
python .\src\examples\example.py oma-and-plot
python .\src\examples\example.py oma-and-publish
python .\src\examples\example.py mode-tracking-with-local-sysid
python .\src\examples\example.py mode-tracking-with-remote-sysid
python .\src\examples\example.py model-update-local-sysid
python .\src\examples\example.py model-update-remote-sysid
To run the examples with specified config, use
python .\src\examples\example.py --config .path_to\production.json align-readingsExample,
python .\src\examples\example.py --config .\config\production.json align-readingsThis explains the setup needed to run the distributed version of the example-shm pipeline.
This machine connects to ADXL375 sensors and is responsible for acquiring raw sensor data. It performs calibration and continuously publishes sensor data over MQTT.
Step 1: Run calibration to find sensor offsets
poetry run python src/scripts/find_offset.pyStep 2: Start publishing raw accelerometer data
poetry run python src/scripts/publish_samples.pyThis machine subscribes to MQTT topics from Machine 1. It aligns multi-channel data, runs system identification, and publishes pyOMA results.
Run the aligner and system identification pipeline
poetry run python src/examples/example.py oma-and-publishThis machine subscribes to pyOMA results, performs mode tracking and updates the structural model.
Run mode tracking and model update
poetry run python src/examples/example.py model-update-remote-sysid