pyaidrone 1.2__tar.gz → 1.3__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 → pyaidrone-1.3}/PKG-INFO +1 -1
- {pyaidrone-1.2 → pyaidrone-1.3}/pyaidrone/aiDrone.py +42 -1
- {pyaidrone-1.2 → pyaidrone-1.3}/pyaidrone/parse.py +13 -0
- {pyaidrone-1.2 → pyaidrone-1.3}/pyaidrone.egg-info/PKG-INFO +1 -1
- {pyaidrone-1.2 → pyaidrone-1.3}/setup.py +1 -1
- {pyaidrone-1.2 → pyaidrone-1.3}/README.md +0 -0
- {pyaidrone-1.2 → pyaidrone-1.3}/pyaidrone/__init__.py +0 -0
- {pyaidrone-1.2 → pyaidrone-1.3}/pyaidrone/deflib.py +0 -0
- {pyaidrone-1.2 → pyaidrone-1.3}/pyaidrone/ikeyevent.py +0 -0
- {pyaidrone-1.2 → pyaidrone-1.3}/pyaidrone/packet.py +0 -0
- {pyaidrone-1.2 → pyaidrone-1.3}/pyaidrone.egg-info/SOURCES.txt +0 -0
- {pyaidrone-1.2 → pyaidrone-1.3}/pyaidrone.egg-info/dependency_links.txt +0 -0
- {pyaidrone-1.2 → pyaidrone-1.3}/pyaidrone.egg-info/requires.txt +0 -0
- {pyaidrone-1.2 → pyaidrone-1.3}/pyaidrone.egg-info/top_level.txt +0 -0
- {pyaidrone-1.2 → pyaidrone-1.3}/setup.cfg +0 -0
|
@@ -32,7 +32,25 @@ class AIDrone(Parse, Packet):
|
|
|
32
32
|
self.receiveCallback(packet)
|
|
33
33
|
self.serial.write(self.makepkt.getPacket())
|
|
34
34
|
|
|
35
|
+
def requestSensorData(self):
|
|
36
|
+
self.makepkt.makePacket(8, bytes([0x10]))
|
|
37
|
+
self.serial.write(self.makepkt.getPacket())
|
|
38
|
+
|
|
39
|
+
def get_gyro(self):
|
|
40
|
+
return self.sensors["gyro"]
|
|
41
|
+
|
|
42
|
+
def get_acceleration(self):
|
|
43
|
+
return self.sensors["acceleration"]
|
|
35
44
|
|
|
45
|
+
def get_altitude(self):
|
|
46
|
+
return self.sensors["altitude"]
|
|
47
|
+
|
|
48
|
+
def get_position(self):
|
|
49
|
+
return self.sensors["position"]
|
|
50
|
+
|
|
51
|
+
def get_tof(self):
|
|
52
|
+
return self.sensors["tof"]
|
|
53
|
+
|
|
36
54
|
def Open(self, portName = "None"):
|
|
37
55
|
if eq(portName, "None"):
|
|
38
56
|
nodes = comports()
|
|
@@ -132,11 +150,12 @@ class AIDrone(Parse, Packet):
|
|
|
132
150
|
|
|
133
151
|
|
|
134
152
|
def rotation(self, rot=90):
|
|
135
|
-
self.rot += rot
|
|
153
|
+
self.rot += rot
|
|
136
154
|
data = self.rot.to_bytes(2, byteorder="little", signed=True)
|
|
137
155
|
self.makepkt.makePacket(10, data)
|
|
138
156
|
|
|
139
157
|
|
|
158
|
+
|
|
140
159
|
def motor(self, what, speed):
|
|
141
160
|
speed = DefLib.constrain(speed, 100, 0)
|
|
142
161
|
data = speed.to_bytes(2, byteorder="little", signed=True)
|
|
@@ -147,5 +166,27 @@ class AIDrone(Parse, Packet):
|
|
|
147
166
|
def emergency(self):
|
|
148
167
|
self.setOption(0x00)
|
|
149
168
|
self.serial.write(self.makepkt.getPacket())
|
|
169
|
+
|
|
170
|
+
def motor(self, motor_id, speed):
|
|
171
|
+
"""
|
|
172
|
+
모터 속도를 0~100 범위에서 설정합니다.
|
|
173
|
+
|
|
174
|
+
:param motor_id: 제어할 모터의 인덱스 (0~3은 개별 모터, 4는 모든 모터)
|
|
175
|
+
:param speed: 모터 속도 (0 ~ 100)
|
|
176
|
+
"""
|
|
177
|
+
speed = max(0, min(speed, 100)) # 속도를 0~100 범위로 제한
|
|
178
|
+
scaled_speed = speed * 10 # 내부적으로 0~1000 범위로 변환
|
|
179
|
+
data = scaled_speed.to_bytes(2, byteorder="little", signed=False)
|
|
180
|
+
|
|
181
|
+
# 모든 모터를 동시에 제어
|
|
182
|
+
if motor_id == 4:
|
|
183
|
+
self.makepkt.makePacket(12, data) # 모든 모터의 속도를 설정 (THR 제어)
|
|
184
|
+
else:
|
|
185
|
+
# 개별 모터 제어
|
|
186
|
+
self.makepkt.makePacket(6 + (motor_id * 2), data)
|
|
187
|
+
|
|
188
|
+
# 패킷을 시리얼 포트를 통해 전송
|
|
189
|
+
self.serial.write(self.makepkt.getPacket())
|
|
190
|
+
|
|
150
191
|
|
|
151
192
|
|
|
@@ -8,6 +8,7 @@ class Parse:
|
|
|
8
8
|
self.type = 0
|
|
9
9
|
self.packetLen = 20
|
|
10
10
|
self.headMatchCnt = 0
|
|
11
|
+
self.sensors = {"gyro":(0,0), "acceleration":(0,0), "altitude": (0,0), "position": (0, 0), "tof": 0}
|
|
11
12
|
if self.model == AIDRONE:
|
|
12
13
|
self.head = (0x26, 0xA8, 0x14, 0xA0)
|
|
13
14
|
|
|
@@ -40,6 +41,18 @@ class Parse:
|
|
|
40
41
|
self.offset = 0
|
|
41
42
|
chksum = DefLib.checksum(self.packet)
|
|
42
43
|
if chksum == self.packet[5]:
|
|
44
|
+
self.parseSensorData(slef.packet)
|
|
43
45
|
return self.packet
|
|
44
46
|
return "None"
|
|
45
47
|
|
|
48
|
+
def parseSensorData(self, packet):
|
|
49
|
+
if packet[3] == 0xA2:
|
|
50
|
+
self.sensors["gyro"] = (int.from_bytes(packet[9:11], "little", signed=True),
|
|
51
|
+
int.from_bytes(packet[11:13], "little", signed=True))
|
|
52
|
+
self.sensors["acceleration"] = (int.from_bytes(packet[13:15], "little", signed=True),
|
|
53
|
+
int.from_bytes(packet[15:17], "little", signed=True))
|
|
54
|
+
self.sensors["altitude"] = int.from_bytes(packet[17:19], "little", signed=True)
|
|
55
|
+
self.sensors["position"] = (int.from_bytes(packet[19:21], "little", signed=True),
|
|
56
|
+
int.from_bytes(packet[21:23], "little", signed=True))
|
|
57
|
+
self.sensors["tof"] = int.from_bytes(packet[23:25], "little", signed=True)
|
|
58
|
+
|
|
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
|
|
|
2
2
|
|
|
3
3
|
setup(
|
|
4
4
|
name="pyaidrone",
|
|
5
|
-
version="1.
|
|
5
|
+
version="1.3",
|
|
6
6
|
description="Library for AIDrone Products",
|
|
7
7
|
long_description=open("README.md").read(), # README.md 내용을 long_description으로 사용
|
|
8
8
|
long_description_content_type="text/markdown", # README 파일이 markdown 형식임을 지정
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|