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