diff --git a/docs/user-guides/sbs_connect_log_param.md b/docs/user-guides/sbs_connect_log_param.md index a708744bc..71869feb2 100644 --- a/docs/user-guides/sbs_connect_log_param.md +++ b/docs/user-guides/sbs_connect_log_param.md @@ -205,7 +205,7 @@ Notice that now you will need to include the SyncCrazyflie instance (`scf`) and Now the logging instances will be inserted by adding the following after you configured the lg_stab: ```python - with SyncLogger(scf, lg_stab) as logger: + with SyncLogger(scf, logconf) as logger: for log_entry in logger: @@ -221,7 +221,7 @@ Now the logging instances will be inserted by adding the following after you con ### Test the script: -First change the `simple_connect()` in _main_ in `simple_log(scf, lg_stab)`. Now run the script (`python3 connect_log_param.py`) like before. +First change the `simple_connect()` in _main_ to `simple_log(scf, lg_stab)`. Now run the script (`python3 connect_log_param.py`) like before. If everything is fine it should continuously print the logging variables, like this: @@ -296,7 +296,7 @@ def simple_log_async(scf, logconf): cf.log.add_config(logconf) ``` -Here you add the logging configuration to to the logging framework of the Crazyflie. It will check if the log configuration is part of the TOC, which is a list of all the logging variables defined in the Crazyflie. You can test this out by changing one of the `lg_stab` variables to a completely bogus name like `'not.real'`. In this case you would receive the following message: +Here you add the logging configuration to the logging framework of the Crazyflie. It will check if the log configuration is part of the TOC, which is a list of all the logging variables defined in the Crazyflie. You can test this out by changing one of the `lg_stab` variables to a completely bogus name like `'not.real'`. In this case you would receive the following message: `KeyError: 'Variable not.real not in TOC'` @@ -308,7 +308,7 @@ def log_stab_callback(timestamp, data, logconf): print('[%d][%s]: %s' % (timestamp, logconf.name, data)) ``` -This callback will be called once the log variables have received it and prints the contents. The callback function added to the logging framework by adding it to the log config in `simple_log_async(..)`: +This callback will be called once the log variables have received it and prints the contents. The callback function is added to the logging framework by adding it to the log config in `simple_log_async(..)`: ```python logconf.data_received_cb.add_callback(log_stab_callback) @@ -317,11 +317,13 @@ This callback will be called once the log variables have received it and prints Then the log configuration would need to be started manually, and then stopped after a few seconds: ```python - logconf.start() + lg_stab.start() time.sleep(5) - logconf.stop() + lg_stab.stop() ``` +Instead of ```time.sleep(5)```, you have the possibility to interact with the Crazyflie in other ways, meaning you now have an asynchronous logging setup. + ## Run the script Make sure to replace the `simple_log(...)` to `simple_log_async(...)` in the `__main__` function. Run the script with `python3 connect_log_param.py` in a terminal and you should see several messages of the following: @@ -354,9 +356,6 @@ def simple_log_async(scf, logconf): cf = scf.cf cf.log.add_config(logconf) logconf.data_received_cb.add_callback(log_stab_callback) - logconf.start() - time.sleep(5) - logconf.stop() (...) @@ -372,6 +371,10 @@ if __name__ == '__main__': with SyncCrazyflie(uri, cf=Crazyflie(rw_cache='./cache')) as scf: simple_log_async(scf, lg_stab) + + lg_stab.start() + time.sleep(5) # Your possibility to interact with the Crazyflie + lg_stab.stop() ``` ## Step 3. Parameters diff --git a/docs/user-guides/sbs_motion_commander.md b/docs/user-guides/sbs_motion_commander.md index 303f49536..2d560f738 100644 --- a/docs/user-guides/sbs_motion_commander.md +++ b/docs/user-guides/sbs_motion_commander.md @@ -15,7 +15,7 @@ We will assume that you already know this before you start with the tutorial: ## Get the script started -Since you should have installed cflib in the previous step by step tutorial, you are all ready to got now. Open up an new python script called `motion_flying.py`. First you will start by adding the following import to the script: +Since you should have installed cflib in the previous step by step tutorial, you are all ready to go now. Open up an new python script called `motion_flying.py`. First you will start by adding the following import to the script: ```python import logging @@ -30,11 +30,9 @@ from cflib.crazyflie.syncCrazyflie import SyncCrazyflie from cflib.positioning.motion_commander import MotionCommander from cflib.utils import uri_helper - URI = uri_helper.uri_from_env(default='radio://0/80/2M/E7E7E7E7E7') -DEFAULT_HEIGHT = 0.5 -BOX_LIMIT = 0.5 +logging.basicConfig(level=logging.ERROR) if __name__ == '__main__': @@ -46,7 +44,7 @@ This probably all looks pretty familiar, except for one thing line, namely: `from cflib.positioning.motion_commander import MotionCommander` -This imports the motion commander, which is pretty much a wrapper around the position setpoint frame work of the crazyflie. You probably have unknowingly experienced this a when trying out the assist modes in this [tutorial with the flow deck in the cfclient](https://www.bitcraze.io/documentation/tutorials/getting-started-with-flow-deck/) +This imports the motion commander, which is pretty much a wrapper around the position setpoint frame work of the crazyflie. You probably have unknowingly experienced this when trying out the assist modes in this [tutorial with the flow deck in the cfclient](https://www.bitcraze.io/documentation/tutorials/getting-started-with-flow-deck/) ## Step 1: Security before flying @@ -150,9 +148,8 @@ Now make the function `take_off_simple(..)` above `__main__`, which will contain ```python def take_off_simple(scf): - with MotionCommander(scf, default_height=DEFAULT_HEIGHT) as mc: + with MotionCommander(scf) as mc: time.sleep(3) - mc.stop() ``` If you run the python script, you will see the crazyflie connect and immediately take off. After flying for 3 seconds it will land again. @@ -161,14 +158,14 @@ The reason for the crazyflie to immediately take off, is that the motion command ### Changing the height -Currently the motion commander had 0.3 meters height as default but this can of course be changed. +Currently the motion commander has 0.3 meters height as default but this can of course be changed. -Change the following line in `take_off_simple(...)`: +Change the following lines in `take_off_simple(...)`: ```python with MotionCommander(scf) as mc: + time.sleep(3) mc.up(0.3) time.sleep(3) - mc.stop() ``` Run the script again. The crazyflie will first take off to 0.3 meters and then goes up for another 0.3 meters. @@ -210,7 +207,6 @@ logging.basicConfig(level=logging.ERROR) def take_off_simple(scf): with MotionCommander(scf, default_height=DEFAULT_HEIGHT) as mc: time.sleep(3) - mc.stop() def param_deck_flow(name, value_str):