How to move Anafi horizontally in fixed height above ground

Hey

We want to move Anafi via Olympe in a fixed height z above the ground inputting x (forward / backward) velocity (m/s) and yaw (rad/s) and do this for a given frame rate.

I checked out to possibilities so far:

  1. moveBy. It always waits until the moveBy command has been completed, hence is not usable for us since we want to steer the drone in a given framerate. We would have to interrupt the running moveBy command and give a new offset somewhow, this would solve our problem. Example code I used:

drone = olympe.Drone(“10.202.0.1”)
drone.connect()
drone(MaxTilt(20)).wait()
drone(
TakeOff()
>> FlyingStateChanged(state=“hovering”, _timeout=5)
).wait()

drone(
moveBy(0.5, 0, 0, 0)
>> FlyingStateChanged(state=“flying”, _timeout=3.0)
).wait()

drone(
moveBy(-0.5, 0, 0, 0)
>> FlyingStateChanged(state=“hovering”, _timeout=3.0)
).wait()

drone(Landing()).wait()
drone.disconnect()

  1. piloting_pcmd This does work in terms of frame rate but I doubt the drone will stay on the same height above ground when we simply operate in joystick mode which is required for us due to the drift. Example code we used:

drone = olympe.Drone(“10.202.0.1”)
drone.connect()
drone(MaxTilt(20)).wait()
drone(
TakeOff()
>> FlyingStateChanged(state=“hovering”, _timeout=5)
).wait()

fps = 1.0
drone.start_piloting()
for i in range(50): # example of drone moving forward / backward
drone.piloting_pcmd(0, (1 if (i % 5 == 0) else -1) * 70, 0, 0, 1.0 / fps)
sleep(1 / fps)
drone.stop_piloting()
drone(Landing()).wait()
drone.disconnect()