Retrieving data?

Firmware/software/electronics/mechanics
Post Reply
Zandion
Beginner
Posts: 7
Joined: Thu Apr 09, 2015 5:09 am

Retrieving data?

Post by Zandion »

Hi, I'm a beginner at using the crazyflie and I've some knowledge on programming python.
I want to collect and use the data from crazyflie data via python and then use that data to be stored for later use.
However I've yet to come across any guides or demos for the source code.

Is there already one available for use? Any replies would be appreciated.
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: Retrieving data?

Post by arnaud »

Hi,

To get data from the copter you can use the log subsystem: http://wiki.bitcraze.se/doc:crazyflie:dev:arch:logparam

The python client is already capable of recording CSV files out of log value. It is located in the "Log Block" tab (view/tabs/log block). If you activate writing to files you can find the resulting log files by opening the config folder (menu settings/open config folder).

If you want to write yourself a logging program, the python client project have a "basiclog" example that implements data logging: https://github.com/bitcraze/crazyflie-c ... asiclog.py
Zandion
Beginner
Posts: 7
Joined: Thu Apr 09, 2015 5:09 am

Re: Retrieving data?

Post by Zandion »

Pardon my inability but I found it very hard to understand and was overwhelmed by what was going on in the wiki. I've read up the Python API as well and it did not help. At the same time I've also tested out the other examples that came along in the python-crazyflie-developer folder but none of them seem to work or it did nothing.

I intend to use only Python to obtain information from the Crazyflie and to update and print out the new value of the yaw/pitch/roll when it changes.
I'm not sure which goes where but I've tried out using and experimented on the basiclog to get it to print out data to the Python shell itself by adding in the LOG_GROUP and LogConfig but that did not work out at all.

I'm really clueless about how to get started or understand how each functions are interlinked to programming Python with CrazyFlie and wanted to do something simple before flying it. Is there a tutorial or guide that I could take reference from?

With regards.
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: Retrieving data?

Post by arnaud »

For that you do not need to change the firmware, all logging variable for pich/roll/yaw are already setup.

The basiclog.py example is doing what you are looking for. For example I ran it in the virtual machine:

Code: Select all

bitcraze@bitcraze-vm:~$ cd projects/crazyflie-clients-python/examples
bitcraze@bitcraze-vm:~/projects/crazyflie-clients-python/examples$ ls
basiclog.py  basicparam.py  ramp.py  scan.py
bitcraze@bitcraze-vm:~/projects/crazyflie-clients-python/examples$ python basiclog.py 
Scanning interfaces for Crazyflies...
Crazyflies found:
radio://0/2/2M
Connecting to radio://0/2/2M
Connected to radio://0/2/2M
[82445][Stabilizer]: {'stabilizer.roll': 0.11288703978061676, 'stabilizer.yaw': 2.1254003047943115, 'stabilizer.pitch': -0.05103013664484024}
[82455][Stabilizer]: {'stabilizer.roll': 0.112091563642025, 'stabilizer.yaw': 2.125885486602783, 'stabilizer.pitch': -0.05120216682553291}
[82465][Stabilizer]: {'stabilizer.roll': 0.1115361824631691, 'stabilizer.yaw': 2.1261250972747803, 'stabilizer.pitch': -0.051947470754384995}
[82475][Stabilizer]: {'stabilizer.roll': 0.11172128468751907, 'stabilizer.yaw': 2.126854419708252, 'stabilizer.pitch': -0.052360739558935165}
[82485][Stabilizer]: {'stabilizer.roll': 0.11256100982427597, 'stabilizer.yaw': 2.1273365020751953, 'stabilizer.pitch': -0.051909659057855606}
[82495][Stabilizer]: {'stabilizer.roll': 0.11289502680301666, 'stabilizer.yaw': 2.1278185844421387, 'stabilizer.pitch': -0.05088762566447258}
[82505][Stabilizer]: {'stabilizer.roll': 0.112638920545578, 'stabilizer.yaw': 2.1275689601898193, 'stabilizer.pitch': -0.05086183175444603}
[82515][Stabilizer]: {'stabilizer.roll': 0.11323916912078857, 'stabilizer.yaw': 2.1282975673675537, 'stabilizer.pitch': -0.05076850205659866}
[82525][Stabilizer]: {'stabilizer.roll': 0.11343179643154144, 'stabilizer.yaw': 2.129758596420288, 'stabilizer.pitch': -0.05166564881801605}
[82535][Stabilizer]: {'stabilizer.roll': 0.11316860467195511, 'stabilizer.yaw': 2.1309754848480225, 'stabilizer.pitch': -0.05150089040398598}
[82545][Stabilizer]: {'stabilizer.roll': 0.1141391471028328, 'stabilizer.yaw': 2.1319468021392822, 'stabilizer.pitch': -0.051240503787994385}
[82555][Stabilizer]: {'stabilizer.roll': 0.11336198449134827, 'stabilizer.yaw': 2.1324305534362793, 'stabilizer.pitch': -0.050698209553956985}
[82565][Stabilizer]: {'stabilizer.roll': 0.11397259682416916, 'stabilizer.yaw': 2.132669448852539, 'stabilizer.pitch': -0.050641126930713654}
[82575][Stabilizer]: {'stabilizer.roll': 0.11319596320390701, 'stabilizer.yaw': 2.1326663494110107, 'stabilizer.pitch': -0.05094360187649727}
[82585][Stabilizer]: {'stabilizer.roll': 0.11210063099861145, 'stabilizer.yaw': 2.132418394088745, 'stabilizer.pitch': -0.05184093117713928}
So to get started you can run basiclog and then understand how it works.

We made a series of video tutorial a while ago the first one is about adding log/param to the firmware: https://www.youtube.com/watch?v=chWrNh73YBw
And the second if about interfacing log and param from python: https://www.youtube.com/watch?v=cutgIMfHwyQ
Zandion
Beginner
Posts: 7
Joined: Thu Apr 09, 2015 5:09 am

Re: Retrieving data?

Post by Zandion »

I see. I had attempted to run the basiclog previously but it yielded different results.

I've taken a look through the forums and it seems that my firmware are outdated and is having the same error as another person who posted recently:
http://forum.bitcraze.se/viewtopic.php?f=5&t=1409

Which firmware is referred to that needs to be updated?
Does that mean I have to update the quad-copter or something else?
I'm very sorry for my lack of knowledge or understanding.
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: Retrieving data?

Post by arnaud »

You can update to the latest firmware: Crazyflie2: https://github.com/bitcraze/crazyflie-f ... /2014.12.0 Crazyflie1: https://github.com/bitcraze/crazyflie-f ... tag/2015.1
The update is done using the Crazyflie client: https://wiki.bitcraze.io/doc:crazyflie: ... bootloader
Zandion
Beginner
Posts: 7
Joined: Thu Apr 09, 2015 5:09 am

Re: Retrieving data?

Post by Zandion »

Thanks a lot arnaud, everything is working great now that my CrazyFlie is updated!

I wouldn't have known what to do without you, thanks again!
Post Reply