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:29 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d10793e5e99b37066febe4daf3536c74dffe29a8
d10793e5
1 parent
ce356ab9
키보드를 통한 착륙 코드 (드론 1대)
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
0 deletions
yujin_test/landByInput.py
yujin_test/landByInput.py
0 → 100644
View file @
d10793e
# 드론 착륙 by 키보드; 테스트 코드 (드론 1대용)
import
CoDrone
import
keyboard
def
getPosition
(
drone
):
position
=
drone
.
get_opt_flow_position
()
# 상대좌표 (시작 0,0)
height
=
drone
.
get_height
()
# 고
print
(
"x={} y={} z={}"
.
format
(
position
.
X
,
position
.
Y
,
height
))
# 단위(mm)
def
main
():
drone
=
CoDrone
.
CoDrone
()
drone
.
connect
()
drone
.
takeoff
()
# 이륙
while
True
:
getPosition
(
drone
)
if
keyboard
.
is_pressed
(
'q'
):
# 키보드에서 'q'가 입력되면 while문 탈출
print
(
'Keyboard input occur: Quit!'
)
break
elif
not
drone
.
isConnected
():
# 연결이 끊기면 프로그램 종료
print
(
'Disconnected'
)
return
print
(
'드론을 착륙시킵니다.'
)
drone
.
arm_pattern
()
# LED 효과
print
(
'Land'
)
drone
.
land
()
# 착륙
drone
.
disconnect
()
# 연결해제
if
__name__
==
'__main__'
:
main
()
Please
register
or
login
to post a comment