Skip to content

Commit 768c58e

Browse files
authored
Merge pull request #522 from bitcraze/Aris/Issues_in_examples
Fixed some example issues
2 parents b7ead19 + e17a506 commit 768c58e

File tree

4 files changed

+22
-5
lines changed

4 files changed

+22
-5
lines changed

examples/autonomy/autonomousSequence.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
one every 5 seconds.
2828
2929
This example is intended to work with the Loco Positioning System in TWR TOA
30-
mode. It aims at documenting how to set the Crazyflie in position control mode
31-
and how to send setpoints.
30+
mode and with the Lighthouse Positioning System. It aims at documenting how
31+
to set the Crazyflie in position control mode and how to send setpoints.
3232
"""
3333
import time
3434

@@ -56,6 +56,19 @@
5656
]
5757

5858

59+
def take_off(cf, position):
60+
take_off_time = 1.0
61+
sleep_time = 0.1
62+
steps = int(take_off_time / sleep_time)
63+
vz = position[2] / take_off_time
64+
65+
print(f'take off at {position[2]}')
66+
67+
for i in range(steps):
68+
cf.commander.send_velocity_world_setpoint(0, 0, vz, 0)
69+
time.sleep(sleep_time)
70+
71+
5972
def position_callback(timestamp, data, logconf):
6073
x = data['kalman.stateX']
6174
y = data['kalman.stateY']
@@ -81,6 +94,9 @@ def run_sequence(scf, sequence):
8194
cf.platform.send_arming_request(True)
8295
time.sleep(1.0)
8396

97+
take_off(cf, sequence[0])
98+
time.sleep(1.0)
99+
84100
for position in sequence:
85101
print('Setting position {}'.format(position))
86102
for i in range(50):

examples/autonomy/position_commander_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
3030
Change the URI variable to your Crazyflie configuration.
3131
"""
32-
from time import time
32+
import time
3333

3434
import cflib.crtp
3535
from cflib.crazyflie import Crazyflie

examples/positioning/flowsequenceSync.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"""
2525
Simple example that connects to the crazyflie at `URI` and runs a figure 8
2626
sequence. This script requires some kind of location system, it has been
27-
tested with (and designed for) the flow deck.
27+
tested with the flow deck and the lighthouse positioning system.
2828
2929
Change the URI variable to your Crazyflie configuration.
3030
"""

examples/swarm/swarmSequence.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,6 @@ def run_sequence(scf, sequence):
215215
try:
216216
cf = scf.cf
217217

218-
arm(cf)
219218
take_off(cf, sequence[0])
220219
for position in sequence:
221220
print('Setting position {}'.format(position))
@@ -249,4 +248,6 @@ def run_sequence(scf, sequence):
249248
print('Waiting for parameters to be downloaded...')
250249
swarm.parallel(wait_for_param_download)
251250

251+
swarm.parallel(arm)
252+
252253
swarm.parallel(run_sequence, args_dict=seq_args)

0 commit comments

Comments
 (0)