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

pocketgps - waypoints, heading and distance!

Started by Lyqyd, 29 March 2014 - 07:52 AM
Lyqyd #1
Posted 29 March 2014 - 08:52 AM
Here's a quick script I whipped up tonight to take advantage of the wireless pocket computers. Its features include a waypoint system, the users's last heading, and the coordinates of and distance to their current destination. You can add new Places to your list, either manually or using your current coordinates. You can also remove or edit your saved Places from within the program. Simply right-click on the delete button next to a Place to remove it and start creating a new Place based on its information.

PocketGPS can also trace your route with the new tracing feature. Simply press "t" or click the tracing button on the main page to activate tracing. Press it again to stop tracing and save the traced coordinates. Traces are saved in "trace", and subsequent traces are saved as "trace2", "trace3", etc. The other button, "Open Doors" is designed to be compatible with oeed's Ultimate Door Lock. If you don't already have a fingerprint file saved on the pocket computer, you can press "f" on the main screen to generate one. You can then place it in your door lock's disk drive as you would with a normal PDA to add the fingerprint to the white list. Clicking the "Open Doors" button so that it is green will cause it to open doors in the vicinity.

Here are some screenshots to show it off:

SpoilerInitial screen:


List of saved locations:


Creating a new saved place from your current coordinates:


Showing distance and destination information, as well as heading:

I have yet to create the Goto page (hopefully soon!), which will simply be a way to quickly and directly enter coordinates for your destination without needing to save a Place.

You can download pocketgps from pastebin: wQaGzaK7, or simply: pastebin get wQaGzaK7 pgps
theoriginalbit #2
Posted 29 March 2014 - 09:02 AM
Awesome! As always, looks amazing :)/>

I think that this could be awesome if it were to wirelessly communicate back to an OpenP Glasses Bridge, and actually have selected waypoints displayed on the specific users glasses! :)/>
oeed #3
Posted 29 March 2014 - 09:15 AM
Is heading just based on the users previous movement or have you got some wizardry that works it out another way?
Bomb Bloke #4
Posted 29 March 2014 - 09:36 AM
Heh. I was wondering if the default "gps" script blocking pocket computers would be symptomatic of underlying issues actually preventing it from working. Guess not! :)/>

Suddenly find myself wishing that pocket computers could be held like maps, or even crafted together with maps to grant them map-like detection powers… Granted their resolution / colour depth is limiting, but..
theoriginalbit #5
Posted 29 March 2014 - 09:41 AM
Heh. I was wondering if the default "gps" script blocking pocket computers would be symptomatic of underlying issues actually preventing it from working. Guess not! :)/>
well its only the GPS hosting ability that it blocks, which I think is fair enough, how is it meant to make sure its always accurately broadcasting its location when you're the one that tells it where its located when starting the host.
Bomb Bloke #6
Posted 29 March 2014 - 10:05 AM
Ah, that makes sense - I'd only read your summary of the change and not looked at the actual code behind it. :P/>
theoriginalbit #7
Posted 29 March 2014 - 10:17 AM
Ah, that makes sense - I'd only read your summary of the change and not looked at the actual code behind it. :P/>
Ah sorry, my bad :P/> fixed
Edited on 29 March 2014 - 09:17 AM
nateracecar5 #8
Posted 29 March 2014 - 12:47 PM
Awesome! As always, looks amazing :)/>

I think that this could be awesome if it were to wirelessly communicate back to an OpenP Glasses Bridge, and actually have selected waypoints displayed on the specific users glasses! :)/>

I've messed with the glasses bridge before. Have you ever used CCGlasses? Try it out! (I think that's what it's called, it's google glasses for the bridge)
theoriginalbit #9
Posted 29 March 2014 - 12:49 PM
I've messed with the glasses bridge before. Have you ever used CCGlasses? Try it out! (I think that's what it's called, it's google glasses for the bridge)
Are you talking about the Glasses that OpenPeripheral adds?
CometWolf #10
Posted 29 March 2014 - 12:50 PM
I've messed with the glasses bridge before. Have you ever used CCGlasses? Try it out! (I think that's what it's called, it's google glasses for the bridge)
Are you talking about the Glasses that OpenPeripheral adds?
hahahahahaha!
nateracecar5 #11
Posted 29 March 2014 - 12:57 PM
When I first boot it up, and goto a waypoint, you can get this as your distance:
Spoiler

Maybe a little something for you to try and work out? ;)/>

I've messed with the glasses bridge before. Have you ever used CCGlasses? Try it out! (I think that's what it's called, it's google glasses for the bridge)
Are you talking about the Glasses that OpenPeripheral adds?

Maybe I'm talking about a different mod then you. It's the terminal glasses. Am I right?
Edited on 29 March 2014 - 11:56 AM
theoriginalbit #12
Posted 29 March 2014 - 12:59 PM
When I first boot it up, and goto a waypoint, you can get this as your distance:
-image snip-
Maybe a little something for you to try and work out? ;)/>
That seems like a strange artefact, 'cause from the quick look at the code that I had, the math for Euclidean distance is correct for Euclidean distance, as are all the variables that get punched into the calculation; have fun with that one Lyqyd!

Maybe I'm talking about a different mod then you. It's the terminal glasses. Am I right?
Yes the Terminal Glasses are added by OpenPeripheral which is developed by the OpenMods team. Pretty sure I've used them. :P/>
Edited on 29 March 2014 - 12:06 PM
GravityScore #13
Posted 29 March 2014 - 03:03 PM
Awesome! It would be cool if you could add the ability to command turtles to follow you, and go to waypoints! :P/>
awsmazinggenius #14
Posted 29 March 2014 - 03:42 PM
Nice program, but as I said in another topic (granted, this one actually has some features, making it much better), I don't really see how this is better than a minimap, simply because of the way pocket computers work, how when you have them open you can't do anything.
dudearent006 #15
Posted 29 March 2014 - 05:34 PM
This could be great as a CC-only navigation device! What if the user doesn't like minimaps, e.g. think they take up too much space on the screen?

One feature I would recommend adding is allowing you to enter your spawn point co-ordinates, and use the vanilla compass item as a direction reference. So, on the PDA's screen would be an image of the compass with the needle facing in a certain direction, and if you turn so the vanilla compass points in the same direction, you'd be facing the right way.

My explanation is terrible, I hope you get what i'm trying to say. This could allow for orienting yourself underground without the F3 info, or for those too lazy to judge which way is north/south from the clouds. It also allows for more accurate heading, compared to the mere 90 degrees precision north, south, east and west.
Lyqyd #16
Posted 29 March 2014 - 05:47 PM
Awesome! As always, looks amazing :)/>

I think that this could be awesome if it were to wirelessly communicate back to an OpenP Glasses Bridge, and actually have selected waypoints displayed on the specific users glasses! :)/>

Thanks! Glasses integration would be a cool feature, but (not having worked with them before), I feel like it would be computationally expensive to try to correctly place a waypoint marker based on GPS data from the pocket computer and (hopefully!) orientation data from the glasses. If orientation data isn't available, it's probably not feasible to make it look reasonably good.

Is heading just based on the users previous movement or have you got some wizardry that works it out another way?

It's based on looking at the difference between the current location and the previous. It also checks to make sure the change was large enough since it has some weird catching-up issues as you stop that were throwing off orientation detection.

When I first boot it up, and goto a waypoint, you can get this as your distance:
Spoiler

Maybe a little something for you to try and work out? ;)/>

Well, since that is extremely close to zero (2.8 x 10 ^ -14), I'd say it's relatively close to accurate. It's probably a floating point rounding error more than anything else.

Awesome! It would be cool if you could add the ability to command turtles to follow you, and go to waypoints! :P/>

That would be kinda cool, though they can be kind of slow at times. I am considering adding a feature that would be for use with turtles, but not this exactly.

Nice program, but as I said in another topic (granted, this one actually has some features, making it much better), I don't really see how this is better than a minimap, simply because of the way pocket computers work, how when you have them open you can't do anything.

There are a couple minor advantages, such as better situational awareness and an easier-to-escape interface for adding waypoints than some minimaps have. There may be more reasons to use them as well down the road, as they become more fully-featured.
Lyqyd #17
Posted 29 March 2014 - 09:15 PM
I've added the Goto screen, as well as a couple of new features on the main screen.

The Tracing feature allows you to trace out a path and save the coordinates in a file. Adventurous users could use these traces to rapidly program GPS-enabled turtles to follow known good paths.

The Open Doors feature adds compatibility with oeed's door lock. If your pocket computer doesn't already have a fingerprint, you can generate one with "f". Toggling the Open Doors button will open any doors in the vicinity that the pocket GPS is whitelisted on.

One feature I would recommend adding is allowing you to enter your spawn point co-ordinates, and use the vanilla compass item as a direction reference. So, on the PDA's screen would be an image of the compass with the needle facing in a certain direction, and if you turn so the vanilla compass points in the same direction, you'd be facing the right way.

My explanation is terrible, I hope you get what i'm trying to say. This could allow for orienting yourself underground without the F3 info, or for those too lazy to judge which way is north/south from the clouds. It also allows for more accurate heading, compared to the mere 90 degrees precision north, south, east and west.

This is kind of a neat idea, but the GPS location fetching seems to have some delays. Once you stand still and open the interface, it seems to update a couple of times before it actually catches up to your current position. That sort of delay makes a compass less useful. I'll keep this in mind as a potential future feature, though. :)/>
theoriginalbit #18
Posted 29 March 2014 - 11:14 PM
Thanks! Glasses integration would be a cool feature, but (not having worked with them before), I feel like it would be computationally expensive to try to correctly place a waypoint marker based on GPS data from the pocket computer and (hopefully!) orientation data from the glasses. If orientation data isn't available, it's probably not feasible to make it look reasonably good.
Yeah possibly. Yeah thinking about this again it could be fairly computationally expensive, a sensor would reduce that as you'd have an accurate heading and you'd also have pitch (or is it yaw, or is it both, mental blank) so that you could have it displayed more accurately on the glasses.
gollark8 #19
Posted 04 April 2014 - 07:46 AM
I would really like to have a feature where a central server broadcasts a picture of the location,with the data being entered on the server or from a PDA,and then displays a picture of the area.
I know it would be very hard to code,but it would be an interesting feature.
Edited on 04 April 2014 - 05:47 AM
oeed #20
Posted 04 April 2014 - 08:44 AM
I would really like to have a feature where a central server broadcasts a picture of the location,with the data being entered on the server or from a PDA,and then displays a picture of the area.
I know it would be very hard to code,but it would be an interesting feature.

Ditto. I've been thinking about making a more visual GPS program but I'm not really sure how to go about it.
Lyqyd #21
Posted 04 April 2014 - 05:46 PM
I would really like to have a feature where a central server broadcasts a picture of the location,with the data being entered on the server or from a PDA,and then displays a picture of the area.
I know it would be very hard to code,but it would be an interesting feature.

This is an interesting idea. I suppose some OCS integration could be done on a program to read data off of maps and then make that data available to the pocket computers. The coding wouldn't be horrendously difficult, depending on a variety of things. I'll look into this more soon, as I have time available.
CastleMan2000 #22
Posted 21 April 2014 - 06:13 PM
pgps:439:attempt to call nil

I get this error when trying to add a place, whether manually or with current. It works great for telling me my location, and it seems that tracing works too, but because of this I can't add places. It seems to perhaps actually add them, because when I check .places it has the coordinates and the name. I love this program, please fix this bug :)/>
Lyqyd #23
Posted 21 April 2014 - 06:36 PM
Okay, I've updated the paste in the first post. Try the updated version. I added a couple forward declarations that should fix the bug, but I'm not able to test it just now. If that doesn't solve it, I'll take another look at this as soon as I can.
CastleMan2000 #24
Posted 21 April 2014 - 08:20 PM
That seems to have fixed it, although the display of the coordinates cuts off the name of the place a little. Thanks!
Lyqyd #25
Posted 21 April 2014 - 08:30 PM
Yep, there's limited space on the places screen. I prioritized coordinates over place names, so if the coordinates are large, it will be difficult to see the name. One thing that helps with setting places from current coordinates is to truncate the coordinates to just integer values.

Glad that seems to have fixed it!
CastleMan2000 #26
Posted 21 April 2014 - 08:33 PM
It seems like truncating might be more efficient, because the gps reading from a pocomp is already slightly inaccurate. Maybe you could make it so you could click something and it would show the coords? Maybe even click the place, and then it opens up a menu to look at the name, maybe a description, the coordinates, and then a button to set it as a destination?
Ashton #27
Posted 04 August 2014 - 09:59 PM
Just a thought, but would it be possible to add a command to teleport to a waypoint (op only, of course — or possibly by linking authorized players to a pc with a command block set to teleport to variables as co-ordinates?) Would be an awesome solution for when a player says "hey, something's wrong at (location)" an op could just click the waypoint and click 'teleport' and it will drop you in.
Lyqyd #28
Posted 04 August 2014 - 10:42 PM
I feel like that functionality is a little too niche to be included in the program, sorry. However, if you play with a minimap mod as well, some of those have the option to teleport to your waypoints.
RlonRyan #29
Posted 14 August 2014 - 07:23 PM
I hope you don't mind if I add this to my computer setup suite? Of course all credit will be given to you.
Lyqyd #30
Posted 14 August 2014 - 07:53 PM
This program is released under the MIT license.
RlonRyan #31
Posted 14 August 2014 - 08:02 PM
This program is released under the MIT license.

Good for you!
LDDestroier #32
Posted 03 October 2014 - 08:16 PM
My god, this looks cool. You should add a minimap to it too! It would just look like a flat square with special characters placed where the waypoints are, and if they are beyond the map, place them on the edge. That would be so awesome!
ninja4523 #33
Posted 21 November 2014 - 10:44 PM
I have a problem with this program that causes it to erase all my waypoints every time I trace my location. I don't know why it does this but if you could please try to fix it I would be very happy.
Lyqyd #34
Posted 22 November 2014 - 01:24 AM
I'm having trouble reproducing the problem. Can you list exactly what you do in order to make the behavior appear? Good reproduction instructions will make the issue easier to find.
ninja4523 #35
Posted 22 November 2014 - 02:10 PM
First I put in a location to save then I go to the next location I want to save and I hit t then I put in the name of the trace that I created and I try to run the trace like a program but when I go back into pgps all my waypoints are gone.
Lyqyd #36
Posted 22 November 2014 - 09:09 PM
I'm a little confused by the "try to run the trace like a program" part. I'll try to play around with it a bit more to see if I can reproduce the issue. You definitely shouldn't be losing all of your saved places.

Just to clarify, though. The tracing feature only saves a list of coordinates in a file that you can use for other things later. The trace files are just information. They can't be run like a program, or used within pocketgps.
ninja4523 #37
Posted 24 November 2014 - 03:01 PM
Oh thanks for telling me that. I had no idea how the trace system worked before. All I knew was that you hit t then it saved your location.
Zareks #38
Posted 23 February 2015 - 12:48 AM
I am currently making a control center for an airship/flying base of awesomeness, and this is alot like one of the features i am looking to integrate… i am wondering if i have your permission to deconstruct and use the pieces of code and such i need to make it happen… with credit of course.

Aaand i feel dumb xD shoulda read before opening my mouth xD credit will still be provided though (speaking of the MIT liscense of course)
Edited on 22 February 2015 - 11:50 PM
Rougeminner #39
Posted 27 February 2015 - 04:47 AM
Dang it… YOU BEAT ME TO IT! :D/>
LDDestroier #40
Posted 01 January 2016 - 06:22 AM
Your GPS program has tracing and compatibility with oeed's pda lock, but I made the only graphical minimap on the forums (to my knowledge). PasteID: x9ajKSc0

</shamelessSelfPlug>

I barely get any replies, boo hoo…
KillerTheSkyLord #41
Posted 05 January 2016 - 09:04 AM
Looks like a great app I wish there were pocket OSes :(/>
sjones321 #42
Posted 15 February 2016 - 03:13 AM
I get an error when starting it up, tracing pgps: 486 : attempt to call nil
Before i had a gps tower up it just said tracing with nothing else.
Lyqyd #43
Posted 15 February 2016 - 05:16 AM
Hmm. That line shouldn't be causing errors. Have you edited the script at all?

If haven't, go into the lua prompt and type in the below two lines and post the results.


unpack
vector.new
LDShadowLord #44
Posted 21 February 2016 - 08:47 PM
I'm having the same issue, Lyqyd. "unpack" returns "nil" and "vector.new" returns "function: 1e6e756e".
Lyqyd #45
Posted 22 February 2016 - 05:04 AM
I just updated the paste. The new version will hopefully not error on that line any more.