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-13 17:54:16 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
44adc5f7823d5b53e0d069b450874899715dfd8b
44adc5f7
1 parent
b7a1e905
테스크 코드 추가
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
116 additions
and
0 deletions
yujin_test/t1.py
yujin_test/t2.py
yujin_test/t3.py
yujin_test/t1.py
0 → 100644
View file @
44adc5f
# 앞으로 이동하고 거리를 일치시키는 테스트 (해당 X 초 동안)
import
CoDrone
from
CoDrone
import
Direction
import
time
def
main
():
# 드론 셋팅
master
=
CoDrone
.
CoDrone
()
master
.
connect
(
"None"
,
"COM5"
,
False
)
slave
=
CoDrone
.
CoDrone
()
slave
.
connect
(
"None"
,
"COM6"
,
False
)
while
True
:
# master
mPosition
=
master
.
get_opt_flow_position
()
# 상대좌표 (시작 0,0)
mHeight
=
master
.
get_height
()
# 고도
# slave
sPosition
=
slave
.
get_opt_flow_position
()
sHeight
=
slave
.
get_height
()
print
(
"master [x={} y={} z={}] slave [x={} y={} z={}]"
.
format
(
mPosition
.
X
,
mPosition
.
Y
,
mHeight
,
sPosition
.
X
,
sPosition
.
Y
,
sHeight
))
# 좌표출력/단위(mm)
if
mHeight
>
20
:
# 높이 제약
slave
.
takeoff
()
slave
.
go
(
Direction
.
FORWARD
,
mPosition
.
X
)
# power를 10만주니까 약한 것 같아서 뺐음
# 종료조건
elif
mHeight
<
-
20
:
slave
.
land
()
# 연결끊기
master
.
disconnect
()
slave
.
disconnect
()
return
if
__name__
==
'__main__'
:
main
()
yujin_test/t2.py
0 → 100644
View file @
44adc5f
# 앞으로 이동하고 거리를 일치시키는 테스트 (duration 없이, 일치하면 stop)
import
CoDrone
from
CoDrone
import
Direction
import
time
def
main
():
# 드론 셋팅
master
=
CoDrone
.
CoDrone
()
master
.
connect
(
"None"
,
"COM5"
,
False
)
slave
=
CoDrone
.
CoDrone
()
slave
.
connect
(
"None"
,
"COM6"
,
False
)
while
True
:
# master
mPosition
=
master
.
get_opt_flow_position
()
# 상대좌표 (시작 0,0)
mHeight
=
master
.
get_height
()
# 고도
# slave
sPosition
=
slave
.
get_opt_flow_position
()
sHeight
=
slave
.
get_height
()
print
(
"master [x={} y={} z={}] slave [x={} y={} z={}]"
.
format
(
mPosition
.
X
,
mPosition
.
Y
,
mHeight
,
sPosition
.
X
,
sPosition
.
Y
,
sHeight
))
# 좌표출력/단위(mm)
if
mHeight
>
20
:
# 높이 제약
slave
.
takeoff
()
while
sPosition
.
X
<=
mPosition
.
X
:
# slave의 x좌표가 master의 x보다 작을 때까지!
# 약간... 양수로만 움직인다고 가정
slave
.
go
(
Direction
.
FORWARD
)
# 종료조건
elif
mHeight
<
-
20
:
slave
.
land
()
# 연결끊기
master
.
disconnect
()
slave
.
disconnect
()
return
if
__name__
==
'__main__'
:
main
()
yujin_test/t3.py
0 → 100644
View file @
44adc5f
# 앞으로 이동하고 거리를 일치시키는 테스트 (duration 없이, 일치하면 stop)
# 이번에는 takeoff 하고 시작!!!!!
import
CoDrone
from
CoDrone
import
Direction
import
time
def
main
():
# 드론 셋팅
master
=
CoDrone
.
CoDrone
()
master
.
connect
(
"None"
,
"COM5"
,
False
)
slave
=
CoDrone
.
CoDrone
()
slave
.
connect
(
"None"
,
"COM6"
,
False
)
slave
.
takeoff
()
# slave를 띄워놓고 시작. 혹시 이거때문에 제대로 움직이지 않나 싶어서
while
True
:
# master
mPosition
=
master
.
get_opt_flow_position
()
# 상대좌표 (시작 0,0)
mHeight
=
master
.
get_height
()
# 고도
# slave
sPosition
=
slave
.
get_opt_flow_position
()
sHeight
=
slave
.
get_height
()
print
(
"master [x={} y={} z={}] slave [x={} y={} z={}]"
.
format
(
mPosition
.
X
,
mPosition
.
Y
,
mHeight
,
sPosition
.
X
,
sPosition
.
Y
,
sHeight
))
# 좌표출력/단위(mm)
if
40
>
mHeight
>
20
:
# 높이 제약
while
sPosition
.
X
<=
mPosition
.
X
:
# slave의 x좌표가 master의 x보다 작을 때까지!
# 약간... 양수로만 움직인다고 가정
slave
.
go
(
Direction
.
FORWARD
)
# 종료조건
elif
mHeight
<
-
20
:
slave
.
land
()
# 연결끊기
master
.
disconnect
()
slave
.
disconnect
()
return
if
__name__
==
'__main__'
:
main
()
Please
register
or
login
to post a comment