From: Erik Andresen Date: Sat, 20 Oct 2018 18:04:09 +0000 (+0200) Subject: Added script to log wifi strength X-Git-Url: https://defiant.homedns.org/gitweb/?p=ros_wild_thumper.git;a=commitdiff_plain;h=cf1ec643629b1b2f3d33ab67ce4851714c02bf5a;hp=c1769fc7f88e8ce879c7a8a9308338eb0df14bd7 Added script to log wifi strength --- 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)