sensor

고도 데이터 확인

from time import sleep

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


def eventAltitude(altitude):
    print("eventAltitude()")
    print("-  Temperature: {0:.3f}".format(altitude.temperature))
    print("-     Pressure: {0:.3f}".format(altitude.pressure))
    print("-     Altitude: {0:.3f}".format(altitude.altitude))
    print("- Range Height: {0:.3f}".format(altitude.rangeHeight))

if __name__ == '__main__':

    drone = Drone()
    drone.open()

    # 이벤트 핸들링 함수 등록
    drone.setEventHandler(DataType.Altitude, eventAltitude)

    # Altitude 정보 요청
    drone.sendRequest(DeviceType.Drone, DataType.Altitude)
    sleep(0.1)

    drone.close()

레인지 센서 확인

from time import sleep

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


def eventRange(range):   
   print("eventRange()")
   print("- left: {0:4d}"     .format(range.left))   
   print("- front: {0:4d}"    .format(range.front))   
   print("- right: {0:4d}"    .format(range.right))
   print("- bottom: {0:4d}"   .format(range.bottom))


if __name__ == '__main__':     

   drone = Drone()
   drone.open()

   # 이벤트 핸들링 함수 등록
   drone.setEventHandler(DataType.Range, eventRange)
   
   # Range 정보 요청   
   drone.sendRequest(DeviceType.Drone, DataType.Range)
   sleep(0.1)

   drone.close()

Motion 센서 데이터 확인

from time import sleep

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


def eventMotion(motion):
    print("eventMotion()")
    print("- Accel: {0:5}, {1:5}, {2:5}".format(motion.accelX, motion.accelY, motion.accelZ))
    print("-  Gyro: {0:5}, {1:5}, {2:5}".format(motion.gyroRoll, motion.gyroPitch, motion.gyroYaw))
    print("- Angle: {0:5}, {1:5}, {2:5}".format(motion.angleRoll, motion.anglePitch, motion.angleYaw))


if __name__ == '__main__':

    drone = Drone()
    drone.open()

    # 이벤트 핸들링 함수 등록
    drone.setEventHandler(DataType.Motion, eventMotion)

    # Motion 정보 요청
    drone.sendRequest(DeviceType.Drone, DataType.Motion)
    sleep(0.1)

    drone.close()

자세 확인

from time import sleep

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


def eventAttitude(attitude):
    print("eventAttitude() / {0:0.1f}, {1:0.1f}, {2:0.1f}".format(attitude.roll, attitude.pitch, attitude.yaw))


if __name__ == '__main__':

    drone = Drone()
    drone.open()

    # 이벤트 핸들링 함수 등록
    drone.setEventHandler(DataType.Attitude, eventAttitude)

    # Attitude 정보 요청
    drone.sendRequest(DeviceType.Drone, DataType.Attitude)
    sleep(0.1)

    drone.close()

Last updated