Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
ComputerErika

Drone Controll Bios

Recommended Posts

Ok!!! :D Hello! So... I was going along. Coding more for the OpenComputer RFTools Dialing Program when I found out about DRONES! I immediately went and checked them out, and found out there "Basically the microcontrollers of robots." Witch I was sorta sad that you cant have a hard drive on them and so forth, Plus you only have a limited space in the bios that the drone runs on. Anyway, I wanted to find a way to run all the stuff remotely so the drone wouldn't have to do any of the processing. Like a separate computer would tell the drone what to do over a wireless network, but because I wanted it to work at whatever distance I then just used linked cards. This is the bios I use to run the drone: 

local d = component.proxy(component.list("drone")())
local t = component.proxy(component.list("tunnel")())
while true do
  local evt,_,sender,_,_,name,cmd,a,b,c = computer.pullSignal()
  if evt == "modem_message" and name == d.name() then
    if cmd == "gst" then
      t.send(d.name(),"gst",d.getStatusText())
    end
    if cmd == "sst" then
      t.send(d.name(),"sst",d.setStatusText(a))
    end
    if cmd == "mov" then
      d.move(a,b,c)
    end
    if cmd == "gos" then
      t.send(d.name(),"gos",d.getOffset())
    end
    if cmd == "gve" then
      t.send(d.name(),"gv",d.getVelocity())
    end
    if cmd == "gmv" then
      t.send(d.name(),"gmv",d.getMaxVelocity())
    end
    if cmd == "gac" then
      t.send(d.name(),"ga",d.getAcceleration())
    end
    if cmd == "sac" then
      d.setAcceleration(a)
    end
    if cmd == "glc" then
      t.send(d.name(),"glc",d.getLightColor())
    end
    if cmd == "slc" then
      d.setLightColor(a)
    end
    if cmd == "dct" then
      local b, s = d.detect(a)
      t.send(d.name(),"dct",b,s)
    end
    if cmd == "cmp" then
      t.send(d.name(),"c",d.compare(a))
    end
  end
end

LINK TO PASTEBIN: https://pastebin.com/cfgsdmQJ

So you would run and create the programs on a separate computer or tablet. This made it much easier for me to code it plus I get to use all my APIs! Here is the start of a drone control program:

local t = require("component").tunnel --or modem if thats what you use
local event = require("event")
function doDrone(dronename,dronecommand,arg1,arg2,arg3)
  t.send(dronename,dronecommand,arg1,arg2,arg3)
  _, _, _, _, _, name, command, respond1, respond2 = event.pull("modem_message")
  return {name, command, respond1, respond2}
end
doDrone("DAVE","mov",0,3,0) --this would make it move up there blocks!

All the commands, like "mov", and what arguments they need, and how they respond are in the drone control bios above! (One above the one above, so like two above)

I plan on adding support for all the drop components like navigation and such, Or you could do that yourself! :D 

Link to post
Share on other sites

i managed to fix the top code

local drone = component.proxy(component.list("drone")())
local modem = component.proxy(component.list("modem")())


--local d = component.proxy(component.list("drone")())
--local t = component.proxy(component.list("tunnel")())
while true do
  local evt,_,sender,_,_,name,cmd,a,b,c = computer.pullSignal()
  if evt == "modem_message" and name == drone.name() then
    if cmd == "gst" then
      modem.send(drone.name(),"gst",drone.getStatusText())
    end
    if cmd == "sst" then
      modem.send(drone.name(),"sst",drone.setStatusText(a))
    end
    if cmd == "mov" then
      drone.move(a,b,c)
    end
    if cmd == "gos" then
      modem.send(drone.name(),"gos",drone.getOffset())
    end
    if cmd == "gve" then
      modem.send(drone.name(),"gv",drone.getVelocity())
    end
    if cmd == "gmv" then
      modem.send(drone.name(),"gmv",drone.getMaxVelocity())
    end
    if cmd == "gac" then
      modem.send(drone.name(),"ga",drone.getAcceleration())
    end
    if cmd == "sac" then
      drone.setAcceleration(a)
    end
    if cmd == "glc" then
      modem.send(drone.name(),"glc",drone.getLightColor())
    end
    if cmd == "slc" then
      drone.setLightColor(a)
    end
    if cmd == "dct" then
      local b, s = drone.detect(a)
      modem.send(drone.name(),"dct",b,s)
    end
    if cmd == "cmp" then
      modem.send(drone.name(),"c",drone.compare(a))
    end
  end
end

 

but i just cant get it to work with te bottom part of the script

 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.