This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
luochen1990's profile picture

Why does gps.locate() fail occasionally?

Started by luochen1990, 12 February 2020 - 03:52 AM
luochen1990 #1
Posted 12 February 2020 - 04:52 AM
From [this post](http://www.computercraft.info/forums2/index.php?/topic/29887-will-rednet-lost-packet/) I know that the rednet doesn't simulate packet lose and network delay, And since gps is based on rednet, why does gps.locate() fail occasionally?

Considering that I have confirmed that I'm near the gps host servers, what is the exact situation in which gps.locate() will fail occasionally? And how can I avoid them and make sure gps.locate() always success?
Lupus590 #2
Posted 12 February 2020 - 08:50 AM
The best setup has the host servers out of plane with each other. Here's a tutorial with a good screenshot http://www.computercraft.info/forums2/index.php?/topic/3088-how-to-guide-gps-global-position-system/

Also, make sure that your coordinates on your hosts are the positions of the block with the modem on it (the computer) and not the modem itself
luochen1990 #3
Posted 12 February 2020 - 09:12 AM
@Lupus590 Thanks for your reply. My GPS host servers works well, and most of the time gps.locate() can success, but it also fails occasionally, So I'm asking about the reason why it fails occasionally, since rednet doesn't simulate packet lose and network delay, I think the result should be certain (always success or always fail at a specific position).
Lupus590 #4
Posted 12 February 2020 - 10:45 AM
What is the return value of GPS.locate or the output of the GPS program when it fails?
luochen1990 #5
Posted 13 February 2020 - 03:29 AM
local x, y, z = gps.locate()

when success, x, y and z are numbers, when fail, they are nil
Lupus590 #6
Posted 13 February 2020 - 08:32 AM
Can you add a print(GPS.locate(nil, true)) near everywhere you do GPS.locate() please