mirror of
https://github.com/kepler155c/opus
synced 2025-11-14 06:17:13 +00:00
relative-gps coord system
This commit is contained in:
@@ -5,10 +5,15 @@ end
|
||||
require = requireInjector(getfenv(1))
|
||||
local GPS = require('gps')
|
||||
|
||||
function turtle.enableGPS()
|
||||
local pt = GPS.getPointAndHeading()
|
||||
function turtle.enableGPS(timeout)
|
||||
if turtle.getState().coordSystem == 'GPS' then
|
||||
return turtle.point
|
||||
end
|
||||
|
||||
local pt = GPS.getPointAndHeading(timeout)
|
||||
if pt then
|
||||
turtle.setPoint(pt)
|
||||
turtle.getState().coordSystem = 'GPS'
|
||||
return true
|
||||
end
|
||||
end
|
||||
@@ -16,25 +21,15 @@ end
|
||||
function turtle.gotoGPSHome()
|
||||
local homePt = turtle.loadLocation('gpsHome')
|
||||
if homePt then
|
||||
local pt = GPS.getPointAndHeading()
|
||||
if pt then
|
||||
turtle.setPoint(pt)
|
||||
if turtle.enableGPS() then
|
||||
turtle.pathfind(homePt)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function turtle.setGPSHome()
|
||||
local GPS = require('gps')
|
||||
|
||||
local pt = GPS.getPoint()
|
||||
if pt then
|
||||
turtle.setPoint(pt)
|
||||
pt.heading = GPS.getHeading()
|
||||
if pt.heading then
|
||||
turtle.point.heading = pt.heading
|
||||
turtle.storeLocation('gpsHome', pt)
|
||||
turtle.gotoPoint(pt)
|
||||
end
|
||||
if turtle.enableGPS() then
|
||||
turtle.storeLocation('gpsHome', turtle.point)
|
||||
turtle.gotoPoint(tturtle.point)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user