Skip to content

BHI260AP IMU and 2D Kalman filter#508

Merged
senthurayyappan merged 30 commits intoneurobionics:mainfrom
Katharine-Walters:BHI260AP
Feb 4, 2026
Merged

BHI260AP IMU and 2D Kalman filter#508
senthurayyappan merged 30 commits intoneurobionics:mainfrom
Katharine-Walters:BHI260AP

Conversation

@Katharine-Walters
Copy link
Contributor

feat: added sensor class for BHI260AP IMU, added sensor class for IMU axis transformations, added filters utility with 2D Kalman filter implementation to estimate roll and pitch

Note 1: Added tutorial for reading from IMU and tutorial for running Kalman filter with axis transformation
Note 2: Kalman filter implementation tested against LordMicrostrain GX5

Copy link
Member

@tkevinbest tkevinbest left a comment

Choose a reason for hiding this comment

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

Hi Katharine! Overall it looks good! I left a few questions in the code. Some other thoughts before we merge:

  1. Right now, it isn't passing the automated checks. Check out the contribution instructions page and it'll tell you how to set up a venv with uv and run all the checks to see what isn't passing.
  2. Is any of the driver code reused from another source or implementation? If so we need to credit the original. Same with the kalman filter.
  3. Thanks for making tutorial scripts! These should be paired with markdown docs that explain the tutorial. Can you add them for your new tutorials? Let me know if you have issues adding them.
  4. We need some unit tests for the new features! These can probably mirror those of the microstrain class, if there are any.

Otherwise looks good! I trust you've tested it and are currently using it haha.

@Katharine-Walters
Copy link
Contributor Author

Katharine-Walters commented Jan 17, 2026

@tkevinbest To address your other comments:
2) I didn't use any pre-existing implementation or source other than the datasheet.
3) I added markdown docs.
4) Unfortunately I don't have the bandwidth to make unit tests right now.

@sentry
Copy link

sentry bot commented Jan 18, 2026

Codecov Report

❌ Patch coverage is 58.88889% with 185 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
opensourceleg/sensors/imu.py 55.8% 170 Missing and 8 partials ⚠️
opensourceleg/utilities/filters.py 85.1% 5 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

@Katharine-Walters
Copy link
Contributor Author

I tried to address all of the test cases that were failing, but I don't know what to do about the last ones. If anyone could explain to me what those are I would appreciate it!

@tkevinbest
Copy link
Member

@Katharine-Walters looks good! I've added the docs to the navigation system and tested them. I've also committed some initial copilot unit tests. I looked through them and they seem reasonable, but it would be good if you can scan them too. I've also fixed any remaining ruff issues that were failing.

See this PR to bring in my changes: Katharine-Walters#1

docs: update imu and KF docs, fixes line refs
Copy link
Member

@tkevinbest tkevinbest left a comment

Choose a reason for hiding this comment

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

Aside from the two remaining questions regarding the snippet in the docs and the __repr__, this looks good to go to me. @senthurayyappan or @ellliewilson have any thoughts before approving?

"""
def __init__(
self,
tag: str = "KalmanFilter2D",
Copy link
Member

Choose a reason for hiding this comment

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

We can eliminate this right?

Or make it a repr response?

Suggested change
tag: str = "KalmanFilter2D",
tag: str = "KalmanFilter2D",
...
self._tag = tag
...
def __repr__(self):
return self._tag

Comment on lines +45 to +51
## IMU Parameters

When initializing the BHI260AP, several important parameters can be configured:

```python
--8<-- "tutorials/sensors/reading_bhi260ap_imu_data.py:14:23"
```
Copy link
Member

Choose a reason for hiding this comment

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

I dont' see what this snipped originally referenced in terms of line numbers. I got the rest updated

@ellliewilson
Copy link
Contributor

Aside from the two remaining questions regarding the snippet in the docs and the __repr__, this looks good to go to me. @senthurayyappan or @ellliewilson have any thoughts before approving?

@tkevinbest The BHI260AP IMU is the one on the OSL electronics board; we are waiting on another shipment of them to do hardware tests for this PR, then it should be good to merge after :)

@tkevinbest
Copy link
Member

@Katharine-Walters if you run make check before committing, it'll automatically do any of the reformatting that it needs to do. If you do that, do you pass all the checks then?

@Katharine-Walters
Copy link
Contributor Author

@tkevinbest is there a way to run that without setting up the virtual environment? I tried doing that on my PC but Python environments make me crazy and I couldn't get it to work

@tkevinbest
Copy link
Member

I typically use a codespace on github for pure code changes. Then the virtual environment works super easily

@Katharine-Walters
Copy link
Contributor Author

Ah, that helps so much!

@senthurayyappan
Copy link
Member

Hey @ellliewilson and @tkevinbest, I'm merging this PR with main to address a git situation with the TMotor changes, which was mostly my blunder. Can we test @Katharine-Walters's new_Tmotor_Servo_CAN branch, which also includes a few IMU fixes?

@senthurayyappan senthurayyappan merged commit f4aa150 into neurobionics:main Feb 4, 2026
6 checks passed
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.

4 participants