def train_means_coll(self): #anchors anc = ac.getAnchors() anchors = anc['anchors'] anchors_ids = anc['anchors_ids'] # drop old self.db['train_means'].drop() train_map = self.db[self.train_map_name] coords = train_map.find().distinct('coords') rssi_means = [] # list of averages; 1 for each coordinate i = 0 for c in coords: print i, 'train coord:', c i += 1 l = [] for a in anchors_ids: tuples = train_map.find({ 'coords': { "y": c['y'], "x": c['x'], "z": c['z'] }, 'id': a }) row = [t['rssi'] for t in tuples] l.append(row) l = np.asarray(l) rssi_mean = np.mean(l, axis=1) rssi_mean = rssi_mean.tolist() mean = {'rssi': rssi_mean, 'coords': c} rssi_means.append(mean) #insert in mongo self.db['train_means'].insert(rssi_means)
def __init__(self, udp_port): self.trilateration = trilateration.Trilateration() self.fingerprinting = fingerprinting.Fingerprinting() self.start = time.time() #anchors anc = ac.getAnchors() self.anchors = anc['anchors'] self.anchors_ids = anc['anchors_ids'] self.anchor_id_keys = anc['idKeys'] #kalman self.history_length = 100 n = len(self.anchors) x0 = np.array([[-50], [0]]*n)#np.zeros((n*2,1)) P0 = np.diag([20]*(2*n))#np.zeros((2*n,2*n)) self.kalman = kalman.Kalman(x0, P0) self.estimates_history = [[] for i in range(0,(len(self.anchors)))] #inizialization as list of empty lists (as many lists as the number of anchors) self.last_times = np.zeros((n,1)) self.last_time = None #udp self.dao = DAO.UDP_DAO("localhost", udp_port) #Receive data (from nodered 12346, from simulation 12348) self.data_interval = -1000 #1000 self.min_diff_anchors_ratio = 0.75 self.min_diff_anchors = 8 #math.ceil(len(self.anchors)*self.min_diff_anchors_ratio) assert n >= self.min_diff_anchors, 'Not enough anchors: ' + str(n) # model self.alpha = 1.9 #0.9722921 self.TxPower = -67.5 self.decimal_approximation = 3 self.batch_size = 1 #if 0: batch_size = len(measures) else batch_size = self.batch_size self.techniques = ['localization_trilateration_kalman', 'localization_trilateration_unfiltered', 'localization_fingerprinting_kalman', 'localization_fingerprinting_unfiltered']
def __init__(self): self.localization = localization.Localization() self.start = time.time() #anchors anc = ac.getAnchors() self.anchors = anc['anchors'] self.anchors_ids = anc['anchors_ids'] self.anchor_id_keys = anc['idKeys'] #kalman self.history_length = 100 n = 3 #x,y,z #len(self.anchors) x0 = np.array([[0.5], [0]] * n) #np.zeros((n*2,1)) P0 = np.diag([20] * (2 * n)) #np.zeros((2*n,2*n)) self.kalman = kalman.Kalman(x0, P0) self.estimates_history = [ [] for i in range(0, (len(self.anchors))) ] #inizialization as list of empty lists (as many lists as the number of anchors) self.last_times = np.zeros((n, 1)) self.last_time = None #udp self.dao = DAO.UDP_DAO("localhost", 12348) #Receive data (from nodered) self.data_interval = 0 #1000 self.min_diff_anchors_ratio = 0.75 self.min_diff_anchors = 3 #math.ceil(len(self.anchors)*self.min_diff_anchors_ratio) self.alpha = 1.7 #1.9 #0.9722921 self.TxPower = -72 self.decimal_approximation = 3 self.batch_size = 0 #if 0: batch_size = len(measures) else batch_size = self.batch_size self.techniques = ['localization_kalman', 'localization_unfiltered']
def __init__(self): self.udp_address = '127.0.0.1' self.udp_port = 12346 self.data_interval = 1000 self.min_diff_anchors_ratio = 0.75 self.alpha = 0.9722921 self.TxPower = -66.42379 self.udp_dao = udpy.UDP_DAO(self.udp_address, self.udp_port) self.anchors = bc.getAnchors() self.min_diff_anchors = math.ceil(len(self.anchors)*self.min_diff_anchors_ratio) self.decimal_approximation = 3
def __init__(self): train_map_name = 'train_means' test_map_name = 'test' self.k = 9 #anchors anc = ac.getAnchors() anchors = anc['anchors'] anchors_ids = anc['anchors_ids'] #get mongo collection mongo = MongoClient() db = mongo.fingerprinting # db train_map = db[train_map_name] # train collection #test_map = db[test_map_name] # test collection self.rssi_means = list(train_map.find( )) # list of lists rssi averages; 1 list for each coordinate print 'Fingerprinting'
def __init__(self): self.localization = localization.Localization() #anchors anc = ac.getAnchors() self.anchors = anc['anchors'] self.anchors_ids = anc['anchors_ids'] self.anchor_id_keys = anc['idKeys'] #kalman self.history_length = 5 n = len(self.anchors) x0 = np.zeros((n * 2, 1)) P0 = np.ones((2 * n, 2 * n)) #np.diag([1]*(2*n)) self.kalman = kalman.Kalman(x0, P0, self.history_length) #udp self.dao = DAO.UDP_DAO("localhost", 12346) self.data_interval = 0 #1000 self.min_diff_anchors_ratio = 0.75 self.min_diff_anchors = 4 #math.ceil(len(self.anchors)*self.min_diff_anchors_ratio) self.alpha = 0.9722921 self.TxPower = -66.42379 self.decimal_approximation = 3 #batch of measures self.dist_history = []
from pymongo import MongoClient import ast import anchor as a import anchors_config as ac import where_is_berry as wib import time import datetime import measure location = 'test' _id = 'test2' #anchors anc = ac.getAnchors() anchors = anc['anchors'] anchor_id_keys = anc['idKeys'] #mongo mongo = MongoClient() db = mongo.fingerprinting # db """ 'models' collection: 'id': univocal for place and time 'location': description of the location 'anchors': dictionary of anchors: key: anchor id value: coordinates 'timestamp' """ models = db.models # collection of models of different rooms assert models.count({'id': _id