Skip to content

Conversation

@Bol-C14
Copy link

@Bol-C14 Bol-C14 commented Apr 3, 2025

πŸ›°οΈ Pull Request β€” Indoor Positioning Project Contribution

Author: Shu Gu
Team Members: Lin Chen, Lai Gan, Aaniket Nayak
Date: April 3, 2025


πŸš€ Summary

This PR introduces the following major improvements and extensions to the PositionMe app, in response to the assignment requirements:

  1. βœ… Integration of WiFi Positioning Module
  2. ✨ New Fusion Engine using EKF and Particle Filter
  3. πŸ—ΊοΈ Redesigned Display Page, with real-time fusion visualization and multi-source overlays

These contributions significantly improve both the positioning accuracy and user experience of the app.


πŸ“¦ What’s New

1. βœ… Integrated: WiFi Positioning Module for #17

  • Added real-time WiFi position overlay with icon
  • Added logic to detect repeated scans (WiFi throttling mitigation)
  • ML-based estimator (optional)

2. ✨ New: Fusion Engine

Implemented sensor fusion combining:

  • πŸ“‘ GNSS (from device sensor)
  • πŸ“Ά WiFi (via openpositioning API)
  • 🦢 PDR (step length + orientation)

Two fusion modes are implemented:

Both are coordinated through the SensorFusion.java class:

  • Dynamic fallback between EKF and PF based on uncertainty (entropy-based decision)
  • Auto-initialization from GNSS or latest WiFi updates
  • Support coordinate transforms (WGS84 β†’ ENU)

Code files modified/added:

  • SensorFusion.java
  • EKF.java
  • ParticleFilter.java
  • DomainUtils.java

3. πŸ—ΊοΈ Updated: Data Display and Tracking

  • Real-time fused trajectory shown in green, GNSS in blue, WiFi in yellow, PDR in red, all can be switched on/off for Live Positioning Data displayΒ #25 see TrajectoryMapFragment.java
  • New info slide-able panel: live sensor and fusion data which can view while using the map see StatusBottomSheetFragment.java
  • New smooth trajectory filter for Improve the estimation of the direction of movementΒ #4 see SmoothingFilter.java
  • Tagging system: allows manual calibration point insertion and dragging, with extra floor / state tagging and text tag adding Tagging functionalityΒ #27 see CalibrationFragment.java (Not implemented with protobuf due limited time constraints and ML training requirement, but can be easily migrated)
  • During tagging, fetch all sensor data, position data and store them under /download folder using .json for Improve file savingΒ #1 see DataFileManager.java and SensorFusionUtils.java
  • Computing absolute accuracy when tagging with true position
  • Accuracy circles shown per update (for GNSS)
  • Region of Interest Icons (like emergency exit, washroom, medication station, etc.)
  • Indoor map switch on / off when going indoor / outdoor

🧠 Notes

  • The new ML model (tflite) is used optionally (validated accuracy is about 6 meters indoor, this low accuracy is due to limited data gathering in time constraints) and included in /assets
  • Offline alignment & training scripts included in machine_learning/

πŸ“Ž Checklist

Component Status
WiFi Positioning βœ… Integrated
Positioning Fusion (EKF/PF) βœ… Done
Data Display Update βœ… Done
Tagging + Calibration Anchors βœ… Done
Accuracy Visualization (Optional) βœ… Done

πŸ“Έ Screenshots

1743716429805

1743716429759

1743716429870

image

image

Bol-C14 and others added 30 commits March 13, 2025 17:06
Added WiFi-based EKF update to refine PDR trajectory.
Updated `updateFusionWifi()` to convert WiFi location to ENU and apply EKF correction.
Added WiFi-based EKF update to refine PDR trajectory.
Updated `updateFusionWifi()` to convert WiFi location to ENU and apply EKF correction.
- Investigated issue where WiFi fingerprint sent to server remained unchanged
- Verified WifiDataProcessor was not calling startScan() properly
- Confirmed BroadcastReceiver was registered and scanning timer active
- Checked wifiScanReceiver and verified it was receiving results correctly
- Found that avgRssi in SensorFusion.updateFusion() was always hardcoded to -70
- Refactored SensorFusion#createWifiPositioningRequest to accept real-time RSSI
- Updated update(Object[] wifiList) to calculate and pass avgRssi dynamically
- Ensured updateFusion uses correct avgRssi from latest WiFi scan results
- Improved EKF update precision based on realistic WiFi signal strength
This commit introduces the `CollectionActivity` and `CollectionFragment` to support passive sensor data collection and calibration.

- `CollectionActivity`:
  - Collects sensor data using SensorFusion (IMU, GNSS, PDR, WiFi).
  - Stores data in a buffer and flushes to a JSON file in the public Downloads folder.
  - Handles calibration triggers from `CollectionFragment`.
  - Manages file output (MediaStore for API >= Q, File API for older).
  - Includes logic for sensor update loop and data flushing.
- `CollectionFragment`:
  - Displays a `TrajectoryMapFragment` for location updates.
  - UI for calibration: marker placement, floor level, indoor state, building name.
  - Triggers calibration via the parent's `onCalibrationTriggered` method.
  - Uses spinners for floor level and indoor state, EditText for building name.
- `TrajectoryMapFragment`:
  - add a public getter method for the underlying GoogleMap instance.
- `fragment_collection.xml`:
  - Layout for `CollectionFragment`, including map container, spinners, and buttons.
- `activity_collection.xml`:
  - Layout for `CollectionActivity`, to hold the `CollectionFragment`.
- `arrays.xml`:
  - Added string-arrays for floor levels and indoor states.
- `strings.xml`:
  - Added strings for floor level, indoor state, and building name.
- `SensorFusion`:
  - Added `getAllSensorData()` for unified sensor data retrieval as a JSON object.
- `HomeFragment`:
  - added a button to open `CollectionActivity`.
- `AndroidManifest.xml`:
  - declare `CollectionActivity`.
- Updated `CollectionFragment` to support multi-point calibration and improve marker handling.
- Modified `TrajectoryMapFragment` to handle calibration pin placement and confirmation.
- Refactored `IndoorMapManager` to improve overlay refresh logic and track building context.
- Added new drawable `ic_baseline_assignment_turned_in_24_red` for tagged position.
- Updated floor and indoor state arrays for better labeling.
- Modified `CollectionActivity` to pass `floorLevel` as `-255` for outdoor.
Feat: Tagging system first done
TODO: fix wifi data collection

- Modify the data output file name to include the device model.
- Update the label of `FloorTransitional` to `Stairs`.
- Add sensor data for filtered acceleration, rotation vector, orientation, step count, proximity, light, pressure, WiFi positioning, device model.
- Add a heading computation method.
- Log errors in sensor data JSON construction.
This commit integrates WiFi positioning into the data collection and fusion process, alongside improvements to the alignment strategy. Key changes include:
- In CollectionActivity.java, WiFi positioning requests are now made periodically (every 8 seconds) using the available WiFi BSSID and RSSI values.
- The machine learning pipeline (main.py) now supports selecting either WiFi or GNSS for positioning. It also incorporates a new piecewise Procrustes alignment for better accuracy.
- EKF fusion (ekf.py) can now use either GNSS or WiFi data based on the chosen option.
- The plotting script (plotting.py) has been updated to visualize WiFi positions and calibration points more clearly.
- SensorFusion.java and related files have been modified to handle and process WiFi data, including a new utility class SensorFusionUtils for organizing sensor data.
introduction of caching mechanism with step-synchronised updates, addition of fusion latency logs
…script

This commit introduces an LSTM model for indoor positioning using WiFi RSSI data and includes a script to check RSSI data quality.

- Implemented an LSTM model to predict latitude and longitude coordinates from WiFi BSSID and RSSI data.
- Added a script `rssi_check.py` to analyze RSSI data, checking for inconsistencies between RSSI similarity and location proximity, and RSSI variance at the same location.
- Included visualization of RSSI data in PCA space colored by latitude.
- Updated the main script to preprocess data, train the LSTM model, evaluate performance, and visualize results.
- Added normalization of latitude and longitude coordinates and saved normalization parameters.
- Implemented a custom loss function considering both MSE and distance penalty.
Replaced unused elevation-based auto floor logic with Wi-Fi floor detection
…terface

Provided `getGnssAccuracy()` accessor for external use;
- Implemented RSSI conversion from dB to linear scale in `rssi_check.py`.
- Added a multi-input (WiFi + sensor) time-series LSTM model in `embedding_train_LSTM.py`.
- Modified data loading and preprocessing to include sensor features and build time-series samples with a sliding window in `embedding_train_LSTM.py`.
- Refactored `embedding_train.py` to include normalization of RSSI and coordinates, and to calculate and print mean and standard deviation of prediction errors.
- Updated UI layouts (`fragment_collection.xml`, `fragment_home.xml`, `strings.xml`) to align with indoor positioning features.
- Added a predictor for indoor positioning in `SensorDataPredictor.java`, including loading a TFLite model and bssid index mapping, and performing inference with WiFi data.
- Updated map display in `TrajectoryMapFragment.java`.
Fixed the ENU trajectory update after PDR step detection by ensuring the correct heading reference and conversion to radians. The update formula now uses Ξ”E = L * sin(ΞΈ) and Ξ”N = L * cos(ΞΈ), where ΞΈ is the heading relative to true north.
- Improved the EKF.predict() method to use the same step length and heading as the PDR module for state updates, ensuring consistency and avoiding duplicate or lagged updates.
- Adjusted EKF.getEstimatedPosition() to consistently use refLat, refLon, and refAlt as the reference point, and corrected the coordinate transformation between ENU and geodetic coordinates so that the EKF output aligns with the pure PDR trajectory when no GNSS/WiFi corrections are available.
- Reviewed and fixed the drawing logic in TrajectoryMapFragment/PathView to correctly accumulate trajectory points and perform proper coordinate conversion, thereby eliminating jump or discontinuity issues in the displayed path.
- Ensured proper EKF initialization and state maintenance to avoid sudden jumps due to reference point changes or reinitialization issues.
add MaterialButton and setShowRawTrajectory()
olinc-nb and others added 24 commits April 2, 2025 22:25
- Refactored PDR processing for better elevation handling, including filtering invalid elevation readings and using a median-based initialization.
- Improved trajectory map display by optimizing camera tracking and marker updates.
- Updated sensor fusion logic to include WiFi data in trajectory recording.
- Enhanced recording fragment to ensure context validity and delay the start of sensor fusion recording.
- Added a loading fragment layout for UI feedback during initialization.
- Improved data flushing in DataFileManager, reducing verbosity of logs.
- Minor improvements in trajectory plotting and trajectory file management.
…dates

- Updated SensorFusion to retrieve the latest GNSS position from `sensorFusion.getSensorValueMap()` instead of `gnssProcessor.getLastKnownLocation()`.
- Modified GNSS location instantiation to use values from the sensor value map.
- Adjusted the condition for using GNSS updates in the EKF, increasing the GNSS update interval to 3 seconds and checking `!useWiFi`.
- Updated initial location retrieval to use GNSS coordinates from the sensor value map, ensuring the usage of the latest available GNSS data.
…rrors for PDR, GNSS, and WiFi

This commit enhances the calibration process by providing real-time feedback on the accuracy of different positioning methods (PDR, GNSS, and WiFi). It introduces a new utility class for error calculation and updates the CalibrationFragment to display both current and average errors, aiding users in assessing system performance.

- Added `CalibrationUtils` class with methods to calculate distances between LatLng points using the Haversine formula and to compute calibration errors for GNSS, PDR, and WiFi positions relative to a marked location.
- Modified `CalibrationFragment` to:
  - Display current and average errors for PDR, GNSS, and WiFi.
  - Calculate and accumulate errors upon each calibration tag.
  - Update UI to show these error metrics in real-time.
- Updated `fragment_calibration.xml` layout to include a `TextView` for displaying error information.
- Adjusted UI elements in `fragment_calibration.xml` for better layout and readability.
- Modified navigation flow in `CorrectionFragment.java` to move to `RecordingFragment` after correction.
- Adjusted Handler usage in `MainActivity.java` to ensure proper execution on the main thread.
- Added text size and input type to building name edit text in `fragment_calibration.xml`
- Updated `CalibrationFragment.java` to convert PDR positions from meters to latitude/longitude degrees for accurate error calculation.
- Modified `SensorFusion.java` to use the latest GNSS accuracy and added a temporary GNSS location to set the accuracy for the fused location.
- Added closing of the data file in `CalibrationFragment.java`.
- Replaced the hardcoded Google Maps API key with a placeholder in `googlemaps_api.xml` and added a string resource for the placeholder.
- Moved `EKF.java` and `ParticleFilter.java` from `FusionAlgorithms` package to `domain` package.
- Updated references to `EKF` and `ParticleFilter` in `SensorFusion.java` to reflect the package change.
- Updated `build.gradle` to use `resValue` for the Google Maps API key and removed the `buildConfigField` for it.
- Updated `build.gradle` to remove optional loading of secrets file.
@Bol-C14 Bol-C14 changed the title G13 G13 - WiFi Positioning, Fusion Engine (EKF/PF), Real-Time Display & Tagging Tools, UI update, etc. Apr 3, 2025
@Bol-C14 Bol-C14 closed this Apr 3, 2025
@Bol-C14 Bol-C14 reopened this Apr 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants