RIP
I'm trying to sort out how all the various filters described here compare with a simpler approach. However I see a number of options, have we settled on a "best one"? Perhaps the one @JayKominek is utilizing which is
#define FIR_LEN 13
// TODO want this in DTCM also
// scipy.signal.savgol_coeffs(13, 2, deriv=1, use='dot', delta=0.01)
// the delta doesn't matter, so it was chosen to bring the values to ~1.0
float filter[FIR_LEN] = { -3.2967032967033107, -2.7472527472527473,
-2.197802197802188, -1.64835164835163, -1.0989010989010746,
-0.5494505494505213, 2.9531932455029164e-14, 0.5494505494505779,
1.098901098901124, 1.6483516483516676, 2.1978021978022086,
2.7472527472527473, 3.296703296703284 };
and
static inline __attribute__((always_inline)) float computefilter(int chan, int idxs[])
{
float v = 0.0;
for(int i=0; i<FIR_LEN; i++) {
// TODO check to see what the compiler-emitted assembly looks like.
// if we're not using the fused multiply and add instruction, fix it.
v += filter[i] * sensorbuffer[chan][idxs[i]];
}
return v;
}
Consider that:
- We need the velocity only at the time of strike (before it is slowed down by whatever the hammer strikes, obviously)
- The hammer is in free flight from let off to the time of strike
- The previous two points imply that the hammer velocity is approximately constant and more accurately slowed down by gravity
My question is: instead of doing this hyperlocal measurement at the very end (with all the noise implications of measuring only few points all nearby), why we could not measure a few points from let off to strike and make the measurement basically averaged along a much longer travel (possibly considering gravity slow down, for which we have analytical formula)?
And by "few points from let off to strike" I really mean a few points (again, to average noise) and not one point alone as I am currently making (if you looked at my code). My gut feeling tells me that this would be computationally simpler (not a big deal on the STM32, but somewhat on a pico, see below) and probably more accurate for the purpose we need.
Thoughts?
vagfilm No idea about implementing Kalman on pico (Python?)
Only now I noticed that I never responded to this. I guess you can use Python on the pico, but I am using C (like Jay is on the STM32). And, to reiterate, the pico is a testing platform which might (and hopefully will) turn out to be decent enough to be viable for those who don't want to order custom PCBs, but it is not our final goal.


