error

Motion μ„Όμ„œ 보정

# λ“œλ‘  μ„Όμ„œ μΊ˜λ¦¬λΈŒλ ˆμ΄μ…˜ μš”μ²­ ν›„ μ—λŸ¬λ‘œ λ‚˜νƒ€λ‚œ μΊ˜λ¦¬λΈŒλ ˆμ΄μ…˜ 진행 μƒνƒœλ₯Ό 화면에 ν‘œμ‹œ
from time import sleep

from e_drone.drone import *
from e_drone.protocol import *


def checkError(error, flag):
    if error & flag.value != 0:
        return True
    else:
        return False

def eventError(error):
    
    print("* eventError() / SystemTime({0:10}) / ErrorFlagsForSensor({1:032b}) / ErrorFlagsForState({2:032b})".format(error.systemTime, error.errorFlagsForSensor, error.errorFlagsForState))

    if checkError(error.errorFlagsForSensor, ErrorFlagsForSensor.Motion_Calibrating):
        print("    - MOTION μ„Όμ„œλ₯Ό 보정 μ€‘μž…λ‹ˆλ‹€.")


if __name__ == '__main__':

    drone = Drone()
    drone.open()

    # 이벀트 핸듀링 ν•¨μˆ˜ 등둝
    drone.setEventHandler(DataType.Error, eventError)

    drone.sendPing(DeviceType.Controller)
    sleep(0.1)

    drone.sendCommand(CommandType.ClearBias)
    sleep(0.1)

    for i in range(30, 0, -1):
        print(i)
        sleep(1)

        error = drone.getData(DataType.Error)
        if error and not checkError(error.errorFlagsForSensor, ErrorFlagsForSensor.Motion_Calibrating):
            print("* MOTION μ„Όμ„œ 보정이 μ™„λ£Œλ˜μ—ˆμŠ΅λ‹ˆλ‹€.")
            break

    drone.close()

Last updated