CoDrone DIY
  • ⚪소개하기
    • 펌웨어 업데이트 방법
      • Raspberry pi
      • Linux
      • Mac
      • Windows
      • Windows(.NET)
    • 다운로드용 자료 모음
  • 코드론 파이썬 라이브러리
    • 🔶파이썬
      • drone class
      • ping
      • information
      • pairing
      • control
      • sensor
      • buzzer
      • vibrator
      • light
      • display
      • input
      • error
    • 🔷프로토콜
      • Typedef
      • DataType
      • Definitions
      • Structs
      • Structs light
      • Structs display
      • Structs card
  • Friend Site
    • 🤍Buy CoDrone DIY
    • 💙ROBOLINK
Powered by GitBook
On this page
  1. 코드론 파이썬 라이브러리
  2. 파이썬

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()
PreviousinputNext프로토콜

Last updated 2 years ago

🔶