Skip to content

Commit eb22acc

Browse files
authored
Merge pull request #531 from bitcraze/Aris/sbs_tutorials_update
Solved arming issue on sbs tutorials
2 parents db51fc2 + 185d517 commit eb22acc

File tree

2 files changed

+29
-25
lines changed

2 files changed

+29
-25
lines changed

docs/user-guides/sbs_motion_commander.md

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,6 @@ Since this tutorial won't be a table top tutorial like last time, but an actual
5555
We want to know if the deck is correctly attached before flying, therefore we will add a callback for the `"deck.bcFlow2"` parameter. Add the following line after the `...SyncCrazyflie(...)` in `__main__`
5656
```python
5757
with SyncCrazyflie(URI, cf=Crazyflie(rw_cache='./cache')) as scf:
58-
# Arm the Crazyflie
59-
scf.cf.platform.send_arming_request(True)
60-
time.sleep(1.0)
6158

6259
scf.cf.param.add_update_callback(group="deck", name="bcFlow2",
6360
cb=param_deck_flow)
@@ -123,9 +120,6 @@ if __name__ == '__main__':
123120
cflib.crtp.init_drivers()
124121

125122
with SyncCrazyflie(URI, cf=Crazyflie(rw_cache='./cache')) as scf:
126-
# Arm the Crazyflie
127-
scf.cf.platform.send_arming_request(True)
128-
time.sleep(1.0)
129123

130124
scf.cf.param.add_update_callback(group='deck', name='bcFlow2',
131125
cb=param_deck_flow)
@@ -139,14 +133,15 @@ So now we are going to start up the SyncCrazyflie and start a function in the `_
139133

140134
```python
141135
with SyncCrazyflie(URI, cf=Crazyflie(rw_cache='./cache')) as scf:
142-
# Arm the Crazyflie
143-
scf.cf.platform.send_arming_request(True)
144-
time.sleep(1.0)
145136

146137
if not deck_attached_event.wait(timeout=5):
147138
print('No flow deck detected!')
148139
sys.exit(1)
149140

141+
# Arm the Crazyflie
142+
scf.cf.platform.send_arming_request(True)
143+
time.sleep(1.0)
144+
150145
take_off_simple(scf)
151146
```
152147
See that we are now using `deck_attached_event.wait()`? If this returns false, the function will not be called and the crazyflie will not take off.
@@ -225,9 +220,6 @@ if __name__ == '__main__':
225220
cflib.crtp.init_drivers()
226221

227222
with SyncCrazyflie(URI, cf=Crazyflie(rw_cache='./cache')) as scf:
228-
# Arm the Crazyflie
229-
scf.cf.platform.send_arming_request(True)
230-
time.sleep(1.0)
231223

232224
scf.cf.param.add_update_callback(group='deck', name='bcFlow2',
233225
cb=param_deck_flow)
@@ -237,6 +229,10 @@ if __name__ == '__main__':
237229
print('No flow deck detected!')
238230
sys.exit(1)
239231

232+
# Arm the Crazyflie
233+
scf.cf.platform.send_arming_request(True)
234+
time.sleep(1.0)
235+
240236
take_off_simple(scf)
241237

242238
```
@@ -317,9 +313,6 @@ if __name__ == '__main__':
317313
cflib.crtp.init_drivers()
318314

319315
with SyncCrazyflie(URI, cf=Crazyflie(rw_cache='./cache')) as scf:
320-
# Arm the Crazyflie
321-
scf.cf.platform.send_arming_request(True)
322-
time.sleep(1.0)
323316

324317
scf.cf.param.add_update_callback(group='deck', name='bcFlow2',
325318
cb=param_deck_flow)
@@ -329,6 +322,10 @@ if __name__ == '__main__':
329322
print('No flow deck detected!')
330323
sys.exit(1)
331324

325+
# Arm the Crazyflie
326+
scf.cf.platform.send_arming_request(True)
327+
time.sleep(1.0)
328+
332329
move_linear_simple(scf)
333330
```
334331

@@ -423,9 +420,6 @@ if __name__ == '__main__':
423420
cflib.crtp.init_drivers()
424421

425422
with SyncCrazyflie(URI, cf=Crazyflie(rw_cache='./cache')) as scf:
426-
# Arm the Crazyflie
427-
scf.cf.platform.send_arming_request(True)
428-
time.sleep(1.0)
429423

430424
scf.cf.param.add_update_callback(group='deck', name='bcFlow2',
431425
cb=param_deck_flow)
@@ -441,6 +435,10 @@ if __name__ == '__main__':
441435
print('No flow deck detected!')
442436
sys.exit(1)
443437

438+
# Arm the Crazyflie
439+
scf.cf.platform.send_arming_request(True)
440+
time.sleep(1.0)
441+
444442
logconf.start()
445443

446444
move_linear_simple(scf)
@@ -539,9 +537,6 @@ if __name__ == '__main__':
539537
cflib.crtp.init_drivers()
540538

541539
with SyncCrazyflie(URI, cf=Crazyflie(rw_cache='./cache')) as scf:
542-
# Arm the Crazyflie
543-
scf.cf.platform.send_arming_request(True)
544-
time.sleep(1.0)
545540

546541
scf.cf.param.add_update_callback(group='deck', name='bcFlow2',
547542
cb=param_deck_flow)
@@ -557,6 +552,10 @@ if __name__ == '__main__':
557552
print('No flow deck detected!')
558553
sys.exit(1)
559554

555+
# Arm the Crazyflie
556+
scf.cf.platform.send_arming_request(True)
557+
time.sleep(1.0)
558+
560559
logconf.start()
561560
move_box_limit(scf)
562561
logconf.stop()
@@ -669,9 +668,6 @@ if __name__ == '__main__':
669668
cflib.crtp.init_drivers()
670669

671670
with SyncCrazyflie(URI, cf=Crazyflie(rw_cache='./cache')) as scf:
672-
# Arm the Crazyflie
673-
scf.cf.platform.send_arming_request(True)
674-
time.sleep(1.0)
675671

676672
scf.cf.param.add_update_callback(group='deck', name='bcFlow2',
677673
cb=param_deck_flow)
@@ -687,6 +683,10 @@ if __name__ == '__main__':
687683
print('No flow deck detected!')
688684
sys.exit(1)
689685

686+
# Arm the Crazyflie
687+
scf.cf.platform.send_arming_request(True)
688+
time.sleep(1.0)
689+
690690
logconf.start()
691691
move_box_limit(scf)
692692
logconf.stop()
@@ -697,4 +697,4 @@ You're done! The full code of this tutorial can be found in the example/step-by-
697697

698698
## What is next ?
699699

700-
Now you are able to send velocity commands to the Crazyflie and react upon logging and parameters variables, so one step closer to writing your own application with the Crazyflie python library! Check out the motion_commander_demo.py in the example folder of the cflib if you would like to see what the commander can do.
700+
Now you are able to send velocity commands to the Crazyflie and react upon logging and parameters variables, so one step closer to writing your own application with the Crazyflie python library! Check out the [motion_commander_demo.py](https://github.com/bitcraze/crazyflie-lib-python/blob/master/examples/step-by-step/sbs_motion_commander.py) in the example folder of the cflib if you would like to see what the commander can do.

examples/step-by-step/sbs_motion_commander.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ def param_deck_flow(_, value_str):
125125
print('No flow deck detected!')
126126
sys.exit(1)
127127

128+
# Arm the Crazyflie
129+
scf.cf.platform.send_arming_request(True)
130+
time.sleep(1.0)
131+
128132
logconf.start()
129133

130134
take_off_simple(scf)

0 commit comments

Comments
 (0)