Page 1 of 1

Adding/deleting a logConf results in double callbacks, bug?

Posted: Wed Feb 19, 2014 12:11 am
by omwdunkley
Hey guys, not sure if this is a bug or I missed something, but:

Im playing around with logging etc (designed a new tab to easier configure what should be a logged and at which frequency, etc) and somehow when I add/delete a logConfig the callbacks are called twice.
Some example output from the console with logging enabled:

After starting to log something:

Code: Select all

INFO:cflib.crazyflie.log:Have successfully started logging for id=1
INFO:cflib.crazyflie.log:Have successfully started logging for id=1
Requested log delete

Code: Select all

INFO:cflib.crazyflie.log:Have successfully deleted id=1
INFO:cflib.crazyflie.log:Have successfully deleted id=1
I thought it must have made a mistake somewhere in my code, but running the cfclient resulted in the following too (small out take):

Code: Select all

NFO:cflib.crazyflie:Callback->Connection initialized[radio://0/1/2M]
INFO:cflib.crazyflie:We are connected[radio://0/1/2M], request connection setup
INFO:cflib.crazyflie:Callback->Connected to [radio://0/1/2M]
INFO:cflib.crazyflie.toc:TOC for port [5] found in cache
INFO:cflib.crazyflie:Log TOC finished updating
INFO:cflib.crazyflie.toc:TOC for port [2] found in cache
INFO:cflib.crazyflie:Param TOC finished updating
INFO:cflib.crazyflie:Callback->Connection setup finished [radio://0/1/2M]
INFO:cfclient.utils.logconfigreader:Parsing [stabilizer.json]
INFO:cflib.crazyflie.log:Have successfully started logging for id=1
INFO:cflib.crazyflie.log:Have successfully started logging for id=3
INFO:cflib.crazyflie.log:Have successfully started logging for id=4
INFO:cflib.crazyflie.log:Have successfully started logging for id=5
INFO:cflib.crazyflie.log:Have successfully started logging for id=1
INFO:cflib.crazyflie.log:Have successfully started logging for id=3
INFO:cflib.crazyflie.log:Have successfully started logging for id=4
INFO:cflib.crazyflie.log:Have successfully started logging for id=5
So once again, it starts logging for each ID twice!
Not sure where to fix this. Any ideas?


This is what I was working on:
Image
It saves configurations between sessions, monitors/sets the frequencies, and shows error messages in case something fails. When its finished one could wrap it in a tab and submit it to the repo. Its currently implemented as a QTreeWidget that takes a Crazyflie as a parameter. However In my application its the only source of logging (wanted to have that centralized) so it might need some work if being added to the cfclient (it doesnt scan for existing logs configs, but that should be easy enough to fix)
Cheers,
-Oliver

[using stock firmware / client]

Re: Adding/deleting a logConf results in double callbacks, b

Posted: Thu Feb 20, 2014 10:35 am
by marcus
Hi Oliver,

Nice additions! The scanning for configs should be easy to fix. Currently it's just callbacks that will be called for every new config that is added. The code that scans for files will wait until you are connected and then add all the blocks to the logging. The block_added_cb in Log will be called for each and this way the different parts of the application is notified about new configurations.

Code: Select all

crazyflie.log.block_added_cb.add_callback()
For the double printout it's due to re-sends and it shouldn't be a problem. With the fixes in 2014.01 the re-sending should be fixed making adding/deleting logging more stable. But this also means that there's more re-sends than before since some of them got lost. Maybe we will have to look into the timeout, it might be set too tight.

/Marcus

Re: Adding/deleting a logConf results in double callbacks, b

Posted: Thu Feb 20, 2014 9:55 pm
by omwdunkley
Thanks for your response Marcus!
marcus wrote: The scanning for configs should be easy to fix. Currently it's just callbacks that will be called for every new config that is added. The code that scans for files will wait until you are connected and then add all the blocks to the logging. The block_added_cb in Log will be called for each and this way the different parts of the application is notified about new configurations.

Code: Select all

crazyflie.log.block_added_cb.add_callback()
/Marcus
Im not exactly sure what you meant there - maybe we misunderstood eachother ;) I am using the latest code from bitbucket for both the client and the firmware. I implemented that widget from scratch according to the docs online. It works robustly as it strictly follows the "finite state machine (FSM)" (as far as I could infer one from the docs/code). It would be awesome to actually put up an accurate diagram on the wiki.

The FSM I infered was obviously wrong though, due to the multiple callback calls I did not expect.
But this also means that there's more re-sends than before since some of them got lost. Maybe we will have to look into the timeout, it might be set too tight.
Is this behaviour documented somewhere; or could you please elaborate a little more on it? Generally its not a problem if one knows whats going on - for now I just ignore the second callback with the same ID with some additional logic. But something feels fishy - hence the forum post ;)

Thanks!

Re: Adding/deleting a logConf results in double callbacks, b

Posted: Sat Oct 11, 2014 6:40 am
by Alice
I also have the same problem.
The Python-client works perfectly fine but when I test the "simple" example of libcflie (I added printing accX) the values stop changing after 0.5s or so and 1-2s after that the motors stop.
I tried different channels and data rates but it did not help, so a packet collision (with WiFi) seems unlikely.
I am in contact with the developer of libcflie (fairlight1337 on the forum) but so far no solution has been found.
He suggested to flash the firmware to the Crazyflie again. It didn't help in my case but maybe you want to try it?