When I generate dynamically a succession of drone(moveBy(...)).wait() there is a waiting time (the drone slow down and then stop moving) between each moveBy. If I remove the the .wait() the drone does not have the desired behavior.
The moveBy command ends when the drone sends the “moveByEnd” event. Normally, this event is sent by the drone when it reaches its final (stop dead) position. This can take a while.
For your use case, I see two options :
Interrupt the moveBy commands by a PCMD commands before reaching the final position
Use only the PCMD commands and control the drone in position and/or velocity using the PositionChanged or SpeedChanged events.
I also wish to use the moveBy function faster than waiting for it to end. We are using an external sensor to implement a precise landing with the anafi, and would like to send consecutive moveBy-commands to correct for drift while approaching the landing spot.
I tried sending a PCMD(1,0,0,0,0,0) where I would have sent a cancelMoveBy, but the anafi did not respond to the moveBy that follows the PCMD, unless I added a 3 seconds long delay in between.
Controlling the drone by the PCMD-commands could be an option, but this option lack the precision we desire.
If you add a time delay between the moveBys in your 5x5 sqare, they seems to stack up to some degree. I tried it in the simulator and the anafi did not move in a perfect sqare, but it ended up where it started. It seemes like maybe the anafi changes the target for the unfinshed moveBy when it receives the next.