pyaidrone 1.0__tar.gz → 1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pyaidrone might be problematic. Click here for more details.
- pyaidrone-1.2/PKG-INFO +23 -0
- pyaidrone-1.2/pyaidrone/__init__.py +1 -0
- pyaidrone-1.0/pyaidrone/AIDrone.py → pyaidrone-1.2/pyaidrone/aiDrone.py +151 -151
- {pyaidrone-1.0 → pyaidrone-1.2}/pyaidrone/packet.py +4 -4
- {pyaidrone-1.0 → pyaidrone-1.2}/pyaidrone/parse.py +2 -2
- pyaidrone-1.2/pyaidrone.egg-info/PKG-INFO +23 -0
- {pyaidrone-1.0 → pyaidrone-1.2}/pyaidrone.egg-info/SOURCES.txt +1 -1
- pyaidrone-1.2/setup.py +23 -0
- pyaidrone-1.0/PKG-INFO +0 -7
- pyaidrone-1.0/pyaidrone/__init__.py +0 -0
- pyaidrone-1.0/pyaidrone.egg-info/PKG-INFO +0 -7
- pyaidrone-1.0/setup.py +0 -16
- {pyaidrone-1.0 → pyaidrone-1.2}/README.md +0 -0
- {pyaidrone-1.0 → pyaidrone-1.2}/pyaidrone/deflib.py +0 -0
- {pyaidrone-1.0 → pyaidrone-1.2}/pyaidrone/ikeyevent.py +0 -0
- {pyaidrone-1.0 → pyaidrone-1.2}/pyaidrone.egg-info/dependency_links.txt +0 -0
- {pyaidrone-1.0 → pyaidrone-1.2}/pyaidrone.egg-info/requires.txt +0 -0
- {pyaidrone-1.0 → pyaidrone-1.2}/pyaidrone.egg-info/top_level.txt +0 -0
- {pyaidrone-1.0 → pyaidrone-1.2}/setup.cfg +0 -0
pyaidrone-1.2/PKG-INFO
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: pyaidrone
|
|
3
|
+
Version: 1.2
|
|
4
|
+
Summary: Library for AIDrone Products
|
|
5
|
+
Home-page: http://www.ir-brain.com
|
|
6
|
+
Author: IR-Brain
|
|
7
|
+
Author-email: ceo@ir-brain.com
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.6
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
|
|
14
|
+
## install pyaidrone
|
|
15
|
+
|
|
16
|
+
> python setup.py install
|
|
17
|
+
> or
|
|
18
|
+
> python install pyaidrone
|
|
19
|
+
|
|
20
|
+
### install Packages
|
|
21
|
+
|
|
22
|
+
> pip install pyserial
|
|
23
|
+
> pip install pynput
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = '1.2'
|
|
@@ -1,151 +1,151 @@
|
|
|
1
|
-
import serial
|
|
2
|
-
import binascii
|
|
3
|
-
import math
|
|
4
|
-
from time import sleep
|
|
5
|
-
import random
|
|
6
|
-
from operator import eq
|
|
7
|
-
from threading import Thread
|
|
8
|
-
from serial.tools.list_ports import comports
|
|
9
|
-
from pyaidrone.parse import *
|
|
10
|
-
from pyaidrone.packet import *
|
|
11
|
-
from pyaidrone.deflib import *
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
class AIDrone(Parse, Packet):
|
|
15
|
-
def __init__(self, receiveCallback = None):
|
|
16
|
-
self.serial = None
|
|
17
|
-
self.isThreadRun = False
|
|
18
|
-
self.parse = Parse(AIDRONE)
|
|
19
|
-
self.makepkt = Packet(AIDRONE)
|
|
20
|
-
self.receiveCallback = receiveCallback
|
|
21
|
-
self.makepkt.clearPacket()
|
|
22
|
-
self.posX = 0
|
|
23
|
-
self.posY = 0
|
|
24
|
-
self.rot = 0
|
|
25
|
-
|
|
26
|
-
def receiveHandler(self):
|
|
27
|
-
while self.isThreadRun:
|
|
28
|
-
readData = self.serial.read(self.serial.in_waiting or 1)
|
|
29
|
-
packet = self.parse.packetArrange(readData)
|
|
30
|
-
if not eq(packet, "None"):
|
|
31
|
-
if self.receiveCallback != None:
|
|
32
|
-
self.receiveCallback(packet)
|
|
33
|
-
self.serial.write(self.makepkt.getPacket())
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
def Open(self, portName = "None"):
|
|
37
|
-
if eq(portName, "None"):
|
|
38
|
-
nodes = comports()
|
|
39
|
-
for node in nodes:
|
|
40
|
-
if "CH340" in node.description:
|
|
41
|
-
portName = node.device
|
|
42
|
-
|
|
43
|
-
if eq(portName, "None"):
|
|
44
|
-
print("Can't find Serial Port")
|
|
45
|
-
exit()
|
|
46
|
-
return False
|
|
47
|
-
try:
|
|
48
|
-
self.serial = serial.Serial(port=portName, baudrate=115200, timeout=1)
|
|
49
|
-
if self.serial.isOpen():
|
|
50
|
-
self.isThreadRun = True
|
|
51
|
-
self.thread = Thread(target=self.receiveHandler, args=(), daemon=True)
|
|
52
|
-
self.thread.start()
|
|
53
|
-
print("Connected to", portName)
|
|
54
|
-
return True
|
|
55
|
-
else:
|
|
56
|
-
print("Can't open " + portName)
|
|
57
|
-
exit()
|
|
58
|
-
return False
|
|
59
|
-
except:
|
|
60
|
-
print("Can't open " + portName)
|
|
61
|
-
exit()
|
|
62
|
-
return False
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
def Close(self):
|
|
66
|
-
self.isThreadRun = False
|
|
67
|
-
sleep(0.2)
|
|
68
|
-
pkt = self.makepkt.getPacket()
|
|
69
|
-
if (pkt[15]&0x80) == 0x80:
|
|
70
|
-
self.makepkt.clearPacket()
|
|
71
|
-
self.setOption(0x8000)
|
|
72
|
-
self.serial.write(self.makepkt.getPacket())
|
|
73
|
-
sleep(0.2)
|
|
74
|
-
self.serial.write(self.makepkt.clearPacket())
|
|
75
|
-
sleep(0.2)
|
|
76
|
-
if self.serial != None:
|
|
77
|
-
if self.serial.isOpen() == True:
|
|
78
|
-
self.serial.close()
|
|
79
|
-
|
|
80
|
-
def setOption(self, option):
|
|
81
|
-
data = option.to_bytes(2, byteorder="little", signed=False)
|
|
82
|
-
self.makepkt.makePacket(14, data)
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
def takeoff(self):
|
|
86
|
-
alt = 70
|
|
87
|
-
data = alt.to_bytes(2, byteorder="little", signed=False)
|
|
88
|
-
self.makepkt.makePacket(12, data)
|
|
89
|
-
alt = 0x2F
|
|
90
|
-
data = alt.to_bytes(2, byteorder="little", signed=False)
|
|
91
|
-
self.setOption(0x2F)
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
def landing(self):
|
|
95
|
-
alt = 0
|
|
96
|
-
data = alt.to_bytes(2, byteorder="little", signed=False)
|
|
97
|
-
self.makepkt.makePacket(12, data)
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
def altitude(self, alt):
|
|
101
|
-
data = alt.to_bytes(2, byteorder="little", signed=False)
|
|
102
|
-
self.makepkt.makePacket(12, data)
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
def velocity(self, dir=0, vel=100):
|
|
106
|
-
if dir > 3:
|
|
107
|
-
return
|
|
108
|
-
if dir==1 or dir==3:
|
|
109
|
-
vel *= -1;
|
|
110
|
-
data = vel.to_bytes(2, byteorder="little", signed=True)
|
|
111
|
-
if dir==0 or dir==1:
|
|
112
|
-
self.makepkt.makePacket(8, data)
|
|
113
|
-
else:
|
|
114
|
-
self.makepkt.makePacket(6, data)
|
|
115
|
-
self.setOption(0x0F)
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
def move(self, dir=0, dist=100):
|
|
119
|
-
if dir > 3:
|
|
120
|
-
return
|
|
121
|
-
if dir==1 or dir==3:
|
|
122
|
-
dist *= -1;
|
|
123
|
-
if dir==0 or dir==1:
|
|
124
|
-
self.posX += dist
|
|
125
|
-
data = self.posX.to_bytes(2, byteorder="little", signed=True)
|
|
126
|
-
self.makepkt.makePacket(8, data)
|
|
127
|
-
else:
|
|
128
|
-
self.posY += dist
|
|
129
|
-
data = self.posY.to_bytes(2, byteorder="little", signed=True)
|
|
130
|
-
self.makepkt.makePacket(6, data)
|
|
131
|
-
self.setOption(0x2F)
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
def rotation(self, rot=90):
|
|
135
|
-
self.rot += rot
|
|
136
|
-
data = self.rot.to_bytes(2, byteorder="little", signed=True)
|
|
137
|
-
self.makepkt.makePacket(10, data)
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
def motor(self, what, speed):
|
|
141
|
-
speed = DefLib.constrain(speed, 100, 0)
|
|
142
|
-
data = speed.to_bytes(2, byteorder="little", signed=True)
|
|
143
|
-
self.makepkt.makePacket(what*2+6, data)
|
|
144
|
-
self.setOption(0x8000)
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
def emergency(self):
|
|
148
|
-
self.setOption(0x00)
|
|
149
|
-
self.serial.write(self.makepkt.getPacket())
|
|
150
|
-
|
|
151
|
-
|
|
1
|
+
import serial
|
|
2
|
+
import binascii
|
|
3
|
+
import math
|
|
4
|
+
from time import sleep
|
|
5
|
+
import random
|
|
6
|
+
from operator import eq
|
|
7
|
+
from threading import Thread
|
|
8
|
+
from serial.tools.list_ports import comports
|
|
9
|
+
from pyaidrone.parse import *
|
|
10
|
+
from pyaidrone.packet import *
|
|
11
|
+
from pyaidrone.deflib import *
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class AIDrone(Parse, Packet):
|
|
15
|
+
def __init__(self, receiveCallback = None):
|
|
16
|
+
self.serial = None
|
|
17
|
+
self.isThreadRun = False
|
|
18
|
+
self.parse = Parse(AIDRONE)
|
|
19
|
+
self.makepkt = Packet(AIDRONE)
|
|
20
|
+
self.receiveCallback = receiveCallback
|
|
21
|
+
self.makepkt.clearPacket()
|
|
22
|
+
self.posX = 0
|
|
23
|
+
self.posY = 0
|
|
24
|
+
self.rot = 0
|
|
25
|
+
|
|
26
|
+
def receiveHandler(self):
|
|
27
|
+
while self.isThreadRun:
|
|
28
|
+
readData = self.serial.read(self.serial.in_waiting or 1)
|
|
29
|
+
packet = self.parse.packetArrange(readData)
|
|
30
|
+
if not eq(packet, "None"):
|
|
31
|
+
if self.receiveCallback != None:
|
|
32
|
+
self.receiveCallback(packet)
|
|
33
|
+
self.serial.write(self.makepkt.getPacket())
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def Open(self, portName = "None"):
|
|
37
|
+
if eq(portName, "None"):
|
|
38
|
+
nodes = comports()
|
|
39
|
+
for node in nodes:
|
|
40
|
+
if "CH340" in node.description:
|
|
41
|
+
portName = node.device
|
|
42
|
+
|
|
43
|
+
if eq(portName, "None"):
|
|
44
|
+
print("Can't find Serial Port")
|
|
45
|
+
exit()
|
|
46
|
+
return False
|
|
47
|
+
try:
|
|
48
|
+
self.serial = serial.Serial(port=portName, baudrate=115200, timeout=1)
|
|
49
|
+
if self.serial.isOpen():
|
|
50
|
+
self.isThreadRun = True
|
|
51
|
+
self.thread = Thread(target=self.receiveHandler, args=(), daemon=True)
|
|
52
|
+
self.thread.start()
|
|
53
|
+
print("Connected to", portName)
|
|
54
|
+
return True
|
|
55
|
+
else:
|
|
56
|
+
print("Can't open " + portName)
|
|
57
|
+
exit()
|
|
58
|
+
return False
|
|
59
|
+
except:
|
|
60
|
+
print("Can't open " + portName)
|
|
61
|
+
exit()
|
|
62
|
+
return False
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def Close(self):
|
|
66
|
+
self.isThreadRun = False
|
|
67
|
+
sleep(0.2)
|
|
68
|
+
pkt = self.makepkt.getPacket()
|
|
69
|
+
if (pkt[15]&0x80) == 0x80:
|
|
70
|
+
self.makepkt.clearPacket()
|
|
71
|
+
self.setOption(0x8000)
|
|
72
|
+
self.serial.write(self.makepkt.getPacket())
|
|
73
|
+
sleep(0.2)
|
|
74
|
+
self.serial.write(self.makepkt.clearPacket())
|
|
75
|
+
sleep(0.2)
|
|
76
|
+
if self.serial != None:
|
|
77
|
+
if self.serial.isOpen() == True:
|
|
78
|
+
self.serial.close()
|
|
79
|
+
|
|
80
|
+
def setOption(self, option):
|
|
81
|
+
data = option.to_bytes(2, byteorder="little", signed=False)
|
|
82
|
+
self.makepkt.makePacket(14, data)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def takeoff(self):
|
|
86
|
+
alt = 70
|
|
87
|
+
data = alt.to_bytes(2, byteorder="little", signed=False)
|
|
88
|
+
self.makepkt.makePacket(12, data)
|
|
89
|
+
alt = 0x2F
|
|
90
|
+
data = alt.to_bytes(2, byteorder="little", signed=False)
|
|
91
|
+
self.setOption(0x2F)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def landing(self):
|
|
95
|
+
alt = 0
|
|
96
|
+
data = alt.to_bytes(2, byteorder="little", signed=False)
|
|
97
|
+
self.makepkt.makePacket(12, data)
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def altitude(self, alt):
|
|
101
|
+
data = alt.to_bytes(2, byteorder="little", signed=False)
|
|
102
|
+
self.makepkt.makePacket(12, data)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def velocity(self, dir=0, vel=100):
|
|
106
|
+
if dir > 3:
|
|
107
|
+
return
|
|
108
|
+
if dir==1 or dir==3:
|
|
109
|
+
vel *= -1;
|
|
110
|
+
data = vel.to_bytes(2, byteorder="little", signed=True)
|
|
111
|
+
if dir==0 or dir==1:
|
|
112
|
+
self.makepkt.makePacket(8, data)
|
|
113
|
+
else:
|
|
114
|
+
self.makepkt.makePacket(6, data)
|
|
115
|
+
self.setOption(0x0F)
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def move(self, dir=0, dist=100):
|
|
119
|
+
if dir > 3:
|
|
120
|
+
return
|
|
121
|
+
if dir==1 or dir==3:
|
|
122
|
+
dist *= -1;
|
|
123
|
+
if dir==0 or dir==1:
|
|
124
|
+
self.posX += dist
|
|
125
|
+
data = self.posX.to_bytes(2, byteorder="little", signed=True)
|
|
126
|
+
self.makepkt.makePacket(8, data)
|
|
127
|
+
else:
|
|
128
|
+
self.posY += dist
|
|
129
|
+
data = self.posY.to_bytes(2, byteorder="little", signed=True)
|
|
130
|
+
self.makepkt.makePacket(6, data)
|
|
131
|
+
self.setOption(0x2F)
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def rotation(self, rot=90):
|
|
135
|
+
self.rot += rot
|
|
136
|
+
data = self.rot.to_bytes(2, byteorder="little", signed=True)
|
|
137
|
+
self.makepkt.makePacket(10, data)
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
def motor(self, what, speed):
|
|
141
|
+
speed = DefLib.constrain(speed, 100, 0)
|
|
142
|
+
data = speed.to_bytes(2, byteorder="little", signed=True)
|
|
143
|
+
self.makepkt.makePacket(what*2+6, data)
|
|
144
|
+
self.setOption(0x8000)
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def emergency(self):
|
|
148
|
+
self.setOption(0x00)
|
|
149
|
+
self.serial.write(self.makepkt.getPacket())
|
|
150
|
+
|
|
151
|
+
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
from
|
|
1
|
+
from pyaidrone.deflib import *
|
|
2
2
|
|
|
3
3
|
class Packet:
|
|
4
|
-
def __init__(self, model =
|
|
4
|
+
def __init__(self, model = AIDRONE):
|
|
5
5
|
self.model = model
|
|
6
6
|
self.packet = bytearray(20)
|
|
7
|
-
if self.model ==
|
|
7
|
+
if self.model == AIDRONE:
|
|
8
8
|
self.packet[0:5] = [0x26, 0xA8, 0x14, 0xB1, 0x14]
|
|
9
9
|
|
|
10
10
|
def getPacket(self):
|
|
@@ -22,7 +22,7 @@ class Packet:
|
|
|
22
22
|
def clearPacket(self):
|
|
23
23
|
for n in range(5, 20):
|
|
24
24
|
self.packet[n] = 0
|
|
25
|
-
if self.model ==
|
|
25
|
+
if self.model == AIDRONE:
|
|
26
26
|
self.packet[5] = self.packet[14] = 0x01
|
|
27
27
|
self.packet[16] = self.packet[18] = 0x64
|
|
28
28
|
return self.packet
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: pyaidrone
|
|
3
|
+
Version: 1.2
|
|
4
|
+
Summary: Library for AIDrone Products
|
|
5
|
+
Home-page: http://www.ir-brain.com
|
|
6
|
+
Author: IR-Brain
|
|
7
|
+
Author-email: ceo@ir-brain.com
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.6
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
|
|
14
|
+
## install pyaidrone
|
|
15
|
+
|
|
16
|
+
> python setup.py install
|
|
17
|
+
> or
|
|
18
|
+
> python install pyaidrone
|
|
19
|
+
|
|
20
|
+
### install Packages
|
|
21
|
+
|
|
22
|
+
> pip install pyserial
|
|
23
|
+
> pip install pynput
|
pyaidrone-1.2/setup.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
|
|
3
|
+
setup(
|
|
4
|
+
name="pyaidrone",
|
|
5
|
+
version="1.2",
|
|
6
|
+
description="Library for AIDrone Products",
|
|
7
|
+
long_description=open("README.md").read(), # README.md 내용을 long_description으로 사용
|
|
8
|
+
long_description_content_type="text/markdown", # README 파일이 markdown 형식임을 지정
|
|
9
|
+
author="IR-Brain",
|
|
10
|
+
author_email="ceo@ir-brain.com",
|
|
11
|
+
url="http://www.ir-brain.com",
|
|
12
|
+
packages=find_packages(), # find_packages()를 사용해 서브패키지까지 자동 탐색
|
|
13
|
+
install_requires=[
|
|
14
|
+
'pyserial>=3.4',
|
|
15
|
+
'pynput>=1.7.3',
|
|
16
|
+
],
|
|
17
|
+
classifiers=[ # 추가 메타데이터
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"License :: OSI Approved :: MIT License", # 실제 라이선스를 설정해야 함
|
|
20
|
+
"Operating System :: OS Independent",
|
|
21
|
+
],
|
|
22
|
+
python_requires='>=3.6', # 최소 Python 버전 요구 사항 설정
|
|
23
|
+
)
|
pyaidrone-1.0/PKG-INFO
DELETED
|
File without changes
|
pyaidrone-1.0/setup.py
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
from setuptools import setup, find_packages
|
|
2
|
-
|
|
3
|
-
setup(
|
|
4
|
-
name = "pyaidrone",
|
|
5
|
-
version = "1.0",
|
|
6
|
-
description = "Library for AIDrone Products",
|
|
7
|
-
author = "IR-Brain",
|
|
8
|
-
author_email = "ceo@ir-brain.com",
|
|
9
|
-
url = "http://www.ir-brain.com",
|
|
10
|
-
packages = ['pyaidrone',
|
|
11
|
-
],
|
|
12
|
-
install_requires = [
|
|
13
|
-
'pyserial>=3.4',
|
|
14
|
-
'pynput>=1.7.3',
|
|
15
|
-
],
|
|
16
|
-
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|