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

Help with GPS api to make a tape measure (1.7.10 CC)

Started by xXAndrew28Xx, 20 January 2015 - 08:48 PM
xXAndrew28Xx #1
Posted 20 January 2015 - 09:48 PM
I'm kind of good at computercraft and know a bit of lua. I was wondering how I can use Gps (API) and Vector (API) on a advanced pocket computer to make a tape measure (measure the distance between two points). I read on the GPS api "there must be at least 4 computers used as gps hosts which will respond and allow trilateration". Can someone help me code a tape measure program with a simple gui? Maybe the program can have two modes (actual distance between two points) and another mode (it will tell you height difference, x axis difference, and y axis difference).
civilwargeeky #2
Posted 21 January 2015 - 02:36 AM
Hi. First, you need to set up a GPS network. The easiest way (that I know of) is to use this program. Once you have that. You then need to specify a starting point. Once you have specified a starting point you can update your GPS position however often you want and display the distance between the two on the screen.

I won't code a GUI for you, but that is what you put in the actual program :)/>
Edited on 21 January 2015 - 01:36 AM
Bomb Bloke #3
Posted 21 January 2015 - 03:36 AM
Exactly which bits are you asking for help with?

The basic idea seems simple enough. Have a button on the APC which records your current position by performing a GPS lookup to one variable. Have another button which performs another lookup, and compares the location you're at to the previously recorded one.

For eg,

local function recordPos()
  savedPos = vector.new(gps.locate())
end

local function comparePos()
  distanceBetween = savedPos - vector.new(gps.locate())
  print(distanceBetween:length())
end

Rig up some functions along these lines to run via touchpoint buttons or something, and you're done.
Lyqyd #4
Posted 21 January 2015 - 03:53 AM
I was going to post that Touchpoint didn't work on terminals (only monitors), but I decided to update it to work on terminals also. I'll update the OP of the Touchpoint topic with the details.
GopherAtl #5
Posted 21 January 2015 - 04:02 AM
someone should note, gps is not strictly required if you just want distance from A to B. Any two computers with modems will report the distance between them when recieving rednet messages. Of course, the program could be more convenient running on a tablet where you can just tap a button and walk out the distance to measure, but depending on your particular needs, it might be easier to just plonk a computer down.
Edited on 21 January 2015 - 03:03 AM