Crazyflie Battery Logging

Firmware/software/electronics/mechanics
Post Reply
stshah3
Beginner
Posts: 8
Joined: Sat Jun 07, 2014 9:59 pm

Crazyflie Battery Logging

Post by stshah3 »

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?
tobias
Bitcraze
Posts: 2339
Joined: Mon Jan 28, 2013 7:17 pm
Location: Sweden

Re: Crazyflie Battery Logging

Post by tobias »

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.
stshah3
Beginner
Posts: 8
Joined: Sat Jun 07, 2014 9:59 pm

Re: Crazyflie Battery Logging

Post by stshah3 »

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.
stshah3
Beginner
Posts: 8
Joined: Sat Jun 07, 2014 9:59 pm

Re: Crazyflie Battery Logging

Post by stshah3 »

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.
stshah3
Beginner
Posts: 8
Joined: Sat Jun 07, 2014 9:59 pm

Re: Crazyflie Battery Logging

Post by stshah3 »

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.
tobias
Bitcraze
Posts: 2339
Joined: Mon Jan 28, 2013 7:17 pm
Location: Sweden

Re: Crazyflie Battery Logging

Post by tobias »

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?
stshah3
Beginner
Posts: 8
Joined: Sat Jun 07, 2014 9:59 pm

Re: Crazyflie Battery Logging

Post by stshah3 »

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.
tobias
Bitcraze
Posts: 2339
Joined: Mon Jan 28, 2013 7:17 pm
Location: Sweden

Re: Crazyflie Battery Logging

Post by tobias »

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
...
eddiebob
Beginner
Posts: 2
Joined: Mon Jul 28, 2014 5:20 pm

Re: Crazyflie Battery Logging

Post by eddiebob »

@OP I'm trying to do something very similar. Would you mind posting your final code?
Thanks!
Post Reply