forked from HengyiWang/Co-SLAM
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathredis_test.py
More file actions
32 lines (22 loc) · 825 Bytes
/
Copy pathredis_test.py
File metadata and controls
32 lines (22 loc) · 825 Bytes
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
import redis
import pickle
import numpy as np
import datetime
# Redis connection
redis_client = redis.StrictRedis(host='localhost', port=6379, db=0, decode_responses=False)
while True:
# send data
# send data
theta_i = np.random.rand(1633360).astype(np.float32)
uncertainty_i = np.random.rand(1633360).astype(np.float32)
msg = {'theta_i':theta_i, 'uncertainty_i':uncertainty_i}
pickled_data = pickle.dumps(msg)
redis_client.set('agent_i', pickled_data )
# get data
agent_j = redis_client.get('agent_j')
if agent_j:
print(f"{datetime.datetime.now()}: receive agent j!")
agent_j = pickle.loads(agent_j)
array_1 = agent_j['theta_j']
array_2 = agent_j['uncertainty_j']
print(f'theta_j = {array_1.shape}, uncertainty_j= {array_2.shape}')