Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
crazyflie-lib-python
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lukas Wegmann
crazyflie-lib-python
Commits
392b4706
Commit
392b4706
authored
5 years ago
by
Arnaud Taffanel
Browse files
Options
Downloads
Patches
Plain Diff
Fix synchrounousSequence flake8/style
parent
84859f55
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/swarm/synchronizedSequence.py
+55
-50
55 additions, 50 deletions
examples/swarm/synchronizedSequence.py
with
55 additions
and
50 deletions
examples/swarm/synchronizedSequence.py
+
55
−
50
View file @
392b4706
...
...
@@ -23,7 +23,8 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
"""
Simple example of a synchronized swarm choreography using the High level commander.
Simple example of a synchronized swarm choreography using the High level
commander.
The swarm takes off and flies a synchronous choreography before landing.
The take-of is relative to the start position but the Goto are absolute.
...
...
@@ -33,7 +34,10 @@ This example is intended to work with any absolute positioning system.
It aims at documenting how to use the High Level Commander together with
the Swarm class to achieve synchronous sequences.
"""
import
threading
import
time
from
collections
import
namedtuple
from
queue
import
Queue
import
cflib.crtp
from
cflib.crazyflie.log
import
LogConfig
...
...
@@ -41,19 +45,17 @@ from cflib.crazyflie.swarm import CachedCfFactory
from
cflib.crazyflie.swarm
import
Swarm
from
cflib.crazyflie.syncLogger
import
SyncLogger
from
collections
import
namedtuple
import
threading
from
queue
import
Queue
# Time for one step in second
STEP_TIME
=
1
# Possible commands, all times are in seconds
Takeoff
=
namedtuple
(
'
Takeoff
'
,
[
'
height
'
,
'
time
'
])
Land
=
namedtuple
(
"
Land
"
,
[
'
time
'
])
Land
=
namedtuple
(
'
Land
'
,
[
'
time
'
])
Goto
=
namedtuple
(
'
Goto
'
,
[
'
x
'
,
'
y
'
,
'
z
'
,
'
time
'
])
Ring
=
namedtuple
(
'
Ring
'
,
[
'
r
'
,
'
g
'
,
'
b
'
,
'
intensity
'
,
'
time
'
])
# RGB [0-255], Intensity [0.0-1.0]
Quit
=
namedtuple
(
'
Quit
'
,
[])
# Reserved for the control loop, do not use in sequence
# RGB [0-255], Intensity [0.0-1.0]
Ring
=
namedtuple
(
'
Ring
'
,
[
'
r
'
,
'
g
'
,
'
b
'
,
'
intensity
'
,
'
time
'
])
# Reserved for the control loop, do not use in sequence
Quit
=
namedtuple
(
'
Quit
'
,
[])
uris
=
[
'
radio://0/10/2M/E7E7E7E701
'
,
# cf_id 0, startup position [-0.5, -0.5]
...
...
@@ -99,6 +101,7 @@ sequence = [
(
15
,
2
,
Ring
(
0
,
0
,
0
,
0
,
5
)),
]
def
wait_for_position_estimator
(
scf
):
print
(
'
Waiting for estimator to find position...
'
)
...
...
@@ -198,26 +201,27 @@ def crazyflie_control(scf):
command
.
intensity
,
command
.
time
)
pass
else
:
print
(
"
Warning! unknown command {} for uri {}
"
.
format
(
command
,
print
(
'
Warning! unknown command {} for uri {}
'
.
format
(
command
,
cf
.
uri
))
def
control_thread
():
pointer
=
0
step
=
0
stop
=
False
while
not
stop
:
print
(
"
Step {}:
"
.
format
(
step
))
print
(
'
Step {}:
'
.
format
(
step
))
while
sequence
[
pointer
][
0
]
<=
step
:
cf_id
=
sequence
[
pointer
][
1
]
command
=
sequence
[
pointer
][
2
]
print
(
"
- Running: {} on {}
"
.
format
(
command
,
cf_id
))
print
(
'
- Running: {} on {}
'
.
format
(
command
,
cf_id
))
controlQueues
[
cf_id
].
put
(
command
)
pointer
+=
1
if
pointer
>=
len
(
sequence
):
print
(
"
Reaching the end of the sequence, stopping!
"
)
print
(
'
Reaching the end of the sequence, stopping!
'
)
stop
=
True
break
...
...
@@ -227,6 +231,7 @@ def control_thread():
for
ctrl
in
controlQueues
:
ctrl
.
put
(
Quit
())
if
__name__
==
'
__main__
'
:
controlQueues
=
[
Queue
()
for
_
in
range
(
len
(
uris
))]
...
...
@@ -236,7 +241,7 @@ if __name__ == '__main__':
swarm
.
parallel_safe
(
activate_high_level_commander
)
swarm
.
parallel_safe
(
reset_estimator
)
print
(
"
Starting sequence!
"
)
print
(
'
Starting sequence!
'
)
threading
.
Thread
(
target
=
control_thread
).
start
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment