]> defiant.homedns.org Git - pyshared.git/blobdiff - simple_kalman.py
Bootloader: Allow to set i2c addr
[pyshared.git] / simple_kalman.py
index d3d36ef1c5874592d758cbdfa0a28f6479af6b48..5e61328f0da086a034a75c5699a2c2cf6cfc6aea 100755 (executable)
@@ -38,6 +38,11 @@ class simple_kalman:
                if x.shape == (1,1): return x.item(0,0)
                return x
 
+       def set_measure_cov(self, R):
+               if type(R) != type(np.matrix([0])): R = np.matrix(R)
+               if np.all(R >= np.zeros([2,2])):
+                       self.R = R
+
 
 if __name__ == '__main__':
        import random
@@ -85,9 +90,9 @@ if __name__ == '__main__':
 
        for i in range(0, 100):
                # Messwert
-               a = p.run(np.array([[y1[i], y2[i]]]).T)
-               x1.append(a.item((0, 0)))
-               x2.append(a.item((1, 0)))
+               result = p.run(np.array([[y1[i], y2[i]]]).T)
+               x1.append(result.item((0, 0)))
+               x2.append(result.item((1, 0)))
 
        plot(orig1, label="Orig")
        plot(orig2, label="Orig")