Crazyflie Battery Logging
Crazyflie Battery Logging
I'm new to Crazyflie, just starting to learn how to develop for it. I've read up on logging on the API wiki page, but it's still fuzzy to me. Specifically, I'm trying to get print outs of the battery level at specific time intervals. Any ideas?
Re: Crazyflie Battery Logging
This you can actually already do in the cfclient. Connect to the Crazyflie and open the plotter tab. There should be one log block for the battery already. You can also log this to a file if you want by opening the "Log blocks" tab and check the write to file for the battery log block.
Re: Crazyflie Battery Logging
Thanks for the tip. Only problem is I can't connect the Crazyflie to cfclient when I am running my code. I need to be able the read the battery voltage independently so I can input that data into my code in real time while operating the Crazyflie.
Currently I am combing through the source code to find how cfclient reads the voltage and writes it to a file.
Currently I am combing through the source code to find how cfclient reads the voltage and writes it to a file.
Re: Crazyflie Battery Logging
I found that there's a file named logdatawriter.py in cfclient\cfclient\utils which is how cfclient is able to write the battery data to a file. Now I am trying to replicate what logdatawriter.py does, but I want to do it outside of cfclient. Any help would be appreciated.
Re: Crazyflie Battery Logging
Just an update for people who find this post in the future: I wrote a program to log the data. I am able to log the accelerometer, stabilizer, gyroscope, barometer, and battery voltage directly to my command prompt.
Last edited by stshah3 on Tue Jul 08, 2014 6:27 pm, edited 1 time in total.
Re: Crazyflie Battery Logging
Great, I was just about to send this to Marcus to get some expertise into this. Could you share a link to your repo or the code for others to look at?
Re: Crazyflie Battery Logging
I used most of the connectSetupFinished function written by eldraco2000 on Bitbucket (link: https://bitbucket.org/eldraco2000/crazy ... ?at=master) for the meat of my code. The code didn't work as it was. I isolated the issue to the __init__ function, which I rewrote because I was having issues connecting to the Crazyflie. Then I added gyroscope and battery voltage, which is straightforward if you know the names of the variables. The names can be found in the Log Blocks tab of the Crazyflie PC client.
I am a part of a research group at a university. We will be posting all of our code once our project is finished, but not until then, sorry. Hopefully I made the instructions clear enough to follow.
On a separate note, what are the default units for instruments on the Crazyflie? The PC client makes the units for the battery voltage clear but nothing else.
I am a part of a research group at a university. We will be posting all of our code once our project is finished, but not until then, sorry. Hopefully I made the instructions clear enough to follow.
On a separate note, what are the default units for instruments on the Crazyflie? The PC client makes the units for the battery voltage clear but nothing else.
Re: Crazyflie Battery Logging
Thanks for sharing and I would love to hear more about you university project.
Well the units might not always be clear and sometimes I think it is best to look in the source code to figure it out.
Pitch, Roll: deg
Yawrate: deg/s
Thrust: uint16
M1,M2,M3,M4: uint16
...
Well the units might not always be clear and sometimes I think it is best to look in the source code to figure it out.
Pitch, Roll: deg
Yawrate: deg/s
Thrust: uint16
M1,M2,M3,M4: uint16
...
Re: Crazyflie Battery Logging
@OP I'm trying to do something very similar. Would you mind posting your final code?
Thanks!
Thanks!