petrone for python / Examples / Information

Modified : 2018.11.26



IMU 데이터 요청

IMU 데이터를 50ms 주기로 10회 요청합니다.

from time import sleep

from petrone.drone import *
from petrone.protocol import *
from petrone.system import *


def eventImu(data):
    print("eventImu() / | Accel (X:{0:5}, Y:{1:5}, Z:{2:5}) | Gyro (R:{3:5}, P:{4:5}, Y:{5:5}) | Angle (R:{6:4}, P:{7:4}, Y:{8:4})".format(
        data.accelX, data.accelY, data.accelZ,
        data.gyroRoll, data.gyroPitch, data.gyroYaw,
        data.angleRoll, data.anglePitch, data.angleYaw))


if __name__ == '__main__':
    
    drone = Drone(True, True, True, True, True)

    drone.setEventHandler(DataType.Imu, eventImu)

    # Connect
    drone.connect(flagSystemReset=True)
    sleep(2)
    
    if drone.isConnected():

        for i in range(0, 10, 1):
            
            drone.sendRequest(DataType.Imu)
            sleep(0.05)

        # Disconnect
        print("Disconnect device.")
        drone.sendLinkDisconnect()
        sleep(0.2)

    drone.close()


실행 결과는 다음과 같습니다.

example1 result

IMU 데이터 요청



petrone for python

  1. Intro
  2. System
  3. Protocol
  4. Drone
  5. Examples - Information
  6. Examples - Imu
  7. Examples - Test Flight
  8. Examples - Light


Index