Garmin Filters or Kalman Filters

Hello people, 

I ran a few experiments on calculating displacement using the accelerometers only, and to no surprise the reading, and the calculated displacement never matched the actual displacement, I suspect due to noise.

I tried to remove as much noise as possible by moving the watch stationary, vertically up a wall to a height, and then back down again to the start position.

Has anyone use the filter features in the Math class with success to filter accelerometer noise?

And, it looks like the IIR filter is or can be setup similarly to a Kalman filter since it has fed forwards filters?

Has anyone used it like this, or am I better off just setting up a stand alone Kalman?

Initially I am hoping to remove the higher frequency noise, but possibly also minor hand motion in a later step

Top Replies

All Replies

  • I ran a few experiments on calculating displacement using the accelerometers only

    FWIW You won't be able to integrate acceleration to deduce displacement. There's just too much noise. Any filtering will degrade accuracy. It's not possible. Submarines require multi-million-dollar gyros for INS. The  commercial chip in a watch won't cut the mustard.

  • And yet, someone has already done it.  https://youtu.be/FkhWCTsiJOs

    Any ideas why this code is giving me not enough arguments error?

    function kalman(U){

     

    	function kalman(U){
    		
    		
    	K = P*H/(H*P*H+R);	// updage kalman gain
    	Uhat=Uhat + K*(U-U*Uhat); // update estimate
    	P=(1-K*H)*P+Q; // update covariance error;
    		
    	}
    
    	function kalmanit() {
    
    	for ( var i = 0; i < power.size();i += 1){
    			Filter[i] = kalman(power[i]);
    		}
    		
    	}
    

  • And yet, someone has already done it

    I saw nothing in the video to indicate he was using the accelerometer.  

    Any ideas why this code is giving me not enough arguments error?

    No, it looks OK to me.

  • Hi, I'm using internal accelerometers based on PitchCounter sample to count use of ski poles (incl. distance of swings), for cross skating (number of pitches, distances between pitches), counting of spikes at Volleyball, pitch counter at table tennis... works perfect.

  • Well, that is the only sensor that can do what he demonstrated, and he didn't have a phone in his hand, so it must have been using accelerometers. 

  • forandy, are you using either of the filters?

  • Yep, Garmin Math.FirFilter , but again, look at the official Garmin sample "PitchCounter", good basis for any project in this area.

  • how do you calculate the Fir parameters ? as it's  mostly "undocumented" or very unclear in the doc and PitchCounter does'nt help !

  • he didn't have a phone in his hand, so it must have been using accelerometers. 

    The Apple Watch, like the Garmin has many sensors, not just accelerometer.

    In philosophy and science, it's not possible to prove a negative, but it's not just me pointing out the challenges to using an accelerometer to derive displacement (in the real world of metres and miles, not millimetres!).

    I'm sticking to the generally held position that:

    1. in the double integration
      1. from acceleration to speed then
      2. from speed to distance,
    2. in three dimensions
    3. in a device in which you also have to deduce its orientation from gyroscopes and magnetometers
    4. in a gravitational field that is usually significantly larger than the applied stimulus, 

    the errors accumulating will overwhelm your results within milliseconds.

    We'll all be delighted to be proved wrong.

  • I took the example, the Fir parameters are working perfect for my use case ... no need to tune. There are some other parameters around the filter in example, they can be tuned. Did you already check the example?

    In general there are tool in web to calculate Fir parameters, if you wonna use you should know the theory behind Fir filters.