fix: Enhance GPS position retrieval with increased timeout and logging
This commit is contained in:
@@ -54,15 +54,19 @@ print("ID: " .. os.getComputerID())
|
|||||||
|
|
||||||
-- GPS Functions
|
-- GPS Functions
|
||||||
local function updatePosition()
|
local function updatePosition()
|
||||||
local x, y, z = gps.locate(2)
|
print("Requesting GPS position...")
|
||||||
|
local x, y, z = gps.locate(10) -- Increased timeout to 10 seconds
|
||||||
if x then
|
if x then
|
||||||
state.position = {x = math.floor(x), y = math.floor(y), z = math.floor(z)}
|
state.position = {x = math.floor(x), y = math.floor(y), z = math.floor(z)}
|
||||||
|
print("GPS position: " .. x .. ", " .. y .. ", " .. z)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
print("GPS timeout - no position received")
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
local function setHome()
|
local function setHome()
|
||||||
|
print("Setting home position...")
|
||||||
if updatePosition() then
|
if updatePosition() then
|
||||||
state.homePosition = {
|
state.homePosition = {
|
||||||
x = state.position.x,
|
x = state.position.x,
|
||||||
|
|||||||
Reference in New Issue
Block a user