Added script to log wifi strength
authorErik Andresen <erik@vontaene.de>
Sat, 20 Oct 2018 18:04:09 +0000 (20:04 +0200)
committerErik Andresen <erik@vontaene.de>
Sat, 20 Oct 2018 18:04:09 +0000 (20:04 +0200)
scripts/wifistrength.py [new file with mode: 0755]

diff --git a/scripts/wifistrength.py b/scripts/wifistrength.py
new file mode 100755 (executable)
index 0000000..496c7b2
--- /dev/null
@@ -0,0 +1,25 @@
+#!/usr/bin/env python
+# -*- coding: iso-8859-15 -*-
+
+import os
+import re
+import rospy
+import tf
+import tf2_ros
+from time import sleep
+
+rospy.init_node('wifi_strength')
+
+tfBuffer = tf2_ros.Buffer()
+listener = tf2_ros.TransformListener(tfBuffer)
+regex_lq = re.compile("Link Quality=(\d*)/(\d*)")
+while not rospy.is_shutdown():
+       f = os.popen("export LANG=C; /sbin/iwconfig wlan0")
+       for line in f:
+               line = line.strip()
+               match_lq = regex_lq.match(line)
+               if match_lq is not None:
+                       lq = float(match_lq.group(1)) / float(match_lq.group(2))
+                       pos = tfBuffer.lookup_transform("map", 'base_link', rospy.Time(0), rospy.Duration(1.0))
+                       print "{'x':%.2f, 'y':%.2f, 'link':%.2f}," % (pos.transform.translation.x, pos.transform.translation.y, lq)
+                       sleep(0.5)