Reply
Thread Tools
zvogt's Avatar
Posts: 118 | Thanked: 67 times | Joined on Dec 2009 @ Saint Louis, MO, USA
#1
My question is about the example script at the bottom of this wiki page: http://wiki.maemo.org/PyMaemo/Using_Location_API The script runs fine, and returns a Latitude and Longitude consistenly and quickly with no errors. But my symptom is this: no matter where I go it always returns the SAME latitude and longitude. If I run the script from my office about 12 miles away I see the same values that I see when I run it from my house. (The values themselves are very near my house.) I've been playing with this for several days, and today I learned something new. If I launch Maep the script will start behaving as expected, but as soon as I quit Maep it will return to the bad behavior. I've done lots of reboots and this behavior is very consistent and repeatable. Does anyone know what about Maep causes the example script to work, and perhaps more importantly how to get that magic "something" to occur on start-up?
 
Posts: 35 | Thanked: 17 times | Joined on Aug 2009
#2
I've noticed that the OMWeather widget has the same problem. If one of the location slots is configured to use GPS, it will show a location based on the last time some other app correctly triggered a location lookup.

The example script you are referring to is more or less identical to the C version on the API page for liblocation:

http://wiki.maemo.org/Documentation/...g_Location_API

I'm curious if that example has the same problem.

Last edited by tuxfoo; 2010-03-24 at 00:56. Reason: "to" not "too"
 
schettj's Avatar
Posts: 501 | Thanked: 292 times | Joined on Nov 2009
#3
Sounds like it doesn't physically turn on the GPS hardware. So you'd need to do that yourself somehow. Perhaps the location widget would work?
 
noobmonkey's Avatar
Posts: 3,203 | Thanked: 1,391 times | Joined on Nov 2009 @ Worthing, England
#4
it does turn it on for me, but i have to loop it for a while to get any new readouts.....
__________________
----------- Follow me on Twitter here
----------- My Photography Website and Blog is here
----------- Author of the N900 Health Check Application ----------- New Version in Extras Devel (Dec 2010 - 2.9.10)
----------- Are you on the N900 World Map? - http://pininthemap.com/maemo - masterpin: shotgun
----------- What apps do you want to see on the n900 or in MeeGo in the future? -
 
Posts: 35 | Thanked: 17 times | Joined on Aug 2009
#5
I tried the python script out myself and it gave me an incorrect position. I then commented out the data.stop() call in on_changed. The first lat/lon pair was the same as my first run (incorrect). I noticed that the GPS icon was blinking in the status area, then went solid. The second and subsequent lat/lon pairs that the script reported were correct. I used CTRL-C to stop the script. The next time I ran it, it started with correct numbers.

I suspect it is responding with the last known position immediately (or possibly garbage if it had no last known position). I'm guessing inspecting some of the fields in the fix object would help you figure out if you want to continue waiting for a better location fix.


UPDATE: The eph field in the fix contains the accuracy in cm. I modified the script to output that value as well (its the next field in the fix array after lat/lon). I then rebooted my device and ran the script. The first pair it gave me was incorrect again (lon=0.000) with an accuracy of about 268 miles. The second run gave me a correct location, with accuracy of about 0.25 mile. Note that I currently have GPS disabled in my location settings (so it is relying on network positioning). So, I'd just check eph until you get some sort of reasonable position. This is actually mentioned on the page I linked to above, though it doesn't explicitly make it clear that you should expect to receive values are unreasonably inaccurate.

Last edited by tuxfoo; 2010-03-24 at 01:24.
 

The Following 2 Users Say Thank You to tuxfoo For This Useful Post:
zvogt's Avatar
Posts: 118 | Thanked: 67 times | Joined on Dec 2009 @ Saint Louis, MO, USA
#6
I did exactly as you suggested and added an additonal check to the If statement to only output a value if device.fix[6] is less than a constant number (mine was consistently returning NaN for the first iteration), and it works exactly as expected. It now takes 2 or 3 seconds to return a (good) value, instead of returning a (bad) value in a fraction of a second. Thanks tuxfoo, and everyone else that responded. Forums are awesome.
 
Posts: 287 | Thanked: 165 times | Joined on Oct 2009 @ The Netherlands
#7
Originally Posted by tuxfoo View Post
I modified the script to output that value as well (its the next field in the fix array after lat/lon).
Originally Posted by zvogt View Post
I did exactly as you suggested and added an additonal check to the If statement to only output a value if device.fix[6] is less than a constant number (mine was consistently returning NaN for the first iteration), and it works exactly as expected.
Would one of you care to update the example on the wiki with your changes?

Thx, Rob
 
Posts: 1 | Thanked: 0 times | Joined on Jul 2010 @ Ontario
#8
would someone please update the example on the wiki??
yes, i'm another noob, especially when it comes to python. (and yes this is a whiney post)

I've been researching for weeks on how to access the GPS via the command line and I've gotten so close only to find a broken script.

edit:

dammit, I'll do it myself. I commented out the data.stop() in the wiki
but I'll add this here. (adds a loop to only check the GPS 6 times, plus gives an idea of accuracy from displaying how many sattelites are actually in use, 9 at a time is the maximum the n900 can do)


Code:
x = 0
def on_changed(device, data):
    if not device:
        return
    if device.fix:
        if (device.fix[1] & location.GPS_DEVICE_LATLONG_SET) and (device.fix[1] & location.GPS_DEVICE_TIME_SET) and not (device.status & location.GPS_DEVICE_STATUS_NO_FIX):
            print "%f, %f, %dm above sea level" % (device.fix[4:6] + (device.fix[7],))
            print "                                               satellites in use: %d" % (device.satellites_in_use)
            global x
            x = x + 1
            if x == 6:
              data.stop()

Last edited by joel_c; 2010-07-17 at 02:35.
 
Posts: 7 | Thanked: 1 time | Joined on Sep 2009
#9
Hello,

after PR1.3 update, the python-location api causes segmentation fault during "import location".
Could someone have a look at it? Thanks...
 
Reply


 
Forum Jump


All times are GMT. The time now is 20:46.