From cf1ec643629b1b2f3d33ab67ce4851714c02bf5a Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Sat, 20 Oct 2018 20:04:09 +0200 Subject: [PATCH] Added script to log wifi strength --- scripts/wifistrength.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 scripts/wifistrength.py diff --git a/scripts/wifistrength.py b/scripts/wifistrength.py new file mode 100755 index 0000000..496c7b2 --- /dev/null +++ b/scripts/wifistrength.py @@ -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) -- 2.39.2