asr_vosk: Allow to handle keyword and command in one sentence
[ros_wild_thumper.git] / scripts / rtl_sdr_strength.py
1 #!/usr/bin/env python
2 # -*- coding: iso-8859-15 -*-
3
4 import sys
5 import subprocess
6 import re
7 import rospy
8 import tf
9 import tf2_ros
10 from time import sleep
11
12 rospy.init_node('wifi_strength')
13
14 tfBuffer = tf2_ros.Buffer()
15 listener = tf2_ros.TransformListener(tfBuffer)
16 regex_lq = re.compile("Link Quality=(\d*)/(\d*)")
17 while not rospy.is_shutdown():
18         popen = subprocess.Popen("rtl_power -f 868.2M:868.5M:10k -g 42 -i 1".split(), stdout=subprocess.PIPE)
19         while True:
20                 line = popen.stdout.readline()
21                 if line == "":
22                         break
23                 power = line.replace("\n", "").split(",")[6:]
24                 power = [float(s) for s in power]
25                 pos = tfBuffer.lookup_transform("map", 'base_link', rospy.Time(0), rospy.Duration(1.0))
26                 print '{"x":%.2f, "y":%.2f, "power": %s},' % (pos.transform.translation.x, pos.transform.translation.y, power)
27                 sys.stdout.flush()