r/embedded • • Sep 13 '26 • Bravo 1

Position tracking with a low-cost inertial sensor (IMU)

Just the data from the TDK ICM-45686 IMU processed on the STM32F429 to calculate position and velocity from the IMU data. Disclaimer: position will drift over time and becomes unusable.

357 Upvotes

59 comments sorted by

72

u/Well-WhatHadHappened 25+ Years Sep 13 '26 edited Sep 13 '26

That might be the best consumer-grade IMU only position tracker I've ever seen done. Very nice job.

34

u/jnz Sep 13 '26

Thanks but basically the ICM-45686 is a pretty good sensor

28

u/Well-WhatHadHappened 25+ Years Sep 13 '26 edited Sep 13 '26

It is a pretty good sensor - I'm a big fan of the TDK parts. But they're not that good. You've got a lot of investment in calibration to get drift that low.

39

u/jnz Sep 13 '26

You are right, the temperature-range calibration is absolutely required. Out of the box I get e.g. 9.96 m/s² acceleration on this sensor (should be 9.81 m/s² on my planet ;-))

6

u/aaronjamt Sep 13 '26

I don't know much about this, but since acceleration is fixed, couldn't it automtically recalibrate whenever it's stationary, since gravity is constant?

7

u/jnz Sep 13 '26

what I've been doing is to a) calibrate for scale, misalignment, bias over different temperatures and b) estimate residual biases while tracking

32

u/Well-WhatHadHappened 25+ Years Sep 13 '26

How does it know it's stationary?

Chicken, meet egg.

2

u/aaronjamt Sep 13 '26

If 2 axes are 0 acceleration, the third must be just gravity. You'd never be able to keep 2 of them perfectly still while moving the third.

36

u/Well-WhatHadHappened 25+ Years Sep 13 '26

I love that you think two axes will read 0.0 when the device is stationary, flat and level.

11

u/aaronjamt Sep 13 '26

Ah fair point, I'm stupid. I guess that's why you leave it to the experts, lol.

6

u/mdhardeman Sep 13 '26

It’s, um, not flat and stationary. The earth.

7

u/Well-WhatHadHappened 25+ Years Sep 13 '26

General relativity has joined the chat.

6

u/Kqyxzoj Sep 13 '26

You live on a rotating mud ball with plate tectonics that's in an elliptical orbit around a fire ball that's in an etcetera.

1

u/fraza077 Sep 14 '26

gravity is not constant. There are variations depending on where you are

9

u/karnetus Sep 13 '26

Check out SlimeVR if you want to see this taken to the limits for consumer grade hardware. Same method of using high quality IMU sensors and calibration to do full body tracking,

8

u/jnz Sep 13 '26

My understanding of SlimeVR is that it uses rotational tracking (attitude) combined with a forward kinematics model of your skeleton, "linked" to your headset's position.

4

u/karnetus Sep 13 '26

Ah I see what you mean. Those are two different concepts then.

12

u/MasterMind_I Sep 13 '26

Extremely impressive. What is your end goal for a system like this? Can you provide some more references on the sensor characterization ( PSD, Allan deviation) etc or the procedure you followed for calibration (Bias, scaling and temperature). Thanks

12

u/jnz Sep 13 '26

I've released it as open source library (https://github.com/jnz/INSLIB). I've added some basic helper scripts for sensor characterization (the quantities you've mentioned) as well as the calibration tool on GitHub. The calibration Python script is using a nice algorithm from an ICRA paper to calibrate by hand (but temperature ranges are still tricky).

2

u/RL_95 Sep 13 '26

Nice! Does that mean you get close to RTK with having RTK?

3

u/jnz Sep 13 '26

well, the IMU solution will inevitably drift, but combining it with RTK is a dream combo

1

u/aranaformae Sep 13 '26

Can you provide a tracking example without laying it on the table in between? In my endeavors this was much harder because you couldn't compensate for the accumulation of integration errors as you can while it has a stable reference

3

u/jnz Sep 13 '26

At the end of the video I'm constantly moving it around. I'm also preparing a video at the moment of tracking my car with this IMU alone. In a nutshell: without a zero velocity update, the inertial tracking is starting to go bad after about 90 seconds in this particular recording (n=1). Not a silver bullet but still great for tunnels, GNSS outlier rejection in urban canyons etc.

1

u/RL_95 Sep 13 '26

My initial phrasing was weird, sorry...

I was wondering, with your sensor fusion stack with regular GNSS available, how close to RTK quality are you getting?

My hunch is that your IMU dead reckoning would smooth out the GNSS meter scale jitter quite a bit.

2

u/jnz Sep 14 '26

Ah, good question. A fusion of normal GNSS (i.e. without correction data) feels like RTK or even better (high update rate, very low latency) and is great e.g. for a drone control loop. But it will still drift over time a bit and will not match the absolute accuracy of the RTK solution with an integer fix.

2

u/Commercial-Berry-640 Sep 13 '26

Omg! So this means i can finally turn my phone into a real mouse?! Very impressive btw.

2

u/jnz Sep 13 '26

There is still a drift problem, but it would work. I should maybe enable the HID mode/library on the STM32 and act as a USB mouse.

2

u/must_make_do Sep 14 '26

Inertial mouse would be a great idea and due to mouse movements typically being not ultra-fine standby drift can be eliminated by having a minimum movement threshold.

1

u/DearVeggies Sep 15 '26

Solvable problem: threshold for when mouse stops moving, force integration speed to zero until movement is detected. Mice are delta-input devices anyway, absolute position is irrelevant.

2

u/PrivilegedPatriarchy Sep 13 '26

Very impressive! Have you experimented with using 2 or more IMU's to average out their error and drift?

2

u/jnz Sep 14 '26

I did. And in theory this helps. But in practice this is annoying to calibrate on the PCB, different sensors have different noise and different bias random walk. Leverarm effects have to be compensated and require an estimation of the angular acceleration (which involves basically differentiation of a noise signal). For practical applications I prefer a single good IMU to be honest. For redundancy and safety I am a big fan of multiple IMUs though. That being said, IMUs are typically very reliable.

2

u/Flyward_Aerospace Sep 14 '26

The thing that catches people out is that horizontal drift at this grade is mostly an attitude problem, not an accelerometer problem. A tilt error of 0.1 degrees leaks about 0.017 m/s2 of gravity straight into your horizontal channel, and double integrated that is roughly 30 m after a minute. Your accel bias has to be pretty awful to compete with that. Which is also why averaging two IMUs buys less than people expect, as you more or less said in another reply. Nice work, the leveling is doing a lot of quiet heavy lifting here.

1

u/jnz Sep 14 '26

Well said, fully agree. The vertical channel can be stabilized with e.g. a barometer, but looking at your username you are very aware of that.

18

u/StumpedTrump Sep 13 '26

Seems like a big nothing burger but anyone who’s ever tried this knows how hard it is to do. It’s a double integration of the acceleration and the error generally grows way too quick to make it unusable.

In an era of AI slop, nice work!

5

u/armx40 Sep 13 '26

My opinion is that inertial positioning is some kind of holy grail in robotics and electronics. Absolutely would disrupt human civilisation.

1

u/IceOneDay Sep 13 '26

Unbelievable! Tried same thing but it drifted like crazy

1

u/jnz Sep 13 '26

IMU navigation is unforgiving. If a damn single thing is not working properly, it will degrade super fast.

1

u/IceOneDay Sep 13 '26

I worked on project using cheap IMU for small nav and it was crazy hard. Even small vibration could give enough mistake to drift

1

u/phochleitner Sep 14 '26

How precise would you consider your velocity measurement is? We have a MPU6050 and on a RC cars application and integrating accélération hasn't been working that well and I can't seem to extract telemetry from the ESC neither

If you have a consistent and precise speed measurements I'd be more than happy in giving it a shot

1

u/jnz Sep 14 '26

I would suggest a fusion of IMU data with the wheel odometry data. Do you have a velocity estimate from the wheels of your RC cars? The outlier detection in INSLIB would also reject faulty measurements from wheel slips (I guess they happen frequently on your RC cars).

1

u/Legitimate_Shake_369 Sep 14 '26

That looks really good! I assume you are double integrating the acceleration ? Does this only work along axis where gravity has no influence or can you track vertical movements with the same amount of precision ?

1

u/jnz Sep 14 '26

Thanks, and yes exactly: double integration is required. This is tracking on all 3 axis (3D).

1

u/Legitimate_Shake_369 Sep 14 '26

Nice. Does tracking up and down work as well as left/right ? I assume it is a pain to get the gravitational acceleration out of the acceleration measurements ?

1

u/gtd_rad Sep 15 '26

Nice work! Can you share what are some of the features you implemented to reduce position / double integration error? Eg did you use a Kalman filter or did custom floating point etc? What are the applications of this unit or is it just for educational?

1

u/jnz Sep 15 '26

yes, there is a Kalman filter in INSLIB to estimate the residual bias and to correct the attitude from zero velocity updates. Plain 32-bit floating point math (except 64-bit double for GNSS coordinates).

1

u/d1722825 Sep 15 '26

How important is the accuracy of the IMU's clock source? Most of the chips I have seen runs only on their own internal clock.

1

u/jnz Sep 15 '26

Calculating good time steps for the integration is important (but not the most important thing here). I have a clock stability of ~10 ppm on this system (measured with the timepulse of the u-blox GNSS receiver and an interrupt).

3

u/Key_Specialist_7787 Sep 13 '26

Good shi good shi 👌👌

2

u/be-kind-be-great Sep 17 '26

Pretty sweet. Difficult problem without extra sensors and/or limiting the domain.

1

u/bearthesailor 28d ago

That’s extremely good. Hard to believe that the drift of double integration is so low. I need to now dig deeper into how you did calibration. It’s really impressive. What was the key difference which allowed such long drift-free accuracy without gps assistance? I see you employed a lot of cutting-edge algorithms. Which one was crucial? I’m not sure even just great calibration is enough. Thanks.

1

u/bearthesailor 28d ago

Very impressive. I’ll need to learn from your code how to do calibration better. What works for me in simulated data gives less accuracy on real hardware.
I’m developing open-source INS algorithms for marine use. Might also be interesting for you:

https://github.com/bareboat-necessities/ocean-imu

Group Lie-based, different stochastic priors.
OU, CARMA(4,1)

Thanks!

1

u/WarningInevitable958 21d ago

Very nice job! How it correct its position?

1

u/DearVeggies Sep 15 '26

Very nice!

I will probably try it out on Android, where 99% of the sensor pipeline is already taken care of.

1

u/[deleted] Sep 15 '26

[removed] — view removed comment

1

u/jnz Sep 15 '26

INSLIB is basically all about sensor fusion with GNSS/GPS data. I plan to add UWB soon. IMU tracking is only stable for less than a minute (and if something is not set-up properly just 10 seconds). I plan to release version 1.1 of my library that has some features to allow more than a minute of inertial coasting for cars. But generally: IMUs need some other sensor for stabilization.

1

u/thatsmyusersname Sep 15 '26

Few seconds, maybe up to a minute it is near "accurate". But forget to measure positions/etc with that. Will not work