diff --git a/docs/user-guides/sbs_motion_commander.md b/docs/user-guides/sbs_motion_commander.md index 883a7b6d8..e17100d2c 100644 --- a/docs/user-guides/sbs_motion_commander.md +++ b/docs/user-guides/sbs_motion_commander.md @@ -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) @@ -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) @@ -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. @@ -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) @@ -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) ``` @@ -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) @@ -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) ``` @@ -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) @@ -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) @@ -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) @@ -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() @@ -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) @@ -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() @@ -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. diff --git a/examples/step-by-step/sbs_motion_commander.py b/examples/step-by-step/sbs_motion_commander.py index 376d0b0d1..a477455c1 100644 --- a/examples/step-by-step/sbs_motion_commander.py +++ b/examples/step-by-step/sbs_motion_commander.py @@ -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)