Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 25 additions & 25 deletions docs/user-guides/sbs_motion_commander.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ Since this tutorial won't be a table top tutorial like last time, but an actual
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__`
```python
with SyncCrazyflie(URI, cf=Crazyflie(rw_cache='./cache')) as scf:
# Arm the Crazyflie
scf.cf.platform.send_arming_request(True)
time.sleep(1.0)

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

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

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

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

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

# Arm the Crazyflie
scf.cf.platform.send_arming_request(True)
time.sleep(1.0)

take_off_simple(scf)
```
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.
Expand Down Expand Up @@ -225,9 +220,6 @@ if __name__ == '__main__':
cflib.crtp.init_drivers()

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

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

# Arm the Crazyflie
scf.cf.platform.send_arming_request(True)
time.sleep(1.0)

take_off_simple(scf)

```
Expand Down Expand Up @@ -317,9 +313,6 @@ if __name__ == '__main__':
cflib.crtp.init_drivers()

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

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

# Arm the Crazyflie
scf.cf.platform.send_arming_request(True)
time.sleep(1.0)

move_linear_simple(scf)
```

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

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

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

# Arm the Crazyflie
scf.cf.platform.send_arming_request(True)
time.sleep(1.0)

logconf.start()

move_linear_simple(scf)
Expand Down Expand Up @@ -539,9 +537,6 @@ if __name__ == '__main__':
cflib.crtp.init_drivers()

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

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

# Arm the Crazyflie
scf.cf.platform.send_arming_request(True)
time.sleep(1.0)

logconf.start()
move_box_limit(scf)
logconf.stop()
Expand Down Expand Up @@ -669,9 +668,6 @@ if __name__ == '__main__':
cflib.crtp.init_drivers()

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

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

# Arm the Crazyflie
scf.cf.platform.send_arming_request(True)
time.sleep(1.0)

logconf.start()
move_box_limit(scf)
logconf.stop()
Expand All @@ -697,4 +697,4 @@ You're done! The full code of this tutorial can be found in the example/step-by-

## What is next ?

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.
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.
4 changes: 4 additions & 0 deletions examples/step-by-step/sbs_motion_commander.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ def param_deck_flow(_, value_str):
print('No flow deck detected!')
sys.exit(1)

# Arm the Crazyflie
scf.cf.platform.send_arming_request(True)
time.sleep(1.0)

logconf.start()

take_off_simple(scf)
Expand Down