Skip to content
GitLab
Explore
Sign in
Commits on Source (3)
Bridge: rename variables; do not check for connection
· d032e3a6
Marlene Böhmer
authored
Oct 29, 2019
d032e3a6
Update crazyflie-lib-python
· 8aff8807
Marlene Böhmer
authored
Oct 29, 2019
8aff8807
Flightscripts: IP command line parameter
· 20cee6b4
Marlene Böhmer
authored
Oct 29, 2019
20cee6b4
Show whitespace changes
Inline
Side-by-side
crazyflie-lib-python
@
bf458be7
Compare
fee47c6a
...
bf458be7
Subproject commit
fee47c6a26e7e9bb343ec30400b7d53ae18de43e
Subproject commit
bf458be7171dd31d47cedd8efe3b01c36682e198
salt/drone/scripts/bridge.py
View file @
20cee6b4
...
...
@@ -3,6 +3,7 @@
import
sys
import
threading
import
signal
import
time
import
cflib.crtp
as
crtp
from
cflib.crtp.crtpstack
import
CRTPPacket
,
CRTPPort
...
...
@@ -13,16 +14,17 @@ class ForwardBridge(threading.Thread):
threading
.
Thread
.
__init__
(
self
)
self
.
_crazyflie_connection
=
crazyflie_connection
self
.
_client_connection
=
client_connection
self
.
stop_running
=
False
self
.
_
stop_running
=
False
def
run
(
self
):
while
not
self
.
stop_running
:
while
not
self
.
_
stop_running
:
pk
=
self
.
_client_connection
.
receive_packet
(
-
1
)
if
pk
and
not
self
.
stop_running
:
if
pk
and
not
self
.
_
stop_running
:
self
.
_crazyflie_connection
.
send_packet
(
pk
)
time
.
sleep
(
0.001
)
def
stop
(
self
):
self
.
stop_running
=
True
self
.
_
stop_running
=
True
class
BackwardBridge
(
threading
.
Thread
):
...
...
@@ -30,58 +32,60 @@ class BackwardBridge(threading.Thread):
threading
.
Thread
.
__init__
(
self
)
self
.
_crazyflie_connection
=
crazyflie_connection
self
.
_client_connection
=
client_connection
self
.
stop_running
=
False
self
.
_
stop_running
=
False
def
run
(
self
):
while
not
self
.
stop_running
:
while
not
self
.
_
stop_running
:
pk
=
self
.
_crazyflie_connection
.
receive_packet
(
-
1
)
if
pk
and
not
self
.
stop_running
:
if
pk
and
not
self
.
_
stop_running
:
self
.
_client_connection
.
send_packet
(
pk
)
time
.
sleep
(
0.001
)
def
stop
(
self
):
self
.
stop_running
=
True
self
.
_
stop_running
=
True
class
Bridge
:
def
__init__
(
self
,
crazyflie_uri
,
client_uri
):
print
(
'
Initializing Bridge ...
'
)
self
.
crazyflie_uri
=
crazyflie_uri
self
.
client_uri
=
client_uri
self
.
_
crazyflie_uri
=
crazyflie_uri
self
.
_
client_uri
=
client_uri
crtp
.
init_drivers
(
enable_debug_driver
=
False
)
self
.
_crazyflie_connection
=
crtp
.
get_link_driver
(
self
.
crazyflie_uri
,
None
,
None
)
self
.
_crazyflie_connection
=
crtp
.
get_link_driver
(
self
.
_
crazyflie_uri
,
None
,
None
)
if
not
self
.
_crazyflie_connection
:
raise
Exception
(
'
No diver found for Crazyflie URI
'
+
self
.
crazyflie_uri
)
self
.
_client_connection
=
crtp
.
get_link_driver
(
self
.
client_uri
,
None
,
None
)
raise
Exception
(
'
No diver found for Crazyflie URI
'
+
self
.
_
crazyflie_uri
)
self
.
_client_connection
=
crtp
.
get_link_driver
(
self
.
_
client_uri
,
None
,
None
)
if
not
self
.
_client_connection
:
raise
Exception
(
'
No diver found for Client URI
'
+
self
.
client_uri
)
raise
Exception
(
'
No diver found for Client URI
'
+
self
.
_
client_uri
)
self
.
forward_thread
=
None
self
.
backward_thread
=
None
self
.
_
forward_thread
=
None
self
.
_
backward_thread
=
None
print
(
'
Bridge initialized.
'
)
def
check_for_crazyflie_connection
(
self
):
print
(
'
Connecting to
'
+
str
(
self
.
crazyflie_uri
)
+
'
...
'
)
print
(
'
Connecting to
'
+
str
(
self
.
_
crazyflie_uri
)
+
'
...
'
)
packet
=
CRTPPacket
()
packet
.
port
=
CRTPPort
.
LINKCTRL
packet
.
channel
=
1
self
.
_crazyflie_connection
.
send_packet
(
packet
)
self
.
_crazyflie_connection
.
receive_packet
(
-
1
)
print
(
'
Connected to
'
+
str
(
self
.
crazyflie_uri
)
+
'
.
'
)
print
(
'
Connected to
'
+
str
(
self
.
_
crazyflie_uri
)
+
'
.
'
)
def
start
(
self
):
self
.
forward_thread
=
ForwardBridge
(
self
.
_crazyflie_connection
,
self
.
_client_connection
)
self
.
backward_thread
=
BackwardBridge
(
self
.
_crazyflie_connection
,
self
.
_client_connection
)
self
.
forward_thread
.
daemon
=
True
self
.
backward_thread
.
daemon
=
True
self
.
forward_thread
.
start
()
self
.
backward_thread
.
start
()
self
.
_
forward_thread
=
ForwardBridge
(
self
.
_crazyflie_connection
,
self
.
_client_connection
)
self
.
_
backward_thread
=
BackwardBridge
(
self
.
_crazyflie_connection
,
self
.
_client_connection
)
self
.
_
forward_thread
.
daemon
=
True
self
.
_
backward_thread
.
daemon
=
True
self
.
_
forward_thread
.
start
()
self
.
_
backward_thread
.
start
()
def
stop
(
self
):
print
(
'
\n
Stopping threads ...
'
)
self
.
forward_thread
.
stop
()
self
.
backward_thread
.
stop
()
self
.
_
forward_thread
.
stop
()
self
.
_
backward_thread
.
stop
()
print
(
'
Closing connections ...
'
)
self
.
_crazyflie_connection
.
close
()
self
.
_client_connection
.
close
()
...
...
@@ -95,11 +99,11 @@ if __name__ == '__main__':
sys
.
exit
(
0
)
serial_uri
=
'
serial://pi
'
prrt_uri
=
sys
.
argv
[
1
]
prrt_uri
=
'
prrt://
'
+
sys
.
argv
[
1
]
+
'
:5000
'
bridge
=
Bridge
(
serial_uri
,
prrt_uri
)
bridge
.
check_for_crazyflie_connection
()
# optional
#
bridge.check_for_crazyflie_connection() # optional
bridge
.
start
()
print
(
'
\n
Setup finished.
\n
Use
"
Ctrl+C
"
to stop.
\n
'
)
...
...
salt/drone/scripts/circle_flightscript.py
View file @
20cee6b4
...
...
@@ -14,7 +14,8 @@ if len(sys.argv) >= 2:
if
sys
.
argv
[
1
]
==
'
radio
'
:
URI
=
'
radio://0/80/2M
'
elif
sys
.
argv
[
1
]
==
'
prrt
'
:
URI
=
'
prrt://10.8.0.208:5000
'
ip
=
sys
.
argv
[
2
]
URI
=
'
prrt://
'
+
ip
+
'
:5000
'
elif
sys
.
argv
[
1
]
==
'
serial
'
:
URI
=
'
serial://pi
'
else
:
...
...
salt/drone/scripts/line_flightscript.py
View file @
20cee6b4
...
...
@@ -14,7 +14,8 @@ if len(sys.argv) >= 2:
if
sys
.
argv
[
1
]
==
'
radio
'
:
URI
=
'
radio://0/80/2M
'
elif
sys
.
argv
[
1
]
==
'
prrt
'
:
URI
=
'
prrt://10.8.0.208:5000
'
ip
=
sys
.
argv
[
2
]
URI
=
'
prrt://
'
+
ip
+
'
:5000
'
elif
sys
.
argv
[
1
]
==
'
serial
'
:
URI
=
'
serial://pi
'
else
:
...
...
salt/drone/scripts/log_gen_flightscript.py
View file @
20cee6b4
...
...
@@ -14,7 +14,8 @@ if len(sys.argv) >= 2:
if
sys
.
argv
[
1
]
==
'
radio
'
:
URI
=
'
radio://0/80/2M
'
elif
sys
.
argv
[
1
]
==
'
prrt
'
:
URI
=
'
prrt://10.8.0.208:5000
'
ip
=
sys
.
argv
[
2
]
URI
=
'
prrt://
'
+
ip
+
'
:5000
'
elif
sys
.
argv
[
1
]
==
'
serial
'
:
URI
=
'
serial://pi
'
else
:
...
...
@@ -30,6 +31,7 @@ if __name__ == '__main__':
cflib
.
crtp
.
init_drivers
(
enable_debug_driver
=
False
)
with
SyncCrazyflie
(
URI
)
as
scf
:
time
.
sleep
(
1
)
with
MotionCommander
(
scf
)
as
mc
:
print
(
'
Taking off!
'
)
time
.
sleep
(
0.5
)
...
...
salt/drone/scripts/simple_flightscript.py
View file @
20cee6b4
...
...
@@ -14,7 +14,8 @@ if len(sys.argv) >= 2:
if
sys
.
argv
[
1
]
==
'
radio
'
:
URI
=
'
radio://0/80/2M
'
elif
sys
.
argv
[
1
]
==
'
prrt
'
:
URI
=
'
prrt://10.8.0.208:5000
'
ip
=
sys
.
argv
[
2
]
URI
=
'
prrt://
'
+
ip
+
'
:5000
'
elif
sys
.
argv
[
1
]
==
'
serial
'
:
URI
=
'
serial://pi
'
else
:
...
...