petrone_v2 for python / Examples / Motor

Modified : 2018.3.5



모터 동작 테스트

드론의 전체 모터를 각각 다른 속도로 동작시켰다가 정지합니다.

통신 과정에서 문제가 생겨 모터 제어 명령이 전달되지 않을 수도 있으니 드론을 잘 잡은 채로 시도하시기 바랍니다.

from time import sleep

from petrone_v2.drone import *
from petrone_v2.protocol import *


def eventAck(ack):
    print("eventAck() / {0} / 0x{1:04X} / {2}".format(ack.dataType.name, ack.crc16, ack.systemTime))


if __name__ == '__main__':

    drone = Drone()
    drone.open("COM22")


    # 이벤트 핸들링 함수 등록
    drone.setEventHandler(DataType.Ack, eventAck)
    sleep(0.01)


    drone.sendMotor(1000, 1200, 1300, 1400)
    sleep(1)

    drone.sendMotor(0, 0, 0, 0)
    sleep(0.1)


    drone.close()



MotorSingle 동작 테스트

우측 앞 모터 속도를 점점 올렸다가 다시 내린 후 정지하는 명령을 차례로 실행합니다.

통신 과정에서 문제가 생겨 모터 제어 명령이 전달되지 않을 수도 있으니 드론을 잘 잡은 채로 시도하시기 바랍니다.

from time import sleep

from petrone_v2.drone import *
from petrone_v2.protocol import *


def eventAck(ack):
    print("eventAck() / {0} / 0x{1:04X} / {2}".format(ack.dataType.name, ack.crc16, ack.systemTime))


if __name__ == '__main__':

    drone = Drone()
    drone.open("COM22")


    # 이벤트 핸들링 함수 등록
    drone.setEventHandler(DataType.Ack, eventAck)
    sleep(0.01)


    drone.sendMotorSingle(1, Rotation.Clockwise, 1000)
    sleep(2)

    drone.sendMotorSingle(1, Rotation.Clockwise, 2000)
    sleep(2)

    drone.sendMotorSingle(1, Rotation.Clockwise, 3000)
    sleep(2)

    drone.sendMotorSingle(1, Rotation.Clockwise, 2000)
    sleep(2)

    drone.sendMotorSingle(1, Rotation.Clockwise, 1000)
    sleep(2)

    drone.sendStop()
    sleep(0.1)


    drone.close()



petrone_v2 for python

  1. Intro
  2. System
  3. Protocol
  4. Drone
  5. Examples - Ping
  6. Examples - Information
  7. Examples - Pairing
  8. Examples - Control
  9. Examples - Sensor
  10. Examples - Motor
  11. Examples - Setup
  12. Examples - Buzzer
  13. Examples - Vibrator
  14. Examples - Light
  15. Examples - Display
  16. Examples - Input
  17. Examples - Error


Index