e_drone for python / Examples / Error
Modified : 2018.7.6
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(" - IMU 센서를 보정 중입니다.")
if __name__ == '__main__':
drone = Drone()
drone.open()
# 이벤트 핸들링 함수 등록
drone.setEventHandler(DataType.Error, eventError)
drone.sendPing(DeviceType.Controller)
sleep(0.1)
drone.sendCommand(CommandType.ClearGyroBias)
sleep(0.1)
for i in range(30, 0, -1):
print(i)
sleep(1)
error = drone.getData(DataType.Error)
if not checkError(error.errorFlagsForSensor, ErrorFlagsForSensor.Motion_Calibrating):
print("* Motion 센서 보정이 완료되었습니다.")
break
drone.close()
e_drone for python
- Intro
- System
- Protocol
- Drone
- Examples - Ping
- Examples - Information
- Examples - Pairing
- Examples - Control
- Examples - Sensor
- Examples - Motor
- Examples - Setup
- Examples - Buzzer
- Examples - Vibrator
- Examples - Light
- Examples - Display
- Examples - Input
- Examples - Error