Motion Analysis using Accelerometer and Gyroscope Data. Python code for detecting motion events, estimating speed with Kalman Filter. Easily customizable.
This repository contains Python code for analyzing motion data captured from accelerometer and gyroscope sensors. The code performs the following tasks:
- Internet Connection Check: Verifies internet connectivity to install necessary libraries.
- Installing Required Packages: Automatically installs required Python packages (
pandasandnumpy). - Data Processing: Reads accelerometer and gyroscope data from specified folders and calculates magnitude for each sensor reading.
- Motion Detection: Detects start and end timestamps of motion events based on accelerometer and gyroscope thresholds.
- Speed Estimation: Applies Extended Kalman Filter to estimate speed from the motion data.
- Python (3.6+)
- Internet connection (for library installation)
- Clone the repository to your local machine.
- Ensure you have Python and pip installed.
- Run the script:
python main.py
- Adjust thresholds, window size, and Kalman Filter parameters in the code as needed.
- Adjust the threshold and window size for motion detection in the code.
- Customize Extended Kalman Filter parameters (Q, R_accel, R_gyro, etc.) as needed.
The code assumes that the accelerometer and gyroscope data files are stored in folders named 'AA', 'BB', 'CC', ..., 'LL'. You can modify the list folders to match your data folder names.
- Detected timestamps for motion start and end will be saved in CSV files: 'ball_static_timestamps folder.csv' and 'ball_moving_timestamps folder.csv', respectively, for each folder.
- Speed estimates will be saved in 'ball_speed_estimates folder.csv' for each folder.
Note: This code provides a basic implementation for motion analysis. Adjustments may be required based on the specific use case and sensor data characteristics.