pytrack sample code
-
@dan
can you share the code you used. -
@abhishek2101 I'm using our Pytrack example: https://github.com/pycom/pycom-libraries/blob/master/pytrack/main.py
-
@dan
I am outside with pytrack having access to open sky.following is the code
from L76GNSS import L76GNSS from pytrack import Pytrack py = Pytrack() l76 = L76GNSS(py, timeout=30) while (True): coord = l76.coordinates() print(coord)still after 20 minutes I only see (none, none).
One only I saw coordinate values but that came in after approx 40 minutes.
How are we suppose to use pytrack if it takes so long to lock onto satellites (that too, not always) or am I missing anything. Please help.
-
@abhishek2101 said in pytrack sample code:
@dan
I am outside with pytrack having access to open sky.following is the code
from L76GNSS import L76GNSS from pytrack import Pytrack py = Pytrack() l76 = L76GNSS(py, timeout=30) while (True): coord = l76.coordinates() print(coord)still after 20 minutes I only see (none, none).
One only I saw coordinate values but that came in after approx 40 minutes.
How are we suppose to use pytrack if it takes so long to lock onto satellites (that too, not always) or am I missing anything. Please help.
need to fix this asap, can somebody help.
-
@abhishek2101 said in pytrack sample code:
I am outside with pytrack having access to open sky.
You have to learn more about the GPS stuff. The pycom library is very basic, you have to know more anyway or have to use a third party library.
You need wide area of clear sky, nice weather and no noise on the frequencies. It needs some time for the GPS chip to see enough satellites for a triangulation. If you just outside a building or next to a steep mountain, you may be in the shadow of this obstacle.
Your phone will do some tricks. First it guesses your position from the last call. It uses a frequently loaded file of statellite positions to reduce search time. Additional it may guess your postion by lookng for a set of known WiFis and their signal strength.
The pycom module does none of this tricks. So locking needs longer. In some cases a better antenna or a better position will solve the connection problem, but there is no connector for an external antenna :(
-
@abhishek2101 said in pytrack sample code:
@dan
Google maps on my iPhone shows my location at the same place within few seconds.Apples and oranges.
A pure GPS device (like the Pytrack) needs to following to find its position:
- the almanac, which gives a list of their satellites, their orbits, correction parameters, etc.
- signal from at least 4 satellites, from which it will derive their position (ephemeris) and differential time of arrival.
The full almanac takes at least 12.5 minutes to receive (provided you can actually receive the signal from at least one satellite), as the GPS signal has very very low bandwidth (50 bits/s) and only a small part of it is available for the almanac. Note that those 12.5 minutes start from the time the GPS receiver has locked onto at least one satellite, which may take a while as well.
Locking on satellites may take a few minutes. It's a lot faster once you have an almanac and know your approximate position as you'll know which satellites should be visible. Otherwise it's just a matter of scanning for them. The almanac is also required for correction data.
A phone does several things very differently, because it has access to the Internet. The GPS is actually often used as a last resort:
-
first, it uses nearby cell towers and Wi-Fi APs. It sends a list of what it "sees" to a server, which in turn gives it a position. This is often done in the background, so when you start the app, the phone actually already knows its position. Depending on the environment, this position may be very accurate, or a lot less. This is visible with the "circle of confidence" shows in maps (the light blue disc around the small blue dot). In dense urban environments, it's usually nearly as precise as GPS, and it works indoors.
-
if the phone decides to actually use the GPS chip, it can retrieve the almanac (and more) from the Internet instead of receiving it over GPS
-
it already knows its approximate position, so it makes it easier to select satellites to scan for
-
once if has locked onto satellites, it will adjust the position it thought it had with the (usually) more precise GPS location.
Now, back to the "pure GPS" Pytrack: it is normal for it to take a while especially at first (not sure if/how the chip actually saves data for future uses), as it needs to receive the almanac, and find satellites. Once it has locked on enough satellites, it should be able to deliver a position pretty quickly.
You should probably try to dump more information from the GPS chip so see what's going on. Also note that the
L76GNSS.pymodule is pretty basic (for instance it only parses GPS data, while the chip is capable of using other GNSS). You should explore alternatives, such as: -
@dan it may make sense to add links to those libraries in the documentation (tutorials and reference).
Actually, reading https://forum.pycom.io/topic/2992/pytrack-gps-library-only-works-with-glonass-derived-positions again, the Pycom lib only listens for GLONASS signals (GNGLL) and ignores GPS signals (GPGLL). This should definitely be fixed. It's probably a matter of adding something like:
if gngll_idx < 0: gngll_idx = nmea.find(b'GPGLL')just after line 58. Didn't try it (don't have a Pytrack).
-
-
@dan
so which libraries I should use ? -
@abhishek2101 you can try both, whichever works
-
@dan
can you link them here please. -
@abhishek2101 they're linked below in @jcaron's post:
...
You should probably try to dump more information from the GPS chip so see what's going on. Also note that theL76GNSS.pymodule is pretty basic (for instance it only parses GPS data, while the chip is capable of using other GNSS). You should explore alternatives, such as:
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login