Active Topics

 


Reply
Thread Tools
Posts: 217 | Thanked: 20 times | Joined on Jan 2010
#1
Ok, here is the code:


PHP Code:
import location
import gobject

def on_error
(controlerrordata):
    print 
"location error: %d... quitting" error
    data
.quit()

def on_changed(devicedata):
    if 
not device:
        return
    if 
device.fix:
        if 
device.fix[1] & location.GPS_DEVICE_LATLONG_SET:
            print 
"lat = %f, long = %f" device.fix[4:6]
            
#data.stop()

def on_stop(controldata):
    print 
"quitting"
    
data.quit()

def start_location(data):
    
data.start()
    return 
False

def get_speed
(devicedata):
    if 
not device:
        return
    if 
device.fix:
        if 
device.fix[1] & location.GPS_DEVICE_SPEED_SET:
            print 
"lat = %f, Speed %s Km/h" device.fix[speed]
            
on_changed
            
#data.stop()

#i = 0
loop gobject.MainLoop()
control location.GPSDControl.get_default()
device location.GPSDevice()
control.set_properties(preferred_method=location.METHOD_USER_SELECTED,
                       
preferred_interval=location.INTERVAL_DEFAULT)

control.connect("error-verbose"on_errorloop)
#while i < 2:
    #device.connect("changed", get_speed, control)
device.connect("changed"on_changedcontrol)
    
#print i,
#    i = i + 1
control.connect("gpsd-stopped"on_stoploop)

gobject.idle_add(start_locationcontrol)

loop.run() 
I am trying to understand it.
I have read:
http://pymaemo.garage.maemo.org/pyth...ual/index.html
http://wiki.maemo.org/PyMaemo/Using_Location_API

I can not get the speed.
My goal is to create a table with speed captured every 1 second, preferently, every 0,1 if it is posible.
I can not full understand how loop works, is it a eternal loop?

I will be more than happy only with someone pointing me in the right direction.

Thanks
 
Posts: 217 | Thanked: 20 times | Joined on Jan 2010
#2
I have tryied with

device.fix[speed]
device.fix[11]
device.fix.speed

I use to program with PHP5.
 
noobmonkey's Avatar
Posts: 3,203 | Thanked: 1,391 times | Joined on Nov 2009 @ Worthing, England
#3
are you getting nan returned?

in my previous trials i needed a speciffic gps connection.... it seems to select auto instead of a specific 1.
__________________
----------- 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: 217 | Thanked: 20 times | Joined on Jan 2010
#4
Yes! I got nan or 37.08 all the time.

What do you mean with speciffic gps connection?
 
noobmonkey's Avatar
Posts: 3,203 | Thanked: 1,391 times | Joined on Nov 2009 @ Worthing, England
#5
Originally Posted by dhcmega View Post
Yes! I got nan or 37.08 all the time.

What do you mean with speciffic gps connection?
there are 4 types. will post a link tmorrow. out on the N900 at the mo!
__________________
----------- 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: 217 | Thanked: 20 times | Joined on Jan 2010
#6
will be waiting!! thanks
 
Posts: 217 | Thanked: 20 times | Joined on Jan 2010
#7
maybe your refere to this:

control.set_properties(preferred_method=location.M ETHOD_AGNSS)
 
noobmonkey's Avatar
Posts: 3,203 | Thanked: 1,391 times | Joined on Nov 2009 @ Worthing, England
#8
ahaaaaaaaaaa yup, GNSS,ACWP and CWP? i think
i did find there is something not right with it.. but after being left on and updating it works - prob is GNSS takes a while to connect correctly.
__________________
----------- 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: 217 | Thanked: 20 times | Joined on Jan 2010
#9
Well well
I went outside and tryed on my car.

This is the code I have used:
PHP Code:
cat speed.py
import location
import gobject

def on_error
(controlerrordata):
    print 
"location error: %d... quitting" error
    data
.quit()

def on_changed(devicedata):
    if 
not device:
        print 
"no device"
        
return
    if 
device.fix:
        if 
device.fix[1] & location.GPS_DEVICE_LATLONG_SET:
            print 
"lat = %f, long = %f" device.fix[4:6]
            
#data.stop()
        
else:
            print 
"no fix 1"
    
else:
        print 
"no fix"

def on_stop(controldata):
    print 
"quitting"
    
data.quit()

def start_location(data):
    
data.start()
    return 
False

def get_speed
(devicedata):
    if 
not device:
        return
    if 
device.fix:
        if 
device.fix[1] & location.GPS_DEVICE_SPEED_SET:
            print 
"Speed %s Km/h" device.fix[11]
            
#data.stop()

#i = 0
loop gobject.MainLoop()
control location.GPSDControl.get_default()
device location.GPSDevice()
control.set_properties(preferred_method=location.METHOD_GNSS,
                       
preferred_interval=location.INTERVAL_1S)

control.connect("error-verbose"on_errorloop)
device.connect("changed"on_changedcontrol)
device.connect("changed"get_speedcontrol)
control.connect("gpsd-stopped"on_stoploop)

gobject.idle_add(start_locationcontrol)

loop.run() 
And this is the output:

~ $ python speed.py
lat = -34.586280, long = -58.408385
Speed 3.348 Km/h
lat = -34.586278, long = -58.408383
Speed 3.348 Km/h
lat = -34.586301, long = -58.408358
Speed 2.772 Km/h
lat = -34.586307, long = -58.408351
Speed 2.772 Km/h
lat = -34.586303, long = -58.408354
Speed 0.468 Km/h
lat = -34.586299, long = -58.408353
Speed 0.468 Km/h
lat = -34.586303, long = -58.408344
Speed 3.996 Km/h
lat = -34.586304, long = -58.408335
Speed 1.656 Km/h
lat = -34.586297, long = -58.408338
Speed 2.16 Km/h
lat = -34.586293, long = -58.408339
Speed 0.468 Km/h
lat = -34.586263, long = -58.408375
Speed 0.324 Km/h
lat = -34.586243, long = -58.408394
Speed 0.108 Km/h
lat = -34.586228, long = -58.408405
Speed 0.648 Km/h
lat = -34.586205, long = -58.408417
Speed 0.864 Km/h
lat = -34.586193, long = -58.408416
Speed 0.324 Km/h
lat = -34.586190, long = -58.408416
Speed 0.252 Km/h
lat = -34.586185, long = -58.408416
Speed 0.396 Km/h
lat = -34.586179, long = -58.408416
Speed 0.324 Km/h
lat = -34.586174, long = -58.408418
Speed 0.324 Km/h
lat = -34.586172, long = -58.408418
Speed 0.396 Km/h
lat = -34.586169, long = -58.408418
Speed 0.756 Km/h
lat = -34.586170, long = -58.408418
Speed 2.772 Km/h
lat = -34.586171, long = -58.408417
Speed 2.628 Km/h
lat = -34.586177, long = -58.408421
Speed 4.932 Km/h
lat = -34.586196, long = -58.408428
Speed 8.424 Km/h
lat = -34.586230, long = -58.408443
Speed 15.048 Km/h
lat = -34.586275, long = -58.408481
Speed 22.392 Km/h
lat = -34.586317, long = -58.408514
Speed 21.024 Km/h
lat = -34.586373, long = -58.408556
Speed 26.82 Km/h
lat = -34.586445, long = -58.408612
Speed 35.316 Km/h
lat = -34.586518, long = -58.408705
Speed 43.092 Km/h
lat = -34.586631, long = -58.408774
Speed 50.796 Km/h
lat = -34.586740, long = -58.408851
Speed 48.564 Km/h
lat = -34.586834, long = -58.408923
Speed 44.352 Km/h
lat = -34.586914, long = -58.409000
Speed 40.068 Km/h
lat = -34.587010, long = -58.409057
Speed 43.164 Km/h
lat = -34.587091, long = -58.409102
Speed 43.164 Km/h
lat = -34.587155, long = -58.409140
Speed 43.164 Km/h
lat = -34.587239, long = -58.409203
Speed 36.684 Km/h
lat = -34.587313, long = -58.409279
Speed 35.568 Km/h
lat = -34.587394, long = -58.409336
Speed 36.252 Km/h
lat = -34.587486, long = -58.409389
Speed 39.528 Km/h
lat = -34.587582, long = -58.409450
Speed 41.832 Km/h
lat = -34.587711, long = -58.409454
Speed 41.22 Km/h
lat = -34.587794, long = -58.409487
Speed 41.22 Km/h
lat = -34.587870, long = -58.409542
Speed 34.236 Km/h
lat = -34.587968, long = -58.409550
Speed 34.236 Km/h
lat = -34.588051, long = -58.409541
Speed 22.068 Km/h
lat = -34.588103, long = -58.409549
Speed 22.068 Km/h
lat = -34.588144, long = -58.409555
Speed 15.012 Km/h
lat = -34.588189, long = -58.409553
Speed 18.072 Km/h
lat = -34.588201, long = -58.409586
Speed 13.86 Km/h
lat = -34.588154, long = -58.409622
Speed 16.56 Km/h
lat = -34.588097, long = -58.409685
Speed 27.288 Km/h
lat = -34.588049, long = -58.409739
Speed 27.288 Km/h
lat = -34.588010, long = -58.409780
Speed 27.288 Km/h
lat = -34.587981, long = -58.409811
Speed 27.288 Km/h
lat = -34.587957, long = -58.409836
Speed 27.288 Km/h
lat = -34.587937, long = -58.409857
Speed 27.288 Km/h
lat = -34.587922, long = -58.409870
Speed 27.288 Km/h
lat = -34.587922, long = -58.409870
Speed 27.288 Km/h
As you can see, by looking at the lat and log, when I am not moving, speed is a fixed number, but when moving, it is prettry acurate.
 
noobmonkey's Avatar
Posts: 3,203 | Thanked: 1,391 times | Joined on Nov 2009 @ Worthing, England
#10
sounds as though it is trying to get a fix.... and almost chasing yourself in circles.......
Will take a proper look tomorrow
__________________
----------- 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? -
 
Reply


 
Forum Jump


All times are GMT. The time now is 06:33.