socrob / autonomous_systems

Material used for learning ROS and robotics, as part of the Autonomous Systems course at Instituto Superior Tecnico
34 stars 9 forks source link

error getting wi fi information #15

Open ruiemcardoso opened 7 years ago

ruiemcardoso commented 7 years ago

i made a shell script which consists in a loop that returns wi fi readings, and it works well for about a minute, but after that i get the following message: "command failed: Device or resource busy (-16)".

i think this may be related to the fact that as we are using the computer's wi fi sensor, when it gets another task, it may not be able to continue providing us the information

The .sh file has this code:

num=1

 > medidaswifi.txt

while(num=1); do

    echo "New measurement" >> medidaswifi.txt

    date +%s >> medidaswifi.txt
    iw dev wlp3s0 scan | egrep "signal|wlp3s0" | sed -e "s/\tsignal: //" -e "s/\wlp3s0 //" >> medidaswifi.txt

    echo "\n\n" >> medidaswifi.txt

done
ruiemcardoso commented 7 years ago

I forgot to mention that I'm running ubuntu natively

oscar-lima commented 7 years ago
  1. please put an example of medidaswifi.txt
  2. the output of the command
    iw dev wlp3s0 scan
oscar-lima commented 7 years ago

in python try:

import os
wifi_readings = os.popen("iwlist wlp4s0 scanning | egrep 'Address|Signal'").read()

then process wifi readings to get only the info that you need

for example to remove spaces between lines:

import re
re.sub(' +',' ','The     quick brown    fox')
oscar-lima commented 7 years ago

also check : https://github.com/RMiyagusuku/ros-wifi-localization/blob/master/rss/src/rss/RSSImeasurement.py

lines 59-60

ruiemcardoso commented 7 years ago

We used the python code import os wifi_readings = os.popen("iwlist wlp4s0 scanning | egrep 'Address|Signal'").read()

and there's a problem: the wifi_readings string only has information about one of the access points.

oscar-lima commented 7 years ago

try disconnecting from the wifi, you will then get many

ruiemcardoso commented 7 years ago

indeed, we get more access points but in order to remotely control the robot we need to be connected to wi fi

oscar-lima commented 7 years ago

yes, you need a usb to wifi pendrive

ruiemcardoso commented 7 years ago

My group has been getting wi fi info this way, but we just noticed that the method used gives us the same information several times, needing too much time to change (10/20 sec)

oscar-lima commented 7 years ago

try out the method used in https://github.com/RMiyagusuku/ros-wifi-localization/blob/master/rss/src/rss/RSSImeasurement.py

but just the code that gets the readings ; )