Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SoftFusion sensor framework with BMI, ICM, LSM6, MPU sensor implementations #322

Merged
merged 55 commits into from
Jun 25, 2024

Conversation

l0ud
Copy link
Contributor

@l0ud l0ud commented Mar 29, 2024

Hi
This change is a is a collaborative effort among developers from Slime Discord to:

  • Reduce the amount of copy-pasting when implementing new IMUs.
  • Make adding new IMUs much quicker and simpler.
  • Support several new, promising IMUs in firmware.

Sfusion is based on a simplified version of 0.dev's BMI160 driver, providing a generic sensor framework with several calibration methods for very slim drivers focused on the low-level handling of particular IMUs.

This change adds support for the following IMUs:

  • BMI270 (good price/performance)
  • ICM42688 (similar to BMI270)
  • LSM6DS3TR-C (cheapest one)
  • LSM6DSV (best performing one)
  • LSM6DSR
  • LSM6DSO
  • MPU6050, without using its flaky onboard fusion.

All drivers were tested to be functional, some are already being used in many sets (LSM6DSV, partially BMI270).
One exception: MPU6050 sfusion driver may underperform until we find a way to change "restThGyr and restThAcc" in VQF based on the sensor. I would prefer to make this separate change, as this PR is already pretty large.
Driver code is written from scratch for Slime, so I don't expect any licensing problems. Required Bosch BMI firmware is provided in separated file and it's BSD-licensed.

Existing drivers were not affected except for the current ICM42688 implementation, which was removed as it didn't work.

Drivers are as minimal as possible to reduce code size not incorporating any external libraries and to have full control over IMU programming.

Other changes:

  • Significant SensorManager refactoring to reduce boilerplate code (like switch-cases for every IMU, ifdef with sensor addresses) and to reduce code size by not linking unused sensors.
  • Sensors' constructors were standardized to support SensorManager change.
  • The "Had data" flag was removed as I considered it not really useful and not supported by most sensors anyway.
  • Platform/Arduino versions were upgraded to have a toolchain with C++20, and the compiler was switched to use it. We checked functionality on ESP8266 and ESP32C3."

l0ud and others added 30 commits March 13, 2024 00:27
Bump Arduino Core to v3.0 to Match GCC12
Fix accel timescale for LSM6DSV (calibration no longer takes forever)
@l0ud l0ud mentioned this pull request May 1, 2024
@@ -40,7 +40,6 @@ enum class ImuID {
BMI270,
Copy link
Contributor

Choose a reason for hiding this comment

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

Conflicts with #296

@unlogisch04 unlogisch04 mentioned this pull request May 4, 2024
@unlogisch04 unlogisch04 added this to the 0.5.0 milestone May 4, 2024
Kubuxu and others added 6 commits June 3, 2024 21:18
@l0ud l0ud requested a review from Eirenliel June 22, 2024 09:59
Copy link
Member

@ImUrX ImUrX left a comment

Choose a reason for hiding this comment

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

BNO seems to work fine

@Eirenliel Eirenliel merged commit ea00beb into SlimeVR:main Jun 25, 2024
1 check passed
Spacefish pushed a commit to Spacefish/SlimeVR-Tracker-ESP that referenced this pull request Jun 28, 2024
…ations (SlimeVR#322)

* Update readme to mention BMI270 support.

* Soft fusion sensor initial code, wip

* Soft fusion ICM-42688-P lazy WIP implementation.

* sfusion: Cleanup, implemented sensor frequency calibration

* icm42688: add more comments, basic driver (no hw filtering) should be working

* sfustion: compilation fix

* sfusion: start calibration when upside down

* cleanup: remove confusing had data flag

* sensor manager: use unique_ptr instead of raw pointers

* sfusion: big refactoring wip

* sfusion: make aux work, at least sfusion sensors should now be functional

* sfusion: lightweight implementation of BMI270 sensor, no sensitivity cal yet

* sfusion: BMI270: added CRT and gyro zx factor. should be functionally equivalent to the old driver

* Added lsm6dsv

* Trying to work around esp32c3 compilation problem, not liking that solution

* sfusion: fix problems found after rebase

* Update README.md

* Bump Arduino core to 3.0 to match GCC12

* Remove fast pin swapping that is no longer compatible with arduino core v3

* Bring back fast pin swapping

* Update platformio-tools.ini

* Fix accel timescale (calibration no longer takes forever)

* Fix non-sfusion sensors

* Added LSM6DSO and DSR support and refactored DSV support

* Removed template float param from the implementation

* sfusion: port MPU6050 driver wip, not expecting to be functional yet

* sfusion: add headers specifying main code owners

* connection: fix warning

* update README.md

* fshelper: fixed ESP8266 regression caused by abstracting FS access

* sfusion: fix error on merge

* bno080: differentiate bno080, bno085, bno086 again

* sfusion: final touches

* restore hadData functionality, implementing it in every sensor, made configured flag bno-only

* fix address supplement in non-sfusion sensors, do i2c bus reset for all sensors

* sfusion: make MPU6050 driver use normal MPU6050 ImuID, change eatSamplesAndReturn function to take ms instead of seconds

* sfusion: hotfix, don't apply sensorOffset, it's applied in sensor base

* Log FIFO overruns on LSMs

* Reset the soft watchdog while eating or collecting calibration samples

Resolves an issue where the soft watchdog would trigger.

* Fix missing word in comment, switch to constexpr

* Update esp32/esp8266

---------

Co-authored-by: Gorbit99 <gorbitgames@gmail.com>
Co-authored-by: nekomona <nekomona@nekomona.com>
Co-authored-by: nekomona <nekomona@163.com>
Co-authored-by: unlogisch04 <98281608+unlogisch04@users.noreply.github.com>
Co-authored-by: kounocom <meia@kouno.xyz>
Co-authored-by: Kubuxu <oss@kubuxu.com>
ShineBrightMeow added a commit to Shine-Bright-Meow/slimevr-node that referenced this pull request Jul 6, 2024
ShineBrightMeow added a commit to Shine-Bright-Meow/SolarXR-Protocol that referenced this pull request Jul 6, 2024
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.

None yet

9 participants