Blocking until Gimbal Finishes Rotating

Hello,

I am trying to write a script in Olympe that moves the gimbal to a specific rotation and then takes a picture. I am using gimbal set target. When I send the command, the gimbal starts moving but the next command to take a picture is run immediately without waiting for the gimbal to stop (even though I am using .wait().success()).

Here is what my code looks like, approximately:

drone(set_target(gimbal_id=0, control_mode=“position”, …, pitch=-45.0,…)).wait().success()
drone(take_photo(0)).wait().success()

Thanks in advance for your help!

I think the set_target returns immediately without waiting for the completion of the rotation.
The succes is the output of the command, not the event.
@ndessart could you confirm?

Hi @mihirbala,

Like Jerome said, you need to wait for the event “attitude”. The following example does the job:

import olympe
from olympe.messages.gimbal import set_target, attitude

drone_ip = "10.202.0.1"


drone = olympe.Drone(drone_ip)

pitch = -45.

assert drone.connect()

expectation = drone(
    set_target(
        gimbal_id=0,
        control_mode="position",
        yaw_frame_of_reference="none",
        yaw=0.,
        pitch=pitch,
        pitch_frame_of_reference="absolute",
        roll=0.,
        roll_frame_of_reference="absolute",
    )
    >> attitude(
        pitch_absolute=pitch, _policy="wait", _float_tol=(1e-3, 1e-1)
    )
).wait(_timeout=20)

assert expectation

assert drone.disconnect()

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.