Page 1 of 1

Control Commands and Logging in the same python script

Posted: Tue May 01, 2018 1:07 am
by RSOCAS
Dear all,
I have been using the examples of https://github.com/bitcraze/crazyflie-l ... r/examples. In my project I can send commands to the CF2 for exmaple modifying the script ramp.py. On the other hand, with the script basiclog.py I can read pediodically the log of the copter. My problem now is that I do not know how I can read the sensor information by logging function and at the same time send commands to the copter in the same script. I need this functionality to implement a controller like PID or others in a python script to control the copter.

Somebody can help me to this issue

Best regards,
Rafael Socas

Re: Control Commands and Logging in the same python script

Posted: Wed May 02, 2018 8:15 am
by arnaud
You can setup log block callbacks and control the Crazyflie in a loop, the callbacks will be called when a log packet arrives. An example of that can be found in the autonomous sequence example, if you uncomment the start_position_printing line a log block is created and started, then the crazyflie is controlled and logs are received at the same time: https://github.com/bitcraze/crazyflie-l ... ce.py#L151

If you only need one log block, another solution is to use the synchronous API. The multiranger_push.py example controls the Crazyflie velocity using the distances logged from the multiranger: https://github.com/bitcraze/crazyflie-l ... er_push.py.

Re: Control Commands and Logging in the same python script

Posted: Wed May 02, 2018 11:39 am
by RSOCAS
Thank you so much,
you are very kind. This information is very useful for my project.

Best regards,
Rafael Socas