netNav - Turtle Pathfinding with Shared Networked Mapping System

Started by blunty666, Jun 16, 2019, 04:25 PM

Previous topic - Next topic

blunty666

netNav

Turtle pathfinding using the A* algorithm built on top of a networked shared mapping system
Originally posted on the old ComputerCraft forums, now tested to work on CC: Tweaked for Minecraft 1.12.2

Install from pastebin:
netNav API (install on turtles):
pastebin run J8azvLQg netnavMap Server Program (install on one networked computer):
pastebin run J8azvLQg remotemap_server
This is my latest and greatest attempt at creating a turtle navigation / pathfinding system. It is based heavily on my previous attempt starNav, but this time it uses a shared map system that lets all connected turtles share the same map data to masssively speed up the process of mapping the world.

netNav now also implements a modular scanning strategy, so if a mod adds a peripheral that performs some kind of scanning function you can easily create a new world scanning strategy that uses it, hopefully massively speeding up the process of mapping the world. Two examples of this are the sensor from OpenPeripherals and the scanner from Plethora, both of which have strategies already available and ready to use, see below on how to install them.

Plethora scanner strategy:
pastebin run J8azvLQg netnav_plethorastrategyOpenPeripherals sensor strategy:
pastebin run J8azvLQg netnav_openperipheralsstrategy
Video Demo:
The first half goes through the setup process. Skip to 5:23 to see it in action


Setup:

Map Server:
The map server is where all the map data is stored. Your turtles will connect to this server to send/receive the latest map data. It can be run from any type of computer, just make sure it is connected to a modem.
mapServer <map_save_folder> <map_server_name>
netNav API:
The turtle will require:
- A wireless modem - to connect to the Map Server and to GPS
- Full GPS coverage of the area you want to navigate
- Fuel!
- (Optional) A sensor from openPeripherals - helps to massively speed up the mapping process

Once the netNav API is loaded, make sure rednet is open on the turtle, then you'll need to specify the name of the Map Server to connect to. Once connected you can proceed to use the 'goto' function to start pathfinding. See demo script below that does the above:
-- OPEN REDNET
for _, side in ipairs({"left", "right"}) do
        if peripheral.getType(side) == "modem" then
                rednet.open(side)
        end
end
if not rednet.isOpen() then
        printError("Could not open rednet")
        return
end

-- SET netNav MAP
netNav.setMap(<map_server_name>, 15) -- the second argument determines how frequently the turtle will check with the server for newer map data

-- START PATHFINDING
netNav.goto(<xPos>, <yPos>, <zPos>)

Explore + Remote Control Program:
The explore program sets your turtles exploring the world to improve the map data stored on the server. To get the program running you'll need to specify the Map Server to connect to, and the min + max coordinates of the area to explore (to define a rectangle area/bounding box).
explore <map_server_name> <minX> <minY> <minZ> <maxX> <maxY> <maxZ>
The remote control then lets you control the turtles whilst they explore. You can control them individually, or all together. The remote lets you pause them, call them to your current position, or return to where they first started.
netNavRemote <map_server_name>
Map Viewer Program:
The map viewer program allows you to directly view the map data on the Map Server. Simply pass it the name of the Map Server as the first argument and it will connect automatically.
mapViewer <map_server_name>
Downloads:
All code is installed using the same pastebin installer script.

Map Server:
pastebin run J8azvLQg remotemap_servernetNav API:
pastebin run J8azvLQg netnavExplore program:
pastebin run J8azvLQg netnav_exploreRemote Control:
pastebin run J8azvLQg netnav_remoteMap Viewer Program:
pastebin run J8azvLQg remotemap_viewer
All code can also be viewed on GitHub.

poisoned

Ah, this is kind of "turtle gets through" labyrinth.
I will have a look at it.
But i for example  tried especially NOT 2 use the GPS...so the turtle really has to explore and set herself absolute in a relative World.
But for sure i (we ) r interested in your solutions.
:=)

poisoned

yeah, but in this moment i decided, that our little "proggi" is much more a toy then yours is.
:0)
But we want the same thing.
We also want the turtle to explore - interact and maybe share with other turtles.
Recreate her "tile map"block for block via command computer spawning them into the positions.
(so no melee, no mining no whatever turtle but a  _copyRecreate() - Turtle.....)

SO much fun. So much "problem-solving"...^^

poisoned

yo, this is really great - we tried it out, we worked us through and we love it!
And we like your video - u really made it "lookable" with touchscreen funcs etc.

Very "inspirable"

:0)

blunty666

Quote from: poisoned on Mar 26, 2021, 10:31 PMyo, this is really great - we tried it out, we worked us through and we love it!
And we like your video - u really made it "lookable" with touchscreen funcs etc.

Very "inspirable"

:0)

I'm very happy you like it!

I would love to see what you create using it!

SeigneurGhost

Hello, it looks great as programs but I tested in 1.19.2 (CraftOS 1.8) and it doesn't work. There is a problem with the registration of programs when placing the turtle on the disk drive (startup.lua:3 No such File)

and when launching the explore the turtle stops after 15s (rednet.lua:204: Too long without yielding).

For scan the environnement i use AdvancedPeripherals (environmentDetector)

Possible to update please? ^^' otherwise it looks great as a program