Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2020-1-capstone-design1
/
JSH_Project7
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
이유진
2020-06-18 22:20:47 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
491a1ec408fbb26a5ec15c21c55a7cb6571b9434
491a1ec4
1 parent
d10793e5
키보드를 통한 착륙 코드 추가 (드론 2대)
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
9 deletions
yujin_test/step2.py
yujin_test/step2.py
View file @
491a1ec
...
...
@@ -13,16 +13,16 @@ def setHeight(_mHeight, _slave):
while
True
:
_sHeight
=
_slave
.
get_height
()
if
_mHeight
-
errorRange
<=
_sHeight
<=
_mHeight
+
errorRange
:
print
(
'
hit
'
)
print
(
'
[hit]
'
)
return
elif
_sHeight
<
_mHeight
-
errorRange
:
_slave
.
go
(
Direction
.
UP
)
sleep
(
0.2
)
print
(
'
up
'
)
print
(
'
[up]
'
)
elif
_sHeight
>
_mHeight
+
errorRange
:
_slave
.
go
(
Direction
.
DOWN
)
sleep
(
0.2
)
print
(
'
down
'
)
print
(
'
[down]
'
)
def
main
():
...
...
@@ -49,13 +49,13 @@ def main():
# 한 번 성공하고 그 이후로 안 되네요
# $pip3 install keyboard
# 로 keyboard를 설치한 다음 실행해야 합니다.
if
keyboard
.
is_pressed
(
'q'
):
print
(
'드론을 착륙시킵니다.'
)
slave
.
land
()
print
(
'land'
)
# slave.emergency_stop()
# print('emergency_stop')
# 성공 : q를 계속 누르고 계세요! ex) qqqqqqqqqqqqqq
if
keyboard
.
is_pressed
(
'q'
):
# 키보드에서 'q'가 입력되면 while문 탈출
print
(
'[Keyboard input occur: Quit!]'
)
break
elif
not
slave
.
isConnected
():
# slave 연결이 끊기면 프로그램 종료
print
(
'[Slave Disconnected]'
)
return
# master의 전 높이 대비 moveRange 만큼의 차이가 있으면 slave가 움직이도록
if
abs
(
mHeight
-
bHeight
)
>
moveRange
:
...
...
@@ -70,6 +70,14 @@ def main():
bX
=
mPosition
.
X
bY
=
mPosition
.
Y
print
(
'드론을 착륙시킵니다.'
)
slave
.
arm_pattern
()
# LED 효과
print
(
'Land'
)
slave
.
land
()
# 착륙
# 연결해제 -> 여기까지 성공했다면 배터리 안 빼도 다시 연결 됩니다.
slave
.
disconnect
()
master
.
disconnect
()
if
__name__
==
'__main__'
:
main
()
...
...
Please
register
or
login
to post a comment