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):
Code Select
pastebin run J8azvLQg netnavMap Server Program (install on one networked computer):
Code Select
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:
Code Select
pastebin run J8azvLQg netnav_plethorastrategyOpenPeripherals sensor strategy:
Code Select
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.
Code Select
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:
Code Select
-- 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).
Code Select
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.
Code Select
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.
Code Select
mapViewer <map_server_name>
Downloads:
All code is installed using the same pastebin installer script.

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