Posted 21 December 2016 - 01:47 PM
netNav
Turtle pathfinding using the A* algorithm built on top of a networked shared mapping system
Install from pastebin:
netNav API: pastebin run J8azvLQg netnav
Map Server: 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.
Video!:
A demo of the explore program I wrote to help map the world
[media]
http://www.youtube.com/watch?v=my8TubUddMI
[/media]
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 can be installed from the same pastebin installer script.
Map Server - pastebin run J8azvLQg remotemap_server
netNav API - pastebin run J8azvLQg netnav
Explore program - pastebin run J8azvLQg netnav_explore
Remote Control - pastebin run J8azvLQg netnav_remote
Map Viewer Program - pastebin run J8azvLQg remotemap_viewer
All code can also be viewed on GitHub.
Edited on 21 December 2016 - 12:48 PM