Gorzoid 10 Posted February 23, 2015 Share Posted February 23, 2015 Changed it up, it now uses navigation upgrade instead of motion sensor so you can now walk anywhere and drone will follow as long as you are close enough to both it and a labled waypoint. Sadly though it is alot laggier because of the delay in navigation.findWaypoints() I could implement code to use it less frequently by translating positions of waypoints after moving but for now this is fine. Code: EEPROM: --Follow Script EEPROM local PORT_FOLLOW = 0xbf01 local MAX_DIST = 100 local drone = component.proxy(component.list("drone")()) local modem = component.proxy(component.list("modem")()) local nav = component.proxy(component.list("navigation")()) modem.open(PORT_FOLLOW) local function findClient() while true do local evt,_,sender,port,dist,msg = computer.pullSignal() if evt == "modem_message" and port == PORT_FOLLOW and dist < MAX_DIST and msg == "FOLLOW_REQUEST_LINK" then drone.setStatusText("Linked: "..sender:sub(1,3)) modem.send(sender,port,"FOLLOW_LINK") return sender end end end local function getNearbyNodes(justLabels) local waypoints = nav.findWaypoints(MAX_DIST) local nodes = {} for i = 1,waypoints.n do if justLabels then nodes[i] = waypoints[i].label else local wp = waypoints[i] nodes[wp.label] = wp.position end end return nodes end local client,nodes,noResponse = findClient(),getNearbyNodes() local timeout = computer.uptime() + 10 while true do local evt,_,sender,port,dist,msg,label,ox,oy,oz = computer.pullSignal(timeout - computer.uptime()) if moving and drone.getOffset() < 0.5 then moving = false nodes = getNearbyNodes() end if not evt then if noResponse then return end noResponse = true; modem.send(client,PORT_FOLLOW,"HEARTBEAT_REQUEST") timeout = timeout + 1 elseif evt == "modem_message" and sender == client and port == PORT_FOLLOW and dist < MAX_DIST then if msg == "HEARTBEAT_RESPONSE" then noResponse = false elseif msg == "HEARTBEAT_REQUEST" then modem.send(sender,port,"HEARTBEAT_RESPONSE") elseif msg == "POS_UPDATE" and not moving then local node = nodes[label] if not node then modem.send(sender,port,"UPDATE_NODES",label,table.unpack(getNearbyNodes(true))) else drone.move(node[1] - ox, node[2] - oy, node[3] - oz) moving = true modem.send(sender,port,"OK") end end timeout = computer.uptime() + 10 end end Client --Follow Script Client local PORT_FOLLOW = 0xbf01 local component = require("component") local event = require("event") local os = require("os") local modem = component.modem local nav = component.navigation modem.open(PORT_FOLLOW) local function findDrone() modem.broadcast(PORT_FOLLOW,"FOLLOW_REQUEST_LINK") local _,_,sender,port,_,msg = event.pull("modem_message",nil,nil,PORT_FOLLOW,nil,"FOLLOW_LINK") return sender end local drone = findDrone() local function heartbeatHook(_,_,sender,port,_,msg) if sender == drone and port == PORT_FOLLOW and msg == "HEARTBEAT_REQUEST" then modem.send(sender,port,"HEARTBEAT_RESPONSE") end end event.listen("modem_message",heartbeatHook) modem.send(drone,PORT_FOLLOW,"POS_UPDATE") local nodes = {select(7,event.pull("modem_message",nil,drone,PORT_FOLLOW,nil,"UPDATE_NODES"))} local function getNode() local tbl = nav.findWaypoints(100) for i=1,tbl.n do local label = tbl[i].label for i2=1,#nodes do if label == nodes[i2] then return label,table.unpack(tbl[i].position) end end end end while true do local label,x,y,z = getNode() print(label,x,y,z) modem.send(drone,PORT_FOLLOW,"POS_UPDATE",label,x,y,z) local args = {select(6,event.pull("modem_message",nil,drone,PORT_FOLLOW,nil))} if table.remove(args,1) == "UPDATE_NODES" then nodes = args end os.sleep(0.1) end Instructions for install: Insert an empty eeprom into your computer edit /dev/eeprom Paste the eeprom code and save. Paste the client code into either /usr/ or your mounted disk drive if you are using floppy disk of openos. Create a drone with navigation upgrade and wireless network card and the eeprom you made. (If you already have drone put it in crafting grid with your eeprom) Instructions for use: Start drone first Then open client Done. (You gotta use Ctrl+Alt+C to escape because I am lazy) Tell me what you guys would prefer? Motion sensors with limited range and portability but good accuracy and good speed. Navigation getPosition with very good range, medium portability and good speed. Navigation waypoints with good range, very high portability, and bad speed. Quote Link to post Share on other sites
opencomputersfan 0 Posted October 16, 2015 Share Posted October 16, 2015 I am not a OpenComputers programmer i just like to play around with open computers and opencomputers programs so can you please tell me how i can get this working? Quote Link to post Share on other sites
Gorzoid 10 Posted October 17, 2015 Author Share Posted October 17, 2015 I am not a OpenComputers programmer i just like to play around with open computers and opencomputers programs so can you please tell me how i can get this working? Ehh this is quite old, not sure if it works, but I think you need to download the file at https://gist.github.com/fnuecke/6bcbd66910b946b54ec7 and use the flash command to flash that file onto an eeprom (you can see how on the drones tutorial here https://www.youtube.com/watch?v=W5JTRKdup7s) then download this and save to client.lua make sure a wireless card is on the drone and the computer and u also need a motion sensor on the computer. once you have done that you should be able to turn on the drone and then run the program, be sure to edit the client.lua to set the positions of the motion sensor and drone otherwise it will not move to u properly Quote Link to post Share on other sites
opencomputersfan 0 Posted October 23, 2015 Share Posted October 23, 2015 what text do i need to edit? Quote Link to post Share on other sites
tnd_blazer 0 Posted June 9, 2016 Share Posted June 9, 2016 Rip me i cant get it to work Quote Link to post Share on other sites
moto1239 0 Posted June 18, 2016 Share Posted June 18, 2016 @Gorzoid Is it possible for you, or me when I'm not feeling lazy, to modify this to use the Navigation Upgrade inside of a tablet? (If the Navigation Upgrade works in a tablet, I don't remember.) Quote Link to post Share on other sites
Gorzoid 10 Posted June 19, 2016 Author Share Posted June 19, 2016 @Gorzoid Is it possible for you, or me when I'm not feeling lazy, to modify this to use the Navigation Upgrade inside of a tablet? (If the Navigation Upgrade works in a tablet, I don't remember.) I think I actually made a test version of what you are talking about, I never finished it but if I may start up MC and try make it again, it would work alot better Quote Link to post Share on other sites
ajud 0 Posted August 6, 2016 Share Posted August 6, 2016 why can't there be an easier version of this thing, because I don't know how to set up the drones Quote Link to post Share on other sites
ExpertPlayz 0 Posted November 10, 2016 Share Posted November 10, 2016 Gorzoid could you finish it for latest version because its very cool. When i use this old version i need to fix coords thing : like it was -231drone you have to make it : -231 drone. and when i change it to sensor too the last coord it attached to function and when i do : -214 function it gives me an error. please fix the program that would be awesome!!! Quote Link to post Share on other sites
Gorzoid 10 Posted November 12, 2016 Author Share Posted November 12, 2016 Updated OP. Quote Link to post Share on other sites
negar 0 Posted January 2, 2017 Share Posted January 2, 2017 is any body have drone code for recieving a pack from source to destination Quote Link to post Share on other sites
helloitsme 0 Posted July 11, 2017 Share Posted July 11, 2017 Gorzoid, I am getting a "no primary 'navigation' available" error message when I try to run client. Any idea whats wrong? Quote Link to post Share on other sites
Fingercomp 37 Posted July 12, 2017 Share Posted July 12, 2017 9 hours ago, helloitsme said: Gorzoid, I am getting a "no primary 'navigation' available" error message when I try to run client. Any idea whats wrong? Assemble both the drone and the client with a navigation upgrade. Quote Link to post Share on other sites
steve121 0 Posted September 10, 2017 Share Posted September 10, 2017 All i get is the tablet i'm using repeating NIL when I open the Client.Lua file. However the drone says it is connected. Quote Link to post Share on other sites
Ender of Games 0 Posted December 1, 2017 Share Posted December 1, 2017 (edited) I have also gotten to the point where the tablet just says "NIL"- four times a line, each line all at once. The Drone says that it is "Linked: 3b" (possibly cutoff, I might change the code to just say "Lnk:") after client.lua runs, but the tablet used starts with 6c, so I am not sure what the drone is suggesting that it is linked to. I would like a drone to do something, but I can barely read the code. I understand what NIL implies, but as far as I can see it means that the tablet and the drone are not communicating. Using V1.6.2.7 of OpenComputers, not latest but should be more recent than than the code (or the updated code). For SkyFactory 3.0.15. Attaching a shot of NILs. Any advice or help? Edit: Tried running from different devices, including a robot. The "Linked:" changes code, but still doesn't reflect the address of the computer/hard drive. Also still nothing but NILs. Also-also, confirmed that all of this is taking place on the map- should that even matter. Edited December 1, 2017 by Ender of Games Updated from yesterday, more clarification given on issues Quote Link to post Share on other sites
tt_thoma 0 Posted June 14, 2021 Share Posted June 14, 2021 I got an error with your eeprom: It says failed loading bios: bios:75: syntax error near 'local' Quote Link to post Share on other sites
PowerMilian 0 Posted December 8, 2021 Share Posted December 8, 2021 On 12/1/2017 at 7:50 AM, Ender of Games said: I have also gotten to the point where the tablet just says "NIL"- four times a line, each line all at once. The Drone says that it is "Linked: 3b" (possibly cutoff, I might change the code to just say "Lnk:") after client.lua runs, but the tablet used starts with 6c, so I am not sure what the drone is suggesting that it is linked to. I would like a drone to do something, but I can barely read the code. I understand what NIL implies, but as far as I can see it means that the tablet and the drone are not communicating. Using V1.6.2.7 of OpenComputers, not latest but should be more recent than than the code (or the updated code). For SkyFactory 3.0.15. Attaching a shot of NILs. Any advice or help? Edit: Tried running from different devices, including a robot. The "Linked:" changes code, but still doesn't reflect the address of the computer/hard drive. Also still nothing but NILs. Also-also, confirmed that all of this is taking place on the map- should that even matter. you need to set up waypoints with the name i2 Quote Link to post Share on other sites