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

owl leader

Members
  • Content Count

    1
  • Joined

  • Last visited

Posts posted by owl leader

  1. This probably was asked numerous times already.
    I have a drone, which I am trying to get to move to waypoints, and for testing the waypoints list start and end is the {0, 0, 0} local coordinate (start location), yet the drone ends up 5 or so blocks away. Oh and I lost the drone by telling it to move 2 * coords + offset blocks and it's now somewhere at Y 1300. RIP Jaeger, been a good time.

    So, the question is, how does one convert a waypoint into an offset that drone.move() will work with?

    The current code is

    local waypoints = {
    	{x = 0, y = 0, z = 0},
      	{x = 15, y = 25, z = -7},
    	-- more waypoints with some values,
      	{x = 0, y = 0, z = 0}
    }
    
    local function sleep(s) -- taken from http://lua-users.org/wiki/SleepFunction
      local ntime = os.clock() + s/10
      repeat until os.clock() > ntime
    end
    
    local function waitForTargetReach() -- actual implementation is probably slightly different
      	local epsilon = 0.2
      	while drone.getOffset() > epsilon do sleep(1) end
    end
    
    local coords = {x = 0, y = 0, z = 0}
    
    local function moveWaypoint(waypoint)
    	drone.move(waypoint.x - coords.x, waypoint.y - coords.y, waypoint.z - coords.z)
      	waitForTargetReach() -- busy wait - probably need to make this a signal pull somehow
      	coords = waypoint -- potential for error buildup, probably the cause for the resulting 5 block error
    end
    
    for _, v in ipairs(waypoints) do
    	moveWaypoint(v)
    end

    The concern is for the moveWaypoint(waypoint) function, other functions are provided to give some context, but probably one of you will find an issue.

    My logic tells me that the function is almost correct, and I just have epsilon set too high, but is it really that high? Besides, how accurate is drone movement even?

    It's my first time working with drones, so I have absolutely no idea whether I need or don't need to do certain things.

     

    Update.
    Turns out I have literally posted working code and it was a matter of setting epsilon to 0.05 and the initial results led me to the conclusion I did something terribly wrong.

    There is a lesson to be learned here somewhere.

    RIP Jaeger, your loss was really unnecessary and preventable lol

×
×
  • Create New...

Important Information

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