-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpublisher.py
54 lines (46 loc) · 1.21 KB
/
publisher.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#
# Weather update server
# Binds PUB socket to tcp://*:5556
# Publishes random weather updates
#
import time
import zmq
import sys
sys.path.append("..")
import config
from random import randrange
from DataProvider.lib.MedianFilter import MedianFilter
context = zmq.Context()
pub = context.socket(zmq.PUB)
pub.bind(config.DATA_SOCK)
axmf = MedianFilter(5)
aymf = MedianFilter(5)
azmf = MedianFilter(5)
gxmf = MedianFilter(5)
gymf = MedianFilter(5)
gzmf = MedianFilter(5)
mxmf = MedianFilter(5)
mymf = MedianFilter(5)
mzmf = MedianFilter(5)
while True:
ax = randrange(1, 100)
ay = randrange(1, 100)
az = randrange(1, 100)
gx = randrange(1, 100)
gy = randrange(1, 100)
gz = randrange(1, 100)
mx = randrange(1, 100)
my = randrange(1, 100)
mz = randrange(1, 100)
ax = axmf.filt(ax)
ay = aymf.filt(ay)
az = azmf.filt(az)
gx = gxmf.filt(gx)
gy = gymf.filt(gy)
gz = gzmf.filt(gz)
mx = mxmf.filt(mx)
my = mymf.filt(my)
mz = mzmf.filt(mz)
print("sending %i %i %i %i %i %i %i %i %i" % (ax, ay, az, gx, gy ,gz, mx, my, mz))
pub.send_string("%s %i %i %i %i %i %i %i %i %i" % (config.IMU_TOPIC, ax, ay, az, gx, gy ,gz, mx, my, mz))
time.sleep(0.020) # 50hz