1
0
mirror of https://github.com/kepler155c/opus synced 2025-10-17 00:37:39 +00:00

relative-gps coord system

This commit is contained in:
kepler155c@gmail.com
2017-05-24 19:48:48 -04:00
parent 64146f8625
commit e6ee432997
11 changed files with 62 additions and 57 deletions

View File

@@ -67,6 +67,7 @@ function turtle.run(fn, ...)
end
if id == ticketId then
turtle.abort = false
turtle.resetState()
local args = { ... }
local s, m = pcall(function() fn(unpack(args)) end)
turtle.abort = false

View File

@@ -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

View File

@@ -50,6 +50,17 @@ function turtle.reset()
return true
end
function turtle.resetState()
--turtle.abort = false -- should be part of state
--turtle.status = 'idle' -- should be part of state
state.moveAttack = noop
state.moveDig = noop
state.moveCallback = noop
state.locations = {}
return true
end
local actions = {
up = {
detect = turtle.native.detectUp,