def run(self): global persons global persons_name global current_emotion_value global name_timeline global Tr_matrix global pub_vis value = [0] * 7 estimation_s = ['angry','disgust','fear','happy','sad','surprise','quiet'] msg_time = Bayesian() while True: time.sleep(0.2) for num in range(0,persons): current_time = time.time() - name_timeline[persons_name[num]] if current_time > 3: for var in range(0,7): for var2 in range(0,7): value[var] += Tr_matrix[estimation_s[var2]][estimation_s[var]] * current_emotion_value[persons_name[num]][estimation_s[var2]] all = 0 for var in range(0,7): all += value[var] for var in range(0,7): current_emotion_value[persons_name[num]][estimation_s[var]] = value[var] / all print current_emotion_value[persons_name[num]] name_timeline[persons_name[num]] = time.time() msg_time.estimation_value = [0] * 7 #msg_time.emotion = now_emo msg_time.name = persons_name[num] for var in range(0,7): msg_time.estimation_value[var] = current_emotion_value[persons_name[num]][estimation_s[var]] print "update" pub_vis.publish(msg_time)
def pub_info(name,now_emo,estimation_s): global current_emotion_value global pub global pub_vis msg = Bayesian() msg.estimation_value = [0] * 7 msg.emotion = now_emo msg.name = name for var in range(0,7): msg.estimation_value[var] = current_emotion_value[name][estimation_s[var]] time.sleep(0.4) pub.publish(msg) pub_vis.publish(msg)