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}}localfunction sleep(s)-- taken from http://lua-users.org/wiki/SleepFunctionlocal ntime = os.clock()+ s/10repeatuntil os.clock()> ntime
endlocalfunction waitForTargetReach()-- actual implementation is probably slightly differentlocal epsilon =0.2while drone.getOffset()> epsilon do sleep(1)endendlocal coords ={x =0, y =0, z =0}localfunction 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 errorendfor _, 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
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.
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
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
Edited by owl leadersolved
Link to post
Share on other sites