CoDrone Mini
  • ๐ŸŸก์†Œ๊ฐœํ•˜๊ธฐ
    • ๋™์˜์ƒ ๋งค๋‰ด์–ผ
    • ๋‹ค์šด๋กœ๋“œ์šฉ ์ž๋ฃŒ ๋ชจ์Œ
  • ์ฝ”๋“œ๋ก  ํŒŒ์ด์ฌ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ
    • ๐Ÿ”ถํŒŒ์ด์ฌ
      • drone class
      • ping
      • information
      • pairing
      • control
      • sensor
      • buzzer
      • vibrator
      • light
      • display
      • input
      • error
    • ๐Ÿ”ทํ”„๋กœํ† ์ฝœ
      • Typedef
      • DataType
      • Definitions
      • Structs
      • Structs light
      • Structs display
      • Structs card
  • Site Link
    • ๐Ÿ’›Buy CoDrone Mini
    • ๐Ÿ’™ROBOLINK
Powered by GitBook
On this page
  • ํŽ˜์–ด๋ง ๋ณ€๊ฒฝ ํ›„ ๋ณ€๊ฒฝ๋œ ์ •๋ณด ํ™•์ธ
  • ํŽ˜์–ด๋ง ๋ณ€๊ฒฝ ํ›„ ๋ณ€๊ฒฝ๋œ ์ •๋ณด ํ™•์ธ(์ด๋ฒคํŠธ ํ•จ์ˆ˜ ๋“ฑ๋ก)
  1. ์ฝ”๋“œ๋ก  ํŒŒ์ด์ฌ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ
  2. ํŒŒ์ด์ฌ

pairing

ํŽ˜์–ด๋ง ๋ณ€๊ฒฝ ํ›„ ๋ณ€๊ฒฝ๋œ ์ •๋ณด ํ™•์ธ

# ์กฐ์ข…๊ธฐ์˜ ํŽ˜์–ด๋ง ์ •๋ณด๋ฅผ ๋ณ€๊ฒฝํ•˜๊ณ , ๋ณ€๊ฒฝ๋œ ์ •๋ณด๋ฅผ ์š”์ฒญํ•œ ํ›„ ์‘๋‹ต์„ ๊ธฐ๋‹ค๋ ค ์ถœ๋ ฅํ•˜๋Š” ์˜ˆ์ œ
from time import sleep

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


if __name__ == '__main__':

    drone = Drone(False)
    drone.open()

    # ํŽ˜์–ด๋ง ์„ค์ •
    drone.sendPairing(DeviceType.Controller, 0x0001, 0x0002, 0x0003, 0x04, 0x05)
    sleep(0.01)

    # ํŽ˜์–ด๋ง๋ฐ์ดํ„ฐ ์š”์ฒญ
    drone.sendRequest(DeviceType.Controller, DataType.Pairing)
    
    timeStart = time.time()

    while True:
        sleep(0.01)
        dataType = drone.check()
        
        if    dataType == DataType.Pairing:
            pairing = drone.getData(DataType.Pairing)

            print("Address: 0x{0:04X}{1:04X}{2:04X} / {0}.{1}.{2}".format(
                pairing.address0, 
                pairing.address1, 
                pairing.address2))

            print("Scramble: {0}".format(pairing.scramble))
            print("Channel: {0}".format(pairing.channel))
            break

        if time.time() > timeStart + 1:
            break
    
    drone.close()

ํŽ˜์–ด๋ง ๋ณ€๊ฒฝ ํ›„ ๋ณ€๊ฒฝ๋œ ์ •๋ณด ํ™•์ธ(์ด๋ฒคํŠธ ํ•จ์ˆ˜ ๋“ฑ๋ก)

# ์กฐ์ข…๊ธฐ์˜ ํŽ˜์–ด๋ง ์ •๋ณด๋ฅผ ๋ณ€๊ฒฝํ•˜๊ณ , ๋ณ€๊ฒฝ๋œ ์ •๋ณด๋ฅผ ์š”์ฒญํ•œ ํ›„ ์ด๋ฒคํŠธ ํ•ธ๋“ค๋Ÿฌ๋ฅผ ํ†ตํ•ด ์‘๋‹ต์„ ์ถœ๋ ฅํ•˜๋Š” ์˜ˆ์ œ
from time import sleep

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


def eventPairing(pairing):
    print("eventPairing()")

    print("Address: 0x{0:04X}{1:04X}{2:04X} / {0}.{1}.{2}".format(
        pairing.address0, 
        pairing.address1, 
        pairing.address2))

    print("Scramble: {0}".format(pairing.scramble))
    print("Channel: {0}".format(pairing.channel))


if __name__ == '__main__':

    drone = Drone()
    drone.open()

    # ์ด๋ฒคํŠธ ํ•ธ๋“ค๋ง ํ•จ์ˆ˜ ๋“ฑ๋ก
    drone.setEventHandler(DataType.Pairing, eventPairing)

    # ํŽ˜์–ด๋ง ์„ค์ •
    drone.sendPairing(DeviceType.Controller, 0x0005, 0x0006, 0x0007, 0x08, 0x09)
    sleep(0.01)

    # ํŽ˜์–ด๋ง๋ฐ์ดํ„ฐ ์š”์ฒญ
    drone.sendRequest(DeviceType.Controller, DataType.Pairing)
    sleep(0.1)
    
    drone.close()
PreviousinformationNextcontrol

Last updated 2 years ago

๐Ÿ”ถ