1 / 15

Wifi-based localization with skyhook

Wifi-based localization with skyhook. Skyhook wifi-based localization. GPS has several drawbacks GPS uses significant energy (not good for battery powered things) GPS does not work indoors GPS uses satellites with high frequency radios. These signals are absorbed by walls

osman
Download Presentation

Wifi-based localization with skyhook

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Wifi-based localization withskyhook

  2. Skyhook wifi-based localization • GPS has several drawbacks • GPS uses significant energy (not good for battery powered things) • GPS does not work indoors • GPS uses satellites with high frequency radios. These signals are absorbed by walls • Wifi based localization • Collect a wifi signature • A set of base station MAC addresses (and signal strengths) • approaches • Look up in a table to determine the location of each base station, and then estimate location. • If wifi signatures are known in some known locations (e.g, known from gps), then we can interpolate between these wifi signatures to estimate the location of a different wifi signature • Different methods are examined in a different lectures • But how to collect all these signature-locations pairs • Drive around in cars and record pairs (common approach) • Use GPS to get location (also common) • Neither of these techniques will give location indoors. • In theory, you could do this yourself indoors. But that is expensive

  3. Get skyhook SDK from skyhookwireless.com and decompress • Start a new project with two buttons (start and stop) and onClickListeners • Import SkyHookWireless.jar • In eclipse, right click on src folder • Select build path • Select configure • Select Libraries tab • click “add external jar” button • Navigate and select the SkyHookWireless.jar file, which is in the SkyHookWireless/lib folder where the SkyHook SDK was decompressed • THEN, select Order and Export tab, and select wpsapi.jar • Go to your java source, at the top type import com.skyhookwireless.*;

  4. (see skyhookwireless quick start information for up to date information) • Set permissions • Internet • CHANGE_WIFI_STATE • ACCESS_WIFI_STATE • ACCEESS_CORSE_LOCATION • ACCESS_FINE_LOCATION

  5. In SkyHookTestActivity • Add member variables • WPS wps = null; // for wifi only • //XPS xps = null; // for wifi and gps • In onCreate (optional) • wps = new WPS(this); • //xps = new XPS(this); • // make directory to save skyhook location maps. In theory, you can save enough of them so that you do not need network access and can still determine location. Android localization always requires network access, even GPS requires network access • // make dir • File externalStorage = Environment.getExternalStorageDirectory(); // get path to sdcard • File skyhookCacheDirectory = new File(externalStorage.getAbsolutePath()+"/skyhook/"); • skyhookCacheDirectory.mkdir(); • // set up tiling • int _maxDataSizePerSession = 100000000; // a lot of data, so we should get everuthing we need. • int _maxDataSizeTotal = _maxDataSizePerSession; • wps.setTiling(skyhookCacheDirectory.getAbsolutePath(), _maxDataSizePerSession, _maxDataSizeTotal, null); • //xps.setTiling(skyhookCacheDirectory.getAbsolutePath(), _maxDataSizePerSession, _maxDataSizeTotal, null);

  6. In SkyHookTestActivity • In SkyHookTestActivity • Add variables • WPSAuthentication auth = null; • In onCreate, add • auth = new WPSAuthentication("bohacek", "udel"); • // bohacek = the user name and udel = domain I used to get sdk • And make start button onClickListener • Button start = (Button)findViewById(R.id.start); • start.setOnClickListener(new View.OnClickListener(){}); • In onClickListener, add • wps.getLocation(auth, WPSStreetAddressLookup.WPS_NO_STREET_ADDRESS_LOOKUP, callback); • // callback is defined on the next slide

  7. MyWPSLocationCallback callback = new MyWPSLocationCallback(); • class MyWPSLocationCallback implements WPSLocationCallback { • intcnt = 0; • public void done() { • cnt = 0; • Log.d("skyhooktest","done"); // after done() returns, you can make more WPS calls. • } • public WPSContinuationhandleError(WPSReturnCode error) { • switch (error) { • case WPS_ERROR: Log.d("skyhooktest","errorSoe other error occurred."); break; • case WPS_ERROR_LOCATION_CANNOT_BE_DETERMINED: Log.d("skyhooktest","error: A location couldn't be determined."); break; • case WPS_ERROR_NO_WIFI_IN_RANGE: Log.d("skyhooktest","error: No Wifi reference points in range."); break; • case WPS_ERROR_SERVER_UNAVAILABLE: Log.d("skyhooktest","error: The server is unavailable."); break; • case WPS_ERROR_UNAUTHORIZED: Log.d("skyhooktest","error:User authentication failed."); break; • case WPS_ERROR_WIFI_NOT_AVAILABLE: Log.d("skyhooktest","error: No Wifi adapter was detected."); break; • case WPS_OK: Log.d("skyhooktest","error: ok"); break; • } • if (cnt++<10) • return WPSContinuation.WPS_CONTINUE; //try again • else • return WPSContinuation.WPS_STOP; • }

  8. class MyWPSLocationCallback continued • public void handleWPSLocation(WPSLocationskyhookLocation) { • Log.e("skykooktest","lat="+ skyhookLocation.getLatitude()+" long="+ skyhookLocation.getLongitude() ); • if (skyhookLocation.hasHPE()) • Log.e("skykooktest","accuracy in meters: "+ skyhookLocation. getHPE ()); • else • Log.e("skykooktest","unknown accuracy"); • Log.e("skykooktest","altitude="+ skyhookLocation.getAltitude()+" number of cell towers used="+ skyhookLocation.getNCell()+" number access pts used: "+ skyhookLocation. getNAP()); • Log.e("skykooktest","speed: "+skyhookLocation.getSpeed()+" bearing (degrees): "+skyhookLocation.getBearing()); • } • }; • run

  9. Periodic location • In the start button onClickListener, replace • wps.getLocation(auth, WPSStreetAddressLookup.WPS_NO_STREET_ADDRESS_LOOKUP, callback); • With • wps.getPeriodicLocation(auth, WPSStreetAddressLookup.WPS_NO_STREET_ADDRESS_LOOKUP, 0, 0, callback);

  10. Replace • class MyWPSLocationCallback implements WPSLocationCallback …. • With • class MyWPSLocationCallback implements WPSLocationCallback, WPSPeriodicLocationCallback … • In MyWPSLocationCallback, add function • @Override • public WPSContinuationhandleWPSPeriodicLocation(WPSLocationskyhookLocation) { • Log.d("skykooktest","lat="+ skyhookLocation.getLatitude()+" long="+ skyhookLocation.getLongitude()+” accuracy: “+ skyhookLocation. getHPE ()); • return WPSContinuation.WPS_CONTINUE; • // return WPSContinuation.WPS_STOP; // if we wanted to stop • In onCreate, make a onClickListener for stop button and add code • wps.abort();

  11. Instead of wps, use xps to include gps, i.e., • Instead of • WPS wps = null; • Use • XPS xps= null; • Instead of • wps = new WPS(this); • Use • xps = new XPS(this); • Instead of • wps.abort • Use • xps.abort() • Instead of • wps.getLocation(auth, WPSStreetAddressLookup.WPS_NO_STREET_ADDRESS_LOOKUP, callback); • Use • xps.getLocation(auth, WPSStreetAddressLookup.WPS_NO_STREET_ADDRESS_LOOKUP, callback); • But use the same callback

  12. Test some more • Add textbox • Open res/layout/main.xml • Drag textView to layout • Change id to skyhookInfo • In SkyHookTestActivity, add member variable • TextViewskyhookInfoTextView = null; • In onCreate, add • skyhookInfoTextView = (TextView)findViewById(R.id.skyhookInfo); • Problem: MyWPSLocationCallback is called from some other trhead, not the UI (user interface thread). So you cannot access UI components from the callback • If you do, weird things happen that you will never ever debug (you’ll be lucky if things crash. But they ,might not!) • Two solutions • Use broadcastReceiver. We’ll do this often later. So let’s try something else • Use runOnUiThread function • Make function in SkyHookTestActivity • public void setText(String str) { • final String textToShow = str; • runOnUiThread(new Runnable() { • @Override • public void run() { • if (textToShow!=null) • skyhookInfoTextView.setText(textToShow); • } • });}

  13. Get output when location is updated • In MyWPSLocationCallback:: handleWPSPeriodicLocation, add • String str = new String(); • str += "lat="+ skyhookLocation.getLatitude()+" long="+ skyhookLocation.getLongitude()+"\n"; • if (skyhookLocation.hasHPE()) • str += "accuracy in meters: "+ skyhookLocation. getHPE ()+"\n"; • else • str += "unknown accuracy\n"; • str += "altitude="+ skyhookLocation.getAltitude()+" number of cell towers used="+ skyhookLocation.getNCell()+"number access pts used: "+ skyhookLocation. getNAP() + "\n"; • str += "speed: "+skyhookLocation.getSpeed()+" bearing (degrees): "+skyhookLocation.getBearing()+"\n"; • setText(str); • Also, add something similar to done and error • Run • Just to test, try calling skyhookInfoTextView.setText(str) from handleWPSPeriodicLocation. Check out logcat to see if anything weird happens (it should) • Run some more and watch location, accuracy, and see if it stops

  14. skyHookvs Android Location services • SkyHook uses wifi, so, in theory, one can get location indoors • However, skyhook seems to only record wifi access points from outside (they drive cars around) • However, it is possible to register access point locations • On the other hand, these access points are usually indoors, and so they can be received indoors and skyhook can give a rough location. GPS gives you nothing indoors. • Skyhook can only get location through polling, whereas android location services can provide proximity alerts (so your app is called only when you exit or enter a region) • I don’t know how android proximity alerts are implemented. For example, they might poll, in which case skyhook is the same (except that the android code might be better than your own polling code) • Advanced proximity alerts could do things like • adjust the polling frequency according to how close you are to the region (if you are very far from the region and not moving, don’t poll for along time, allowing the phone to sleep and save energy) • Use the accelerometer to determine if the phone is moving. If not moving, then don’t poll location. • Skyhook also requires a license. • Skyhook uses wifi, which uses more energy than using cell towers. I’m not sure if gps of skyhook uses more power • Both approaches use energy to get map information, • For android, once you have the gps or cell phone tower, you need to use data connection to get the map information • For skyhook, you need to download the wifi map. However, you can download wifi maps for a large region, reducing the time between accessing the network • You might even be able to download the full datebase • Skyhook is a bit buggy. • Try it and let me know. • Walk around and watch for error messages in periodic mode • In periodic mode, you might get some errors, but it should keep on going • Watch is periodic mode gives up (it should just keep on going)

  15. Deployment models • See http://www.skyhookwireless.com/devices/deploymentmodels.php • Tiling • http://groups.google.com/group/skyhook/browse_thread/thread/d024a13b8e4a8fef?hl=en • getHPE gives accuracy in meters • http://grail.cba.csuohio.edu/~matos/notes/cis-493/lecture-notes/Android-Chapter24-LocationServices.pdf

More Related