Skip to content

FIR filters#81

Merged
energy-in-joles merged 46 commits intomainfrom
position_filtering_2
Feb 21, 2026
Merged

FIR filters#81
energy-in-joles merged 46 commits intomainfrom
position_filtering_2

Conversation

@szeyoong-low
Copy link
Copy Markdown
Member

@szeyoong-low szeyoong-low commented Dec 8, 2025

Finite Impulse Response (FIR) filters for noise filtering

  • Implemented a FIR filter (utama_core/run/refiners/filters.py)
  • Wrote unit tests to verify that mean squared error is reduced across the board (utama_core/tests/refiners/noise_filter_test.py)
  • Integrated filters into the position refiners (utama_core/run/refiners/position.py)
  • Added utilities for exporting vision data and real time tracking of robot coordinates during live testing (utama_core/run/refiners/position.py) -> Moved to testing/data_processing
  • Modified other unit tests affected by PositionRefiner taking more arguments necessary for the filters (utama_core/tests/refiners/position_unit_test.py and position_refiner_integration_test.py)
  • Added a folder (vision_data) with various datasets generated from simulations for use in unit testing and running analytics
  • Analysed the filters to optimise parameters and verify effectiveness in a Jupyter notebook (vision_data/filter_results_summary.ipynb) -> Moved to testing/data_processing
  • Added multiple dependencies to Pixi: scipy, seaborn, pyqtgraph, pyside6 (pixi.toml)

Results achieved

When testing with grSim using the PID controller under random noise with standard deviation of 10 cm, we achieved a 45% improvement in robot positioning accuracy.

However, under the DWA controller, it creates random oscillations. We suspect it is due to the phase delay that FIR filters inherently caused. As such, we have since focused on developing a Kalman filter.

image image image

Note:

Kindly keep the additional unused parameters to the Position Refiner. It is required for Kalman filters, and removing it will require double work.

Completed by @szeyoong-low and @JiamingLiu5

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements FIR (Finite Impulse Response) filtering for noise reduction in robot position tracking from vision data. The implementation includes a new filter module, comprehensive unit tests validating MSE reduction, and integration into the position refinement pipeline with support for both friendly and enemy robot tracking.

Key Changes:

  • New FIR filter implementation with configurable parameters for position smoothing
  • Unit tests demonstrating filter effectiveness across 6 robots using real simulation data
  • Updated PositionRefiner API to accept team color and robot count parameters for filter initialization
  • Added visualization and analysis dependencies (scipy, seaborn, pyqtgraph, pyside6)

Reviewed changes

Copilot reviewed 17 out of 24 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
utama_core/run/refiners/filters.py New FIR filter implementation with position and orientation filtering support
utama_core/tests/refiners/noise_filter_test.py Comprehensive unit tests validating MSE reduction for x, y, and vector positions
utama_core/run/refiners/position.py Integration of filters into position refiners (not shown in diff)
utama_core/tests/refiners/position_unit_test.py Updated test signatures to match new PositionRefiner constructor
utama_core/tests/refiners/position_refiner_integration_test.py Updated integration test with new PositionRefiner parameters
utama_core/run/strategy_runner.py Updated PositionRefiner instantiation with team and robot count parameters
utama_core/entities/data/vision.py Added Gaussian noise injection method for testing
pixi.toml Added scipy, seaborn, pyqtgraph, and pyside6 dependencies
vision_data/*.csv Test data files for filter validation
vision_data/.jupyter/* Jupyter workspace configuration (should not be committed)
main.py Changed mode from "rsim" to "grsim"

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@szeyoong-low szeyoong-low changed the title Position filtering 2 FIR filters Jan 31, 2026
@energy-in-joles energy-in-joles merged commit e30e667 into main Feb 21, 2026
2 checks passed
@energy-in-joles energy-in-joles deleted the position_filtering_2 branch February 21, 2026 22:17
valentinbruehl pushed a commit that referenced this pull request Feb 22, 2026
* Added extracted vision data with varying degrees of vanishing and noise

* Attempt to store past raw game frames; starting work on test cases

* added Andrew's filter

* Integrated filters into position refiner

* bad example test

* Refined filter weights, added vision data for testing

* Updated test data

* Noise now added manually, updated test data

* Amended test cases to address CI failure due to changes to PositionRefiner's constructor

* Refinements to filters based on empirical data

* Added some references for building tests

* First pass unit tests

* Some issues with unit tests. Working on fix

* Added live testing utilities, conducted analytics for filters, refactored classes, added new datasets

* Finalised analysis of filters, unit tests are working, added more live testing utilities

* Deleted redundant files

* Minor refinements to the live testing utilities

* fixed formatting issues

* Commented out utilities for testing and exporting data

* Addressed comments on PR

* Removed redundant utility function

* cleanup

* Added back error handling for imports when run from Jupyter

* Moved unused testing/debugging utilities to a separate text file, turned off filtering by default with a flag to PositionRefiner

* Further cleanup

* Removed all testing utilities, will create a testing branch

* Cleaned up test suite

* Removed data analysis

* Removed data analysis

* Removed data analysis

* Final cleanup

* revert position_refiner_integration_test

* update test

* fixes and formatting

* remove unncessary comments

* update readme

---------

Co-authored-by: Fred Huang <fredhuang122106@gmail.com>
Co-authored-by: Joel <nzmjoel@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release:minor Minor changes to main

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants