Crazyflie Python Demos

Firmware/software/electronics/mechanics
Post Reply
jamisnemo
Beginner
Posts: 9
Joined: Fri May 10, 2013 10:23 pm

Crazyflie Python Demos

Post by jamisnemo »

I made a GitHub repo for demos of the crazyflie python libraries. It's probably not needed but maybe it will be useful to someone down the road.
https://github.com/JamesHagerman/Crazyflie_Python_Demos

The only script in there right now is a fixed-up version of the sample code at the bottom of this page:
http://wiki.bitcraze.se/projects:crazyf ... de_example

If nothing else, the "update" thread down at the bottom shouldn't be recursive.

I also added some input checking to make it not crash the app if you enter bad values along with code to detect "exit", "quit", "e", and "q" inputs to try and close everything down cleanly.

There seem to be a few bugs in the libraries themselves but since my version of libusb is also acting up I'm not quite sure what's going on.

Also, the only way I can get the script to run is to put the script into the lib/ directory of the client repo and run it from there. I don't know how to get the imports to work correctly otherwise.

So, I hope this helps some people out! If someone wants to do a pull request to add other scripts, I'll be glad to add em!

p.s. My quad starts lifting off with a lift value of 25000-30000... HOLD ON TO THE THING if you put values in higher then 20000! It WILL launch itself into a wall otherwise...
danielsamuels
Beginner
Posts: 14
Joined: Sun May 05, 2013 3:21 pm

Re: Crazyflie Python Demos

Post by danielsamuels »

Hello,

I'm the original author of the code example. The main point of it was to be a very simplistic starting point for anyone looking to get started with Python programming for the Crazyflie, so it's by no means fully-featured or full of error checking.

The update thread being recursive was to make sure the 2 second cut-out implemented in the firmware wasn't triggered, by putting the commander call into its own thread, it means that with the right scripting, you can modify the value of self.thrust (or any of the other values) and they'll be sent to the Crazyflie within 10ms or so, this should allow for fairly precise operation.

But, your script is a nice, natural, expected evolution of the starter code and it's nice to see other people using Python with the Crazyflie. For your import issues, it's just a case of the Crazyflie libraries not being on PATH. You can check what's currently on your path with

Code: Select all

>>> import sys
>>> sys.path
Typically you'll have a site-packages folder, or something similar, where you need to put your Crazyflie modules. Alternatively you should be able to run

Code: Select all

./setup.py install
in the base of the libraries folder and it should install by itself (assuming your Python install is set up properly)
jamisnemo
Beginner
Posts: 9
Joined: Fri May 10, 2013 10:23 pm

Re: Crazyflie Python Demos

Post by jamisnemo »

danielsamuels,

Thanks for writing that code example! It's helped a lot!

I kinda figured out the path stuff last night but thank you so much for the directions on how it SHOULD be done. I was kinda wrong in the way I did it. I'll try the setup.py too.

The next step is to try getting gyro readings out of the libraries and make an example of that for the repo. With those I think there should be enough data to start putting together a quick "Auto-fly" demo.

That being said, I haven't done all that much research on what other people have done in regards to hovering with the altimeter on the 10dof version or anything else of the sort (OpenCV motion tracking, path following, etc.)

Thanks for commenting! I was wondering who wrote it!
Post Reply