How to have continuous moveBy

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.

For example, if I do that:

drone(
    moveBy(5, 0, 0, 0)
).wait()
drone(
    moveBy(0, 5, 0, 0)
).wait
drone(
    moveBy(-5, 0, 0, 0)
).wait()
drone(
    moveBy(0, -5, 0, 0)
).wait()

I got a perfect square (with long pause at each angle !!), but if I do that:

drone(
    moveBy(5, 0, 0, 0)
)
drone(
    moveBy(0, 5, 0, 0)
)
drone(
    moveBy(-5, 0, 0, 0)
)
drone(
    moveBy(0, -5, 0, 0)
).wait()

the drone move 20m to the left. So what I want as behavior it that the drone do the square smoothly (the corner can be curved)

Thank you.

2 Likes

Hi,

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 :

  1. Interrupt the moveBy commands by a PCMD commands before reaching the final position
  2. Use only the PCMD commands and control the drone in position and/or velocity using the PositionChanged or SpeedChanged events.

Ok, thank you for your answer

Hi!

Would the cancelMoveBy work to interupt the previous moveBy, instead of the PCMD-command?

Hi!

Last time I tried cancelMoveBy command it was not working.

I don’t know if it’s a bug or I used it badly

Hi again!

I tried the cancelMoveBy too, but had no success. :slightly_frowning_face:

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.

Is there any other tricks that might help?

By the way, @BaptisteP,

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.

I am in the same situation, but currently I have no solution. I hope someone has one.

Thanks, but I don’t know how to determines the delay. It will depend of the time needed to do the moveBy, but we don’t know it.

Hi.
I can interrupt the moveBy commands to use PCMD commands as blow.
PCMD(1,1,1,1,1,1)
Anafi stoped befor reaching its final position.

@misoragod Would you be so kind and share some example code on how you achieved this exactly? Thank you!

1 Like