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-21 03:42:39 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
fa3f7f261605164eb26f2cb7751bf8078d45755e
fa3f7f26
1 parent
4a878fff
높이 동기화
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
final_code/step1.py
final_code/step1.py
View file @
fa3f7f2
# step1 : 높이조정
import
CoDrone
import
keyboard
from
CoDrone.system
import
Direction
from
CoDrone.system
import
Mode
from
time
import
sleep
errorRange
=
50
# 오차범위
moveRange
=
150
# 움직였다고 판단할 거리
heightRange
=
70
# 움직였다고 판단할 거리 height
# 키보드로 콘솔창에 'q'를 누르면 드론이 착륙하게 만드는 코드
def
stop
(
_master
,
_slave
):
if
keyboard
.
is_pressed
(
'q'
):
# 키보드에서 'q'가 입력되면 while문 탈출
print
(
'[Keyboard input occur: Quit!]'
)
# 착륙
에 성공할 때까지
LED 효과
# 착륙
시작시
LED 효과
_master
.
arm_default_pattern
(
0
,
125
,
155
,
Mode
.
DOUBLE_BLINK
,
10
)
_slave
.
arm_default_pattern
(
0
,
125
,
155
,
Mode
.
DOUBLE_BLINK
,
10
)
return
True
...
...
@@ -38,11 +39,9 @@ def setHeight(_master, _mHeight, _slave):
return
elif
_sHeight
<
_mHeight
-
errorRange
:
_slave
.
go
(
Direction
.
UP
,
0
,
100
)
# sleep(0.2)
print
(
'[up]'
)
elif
_sHeight
>
_mHeight
+
errorRange
:
_slave
.
go
(
Direction
.
DOWN
,
0
,
100
)
# sleep(0.2)
print
(
'[down]'
)
...
...
@@ -70,6 +69,7 @@ def main():
.
format
(
mPosition
.
X
,
mPosition
.
Y
,
mHeight
,
sPosition
.
X
,
sPosition
.
Y
,
sHeight
))
# 좌표출력/단위(mm)
if
stop
(
master
,
slave
):
print
(
'드론을 착륙시킵니다.'
)
break
# master의 전 높이 대비 +- moveRange 만큼의 차이가 있으면 slave가 움직이도록
...
...
@@ -80,10 +80,10 @@ def main():
slave
.
arm_strobe
()
setHeight
(
master
,
mHeight
,
slave
)
print
(
'Land'
)
slave
.
land
()
# 착륙
master
.
arm_off
()
slave
.
arm_off
()
print
(
'Land'
)
slave
.
land
()
# 착륙
# 연결해제 -> 여기까지 성공했다면 배터리 안 빼도 다시 연결 됩니다.
slave
.
disconnect
()
...
...
Please
register
or
login
to post a comment