Commit Graph

660 Commits

Author SHA1 Message Date
gorbit99
a4547c3a3b Apply some ICM code fixes 2025-04-23 19:43:17 +02:00
gorbit99
66cb5fd62f Fix compilation issues 2025-04-23 18:50:31 +02:00
gorbit99
3a25cc70d7 Merge remote-tracking branch 'kounocom/sfusion-machine-optimized' into machine-optimized-spi 2025-04-23 18:47:35 +02:00
kounocom
02b272e215 Re-add biasClip value 2025-04-23 17:44:46 +03:00
Eiren Rain
3d647f0c8b (Probably) multiply acceleration by tracker rotation offset 2025-04-23 15:37:53 +02:00
Butterscotch!
f5df7534db ESP32 spelling fix (#396)
Fix: ES32 -> ESP32
2025-04-23 15:37:52 +02:00
Eiren Rain
079919641a Make SPI work
Move sensor building logic to a separate class and file

Don't use templates for RegisterInterface/I2CImpl/SPIImpl

This started getting ridiculous, now we can actually maintain it.

Make BNO085 work again

Add BNO to automatic detection, remove a bunch of others

Not all IMU types are enabled right now due to code size optimization, but it could be expanded in the future with optimization of Softfusion.

Pick IMU type automatically by asking it
2025-04-23 15:37:52 +02:00
kounocom
83516118ba fix merge 2025-04-19 19:39:18 +02:00
kounocom
38b9f705bf Merge remote-tracking branch 'jabber/jabber-gorbit99-on-off-button' into sfusion-machine-optimized 2025-04-19 19:34:37 +02:00
kounocom
7629c6ad2c update to main, but squished~ 2025-04-19 19:08:48 +02:00
jabberrock
bbba63e06c [ICM45*] Fix processing bad samples and stack overflow panics (#423)
* [ICM45*] Fix processing bad samples and stack overflow panics

1. At startup, we were receiving invalid samples from the IMU and passing it to
   VQF. This causes huge initial rotations and accelerations that takes time
   for VQF to eliminate.

   Fix is to check the header to see if the data is present. Also had to add a
   check for invalid gyro samples even though it is present.

2. During play, the tracker would rarely go haywire and jump into a random
   position. I suspect this is caused by a stack overflow, which causes the
   tracker to panic. Combined with problem (1), whenever the tracker restarts,
   it would send huge rotations and accelerations to the server. This causes
   the jump.

   Fix is to make the read_buffer static, so that it's reserved on the BSS
   segment instead of the stack. I noticed this because I was getting panics
   when I tried to increase the size of the read buffer, or declared some new
   stack variables.

After implementing these two fixes, rotation and acceleration are stable at
startup, and I am able to make modifications to the icm45base code without
randomly encountering panics.

* Always read one fewer packet to prevent AN-000364 2.16 errata
2025-04-19 19:21:03 +03:00
Jabberrock
412e43b5d6 ON-OFF button support
Adapted from d8e7e74f96
2025-04-18 18:57:21 -07:00
Jabberrock
a61342bc5f Set POWERSAVING_MODE to POWER_SAVING_NONE
On ESP32, latency is high when TPS is low. When you go from not-moving to
moving, there is also some latency before movement starts. This is because the
ESP32 goes into sleep mode. This change eliminates sleep mode, which brings
latency in line with ESP8266-based trackers.
2025-04-18 18:56:21 -07:00
Jabberrock
295edd9ec8 Always read one fewer packet to prevent AN-000364 2.16 errata 2025-04-18 18:37:49 -07:00
Jabberrock
3ac0afd362 [ICM45*] Fix processing bad samples and stack overflow panics
1. At startup, we were receiving invalid samples from the IMU and passing it to
   VQF. This causes huge initial rotations and accelerations that takes time
   for VQF to eliminate.

   Fix is to check the header to see if the data is present. Also had to add a
   check for invalid gyro samples even though it is present.

2. During play, the tracker would rarely go haywire and jump into a random
   position. I suspect this is caused by a stack overflow, which causes the
   tracker to panic. Combined with problem (1), whenever the tracker restarts,
   it would send huge rotations and accelerations to the server. This causes
   the jump.

   Fix is to make the read_buffer static, so that it's reserved on the BSS
   segment instead of the stack. I noticed this because I was getting panics
   when I tried to increase the size of the read buffer, or declared some new
   stack variables.

After implementing these two fixes, rotation and acceleration are stable at
startup, and I am able to make modifications to the icm45base code without
randomly encountering panics.
2025-04-18 15:03:37 -07:00
unlogisch04
ee48341c30 Feat BNO085 temp (#417)
* BNO085 add more Features and Readouts to the lib

* BNO085 add
- Experimental compiler flags for disable Calibration
- Temp Readout (all 1 sec)
- Inspection only send when updated
- added conginue as 1 imu.dataAvailable() only reads out 1 packet of data

* BNO085 add source of info
2025-04-17 19:15:47 +03:00
unlogisch04
4c2377f2f3 fix SensorStateUpdate (#418)
After a reboot of the tracker the optional sensor did show up on the server too.
This is because a sensor packet was sent from all sensors including empty and unknown.
This should hopefully fix the issue.
It is a fast fix. It probably would be better to move all this check to sensor, and if the sensor has a chang set the flag, and reset the flag if the function gets called.
2025-04-17 18:57:33 +03:00
Meia
913a330601 Use ubuntu-latest for build job (#421)
Use ubuntu-latest for build action
2025-04-17 16:24:01 +03:00
Meia
39545d7ae7 Remove OTA timeout (#419)
* Remove OTA timeout

* Make it toggleable from debug.h
2025-04-17 16:23:36 +03:00
kounocom
cdb07f780c read 6 frames at most 2025-04-17 02:32:24 +02:00
kounocom
0342713b5e stop-on-full fifo mode 2025-04-15 18:20:55 +02:00
gorbit99
4e937ce79b Refactor feature toggling into a class (#410)
* Refactor toggles into separate class

* Add vqf toggles to config bits

* Load toggles into the sensor

* Mark correct toggles as supported for VQF

* Zero out calibration if it's disabled for softfusioncalibration

* Fix BNO085 typo

* Formatting
2025-04-07 00:20:08 +03:00
gorbit99
9a6813457d Implement SensorInterfaceManager (#415)
* Implement a sensor interface manager

* Add missed return true

* Formatting
2025-04-07 00:12:05 +03:00
Meia
4d5f5ec885 More ICM45 fixes (#416)
* hotfix: scan for IMU on bus twice

* hotfix: never fully empty icm45 fifo

* leave one packet, not one byte

* Formatting

---------

Co-authored-by: gorbit99 <gorbitgames@gmail.com>
2025-04-07 00:04:05 +03:00
kounocom
7b6e1e1f20 leave one packet not one byte 2025-04-06 18:24:23 +03:00
kounocom
07d7af49bf ICM45*: Never fully empty FIFO? 2025-04-05 16:54:02 +03:00
kounocom
98a9ef87b9 Use double precision for some parts of VQF again 2025-03-31 23:07:50 +03:00
gorbit99
a401d98028 Update to latest main and use newest params 2025-03-31 20:11:10 +02:00
Ilia Ki
b873ba66dd Add Gestures Boards (#413)
* Add Gestures Boards

* Update src/consts.h

Co-authored-by: gorbit99 <gorbitgames@gmail.com>

---------

Co-authored-by: gorbit99 <gorbitgames@gmail.com>
2025-03-30 19:23:09 +03:00
unlogisch04
4b070d1bf1 Fix BNO SensorState when i2c disconnects while working (#411)
The BNO08x Sensor did not change its state when a i2c timeout is occoured.
2025-03-23 23:11:57 +03:00
unlogisch04
ed4fa32043 fix i2c clockspeed to default 400khz back (#408) 2025-03-18 03:29:35 +03:00
unlogisch04
cade3ebcf5 add handling for not given pin (-1 or 255) (#406)
This commit fixes the use case BNO08x whit out a interrupt pin.
2025-03-17 16:48:16 +03:00
unlogisch04
c87c3456d8 fix_sensorConfigData Magnetometer not avaliable on Server (#405)
* fix_sensorConfigData Magnetometer not avaliable on Server

* fix formating

* Send Sensor Configuration changes to Server.
before the Magnetometerchanges would not have been sent to the Server.

* Formating
2025-03-17 16:47:21 +03:00
gorbit99
1749dabdda Refactor network packets into structs (#402)
* Refactor packets into structures

* Remove left in packet code

* Swap multi-byte data to big endian

* Refactor convert_to_bytes to use std::reverse instead

* Missed removing some old code

* Fix convert_to_chars refactor

* Add comment to legacy fields

* Add back rest of cut off comment
2025-03-16 14:12:37 +02:00
Meia
2d24440eec ICM45*: Remove erroneous sizeof() from FIFO read logic (#403) 2025-03-16 13:54:05 +02:00
Eiren Rain
16578b90d7 Swapped imu addr fix (#401)
* Make IMU addresses work when first/second is swapped

* Add secondary default addresses

---------

Co-authored-by: unlogisch04 <98281608+unlogisch04@users.noreply.github.com>
2025-03-14 15:08:41 +02:00
Meia
0de5cb8a1f ICM45*: Process accel sample LSB correctly (#399) 2025-03-09 05:09:53 +03:00
Butterscotch!
65929a7f2b Re-order SensorInfo packet (#394) 2025-02-26 12:34:26 +03:00
gorbit99
a3c191ef3a Revert "Don't copy memory on ICM45 reads" (#392)
This reverts commit 63b18735fc.
2025-02-23 19:18:16 +02:00
gorbit99
624c6488a6 Small fixes (#393)
* fix: Only set the pin direction to input if i2c was used before

* fix: Don't tick calibrator twice

* Formatting
2025-02-22 10:57:08 +03:00
gorbit99
77221577ca Dynamic Sfusion Attempt 2 (#375)
* Move temperature reading into the FIFO whenever possible (no love for MPU)

* Calculate gradient and feed into VQF

* Per sensor VQF params

* Split out classic softfusion calibration

* Cleanup

* Nonblocking calibration implemented

* Oops

* Formatting

* Make sure it actually compiles

* Use calibrated ZRO values

* Fix compilation errors and warnings

* Send temperature in correct place

* Add DELCAL command

* Slightly optimize ICM45 fifo handling

* Implement time taken measurer

* Precalculate nonblocking zro change

* Adjusted debug.h

* Reduced ICM45 accel rate to 102.4Hz

* Poll sensor at the same time we send data

* I hate git again

* Undo icm45 optimization

* Don't copy memory on ICM45 reads

* Change relevant doubles to floats

* Remove unnecessary union

* Fix guards to profiler

* Move temperature reading into the FIFO whenever possible (no love for MPU)

* Calculate gradient and feed into VQF

* Per sensor VQF params

* Split out classic softfusion calibration

* Cleanup

* Nonblocking calibration implemented

* Oops

* Formatting

* Make sure it actually compiles

* Use calibrated ZRO values

* Fix compilation errors and warnings

* Send temperature in correct place

* Add DELCAL command

* Slightly optimize ICM45 fifo handling

* Implement time taken measurer

* Precalculate nonblocking zro change

* Adjusted debug.h

* Reduced ICM45 accel rate to 102.4Hz

* Poll sensor at the same time we send data

* Undo icm45 optimization

* Don't copy memory on ICM45 reads

* Change relevant doubles to floats

* Remove unnecessary union

* Fix guards to profiler

* Fixes after rebase

* Fix after rebase

* Fix formatting

* Make SPI work

* Revert "Make SPI work"

This reverts commit 92bc946eaa.

* Rename to RuntimeCalibration

* Disable profiling

---------

Co-authored-by: Eiren Rain <Eirenliel@users.noreply.github.com>
2025-02-20 00:25:15 +03:00
Butterscotch!
c3536f0d75 Ignore rest calibration ack if packet is too short (#389)
* Ignore rest calibration ack if packet is too short

* Fix sensor calibration ack byte index
2025-02-17 12:14:12 +03:00
Eiren Rain
f4b5148898 Bump protocol version to 20 2025-02-06 16:47:16 +01:00
Eiren Rain
cdb6e4b39f Glove (#371)
* Add calibration reading commands for BNO08X

* Disable accelerometer calibration 1 minute after start up on BNO08X

Also save dynamic calibration periodically

* Work on new sensor interface to abstract I2C hardware

* Fix compile errors

* Abstract int pin and add multiplexer libraries

* Update IMU list to use new interfaces

* Make other IMUs definable, not only BNOx

* Fix build for ESP32

* Add TPS tracking code

Rename IMU_DESC_LIST to SENSOR_DESC_LIST
Start work on many-imu glove support

* Add PCA9546A support & glove imus list

* WIP use pointers properly

* I love C++ <3

* c++ is magic

* Fix build error because of typo

* Fix warnings

* Fix pinouts and some other issues

* Fix I2C with multiplexer

* Implement sending bone position

Implement sending flex data,
Minor refactoring

* Add tracker type to the protocol

* Work on analog sensors support

* Fix build errors

* Fix rebase conflict

* Apply formatting

* Update protocol to match server

* Fix thumb bone names

* Add an important comment

* Fix protocol compatibility

* Update defines for default configuration

* Minor comments and cleanups

* Format defines

* Formatting

* Formatting with proper clang

* Fucking clang

* Minor fixes after merge

* Fix formatting

* Remove unnecessary virtual keyword

* Remove delay on I2C clear error so OTA doesn't break

* Address some of the review comments

* Fix formatting

* Minor include imporvement

* Make new defines enums

* Fix build for sfusion
2025-02-06 17:46:09 +02:00
Eiren Rain
35b42a9e5c Fix formatting v0.5.3 2025-02-04 22:31:19 +01:00
pembem22
8e71bc5ce2 Add IMU timeout detection to SoftFusionSensor (#376)
* Add IMU timeout detection to `SoftFusionSensor`

* Early return, use constexpr

* Define a sensor timeout error code

* Use enum instead of define

* Avoid false timeout on timer overflow

* Revert "Avoid false timeout on timer overflow"

This reverts commit f4c2835c7f.

* Use millis instead of micros

* Use SH-2 error codes
2025-02-04 23:23:56 +02:00
gorbit99
3c7e458985 Report rest calibration (#384)
* Add rest calibration detection for the sensors that support it

* Resend sensor packet on calibration

* Renamed completedRestCalibration to hasCompletedRestCalibration

* Log when rest calibration is completed

---------

Co-authored-by: Eiren Rain <Eirenliel@users.noreply.github.com>
2025-02-04 23:23:08 +02:00
Meia
38c180c561 Make I2Cscan non-blocking (#378)
* Make I2Cscan non-blocking

* Address suggestions

* Use portExclude again

* Re-add some comments

* It's 8 AM and I'm allowed to be stupid

* No more while(true)

* More cleanup

* ...and more

* even more!

* Thanks clang-format

* Do not scan the same port twice

---------

Co-authored-by: Eiren Rain <Eirenliel@users.noreply.github.com>
2025-02-04 23:16:13 +02:00
gorbit99
6942e486ed ICM45 implementation (#374)
* ICM45 implementation

* I have a love-hate relationship with git

* Formatting
2025-01-05 02:45:17 +03:00
Eiren Rain
c29b7bd1b1 Reverse IMU I2C address from supplement to full (#372)
* Reverse IMU I2C address from supplement to full

* Formatting fix

* More formatting

* Make suggested change to improve compatibility with lazy people

* Create CODEOWNERS

* Fix include and C++ standards
2024-12-20 19:07:19 +02:00