Adedoyinjames commited on
Commit
efa4d48
·
verified ·
1 Parent(s): 94f9cd3

Create magnetometer.py

Browse files
Files changed (1) hide show
  1. magnetometer.py +15 -0
magnetometer.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import time
3
+
4
+ EARTH_FIELD = np.array([22.0, 0.0, -44.0])
5
+ NOISE_STD = 0.2
6
+
7
+ def read(x, y, z):
8
+ noise = np.random.normal(0, NOISE_STD, 3)
9
+ field = EARTH_FIELD + noise
10
+ return {
11
+ "Bx": float(field[0]),
12
+ "By": float(field[1]),
13
+ "Bz": float(field[2]),
14
+ "timestamp": time.time()
15
+ }