First, my intent is not to say the current documentation is bad, or the devs haven't done enough work. There is a ton of good info on the wiki, Bitcraze Github readmes, and random places like https://www.bitcraze.io/getting-started ... velopment/ which don't appear to be part of the wiki. To make development easy on all platforms, using the Bitcraze Virtual Machine is advised, but I ran into issues using this on Windows because Virtualbox had issues with USB drivers.
If I could start over with everything I have learned in the past few months of light work on this for a class examining my own issues as well as other students, I would say for reliable use and light development of the Crazyflie 2.0, one should be running Linux naively on their machine (either alone, or with dual boot, or a persistent boot off a flash drive). This avoids issues with VM USB drivers, a source of major hassle for us. If you just want to fly it around on your computer, with Windows, using the CFClient binaries for Windows should work fine. But if you even think you want to do some dev, or have a more involved experience with this amazing, modular, open-source platform, bite the bullet and install linux, even if you have never used it before. This will attempt to get you up to speed with what I used the last month or so, and took many hours to get there. It is targeted at someone with no Linux or development experience, but wants to use their Crazyflie to its full potential, therefore lowering the barrier to entrance on this amazing platform. Some instruction is written, or pages on the wiki are linked where I would not change anything.
If you do not know what you're doing, this might feel a little spoon fed, but it is my personal belief, that having something running to play with and then learning why that worked, is more motivating than staring at a mountain, and feeling you can't play until you learn how to, and then climb it. While this is a bit more wordy than originally intended, it is actually not that complicated. Skim it, then you can type the commands exactly as shown without even reading the brief explanation and it should work (note that blindly following commands or running scripts, especially with admin privileges is bad practice). Once you've done it once, repeating the following steps takes only a few minutes, if that.
1. Concise setup intro
This assumes you have Linux installed on your machine, assumed to be a 'normal' laptop/desktop x64 processor etc not a raspberry pi (though this might work on that), or running off a persistent install (saves changes, unlike live CD) flash drive. Also assumed is that you have Git installed, which comes on most Linux distros. It is recommended that you read this on the machine you are setting up so you can copy and paste long or detailed commands.
The Crazyflie PC Client is entirely written in Python, which is great as it is easy to read and learn quickly. Python relies heavily on built-in and openly developed 3rd party libraries to run. To install/use the Crazyflie PC client (referred to as CFClient or CFC) on Linux, you will need to download the CFClient and install its dependencies (external Python libraries) inside a virtual environment, so that these do not interfere with other dependencies and make it hard to find the source of a bug. I have started doing this for almost everything as the compartmentalization is so nice.
You will also need to set udev permissions by adding a couple lines to a text file, or creating it if it doesn't exist.
2. Download the CFClient using Git
Open terminal and type these commands. The default current working directory is your home folder. Make a directory for Github stuff, with a good, organized structure for your projects.
Code: Select all
mkdir Github
Code: Select all
cd Github
Code: Select all
mkdir bitcraze
Code: Select all
cd bitcraze
Download the CFClient by cloning the repository with Git
Code: Select all
git clone https://github.com/bitcraze/crazyflie-clients-python.git
You could stop here, downloading the latest version will probably work with the dependencies described next, but just to be sure, reset the local files to the version this was designed for by changing into the cloned repository's folder:
Code: Select all
cd crazyflie-clients-python
and telling git to reset these local files to a past version, identified by the long SHA-1 hash at the end
Code: Select all
git reset --hard b1045f561863fdd60999543dcfa50080fa3ff26d
3. Install Minconda
Use your web browser to download Miniconda here:
https://conda.io/miniconda.html
In a new terminal window, change directory to your 'Downloads'
Code: Select all
cd Downloads
Change permissions using chmod to allow the Miniconda setup execute
Code: Select all
sudo chmod +x Miniconda3-latest-Linux-x86_64.sh
Run the installer:
Code: Select all
./Miniconda3-latest-Linux-x86_64.sh
4. Make a conda virtual environment and install dependencies for CFClient
This should be complicated, but using conda and the configuration file shown the next post, this is done in one line!
First, create the configuration file by pasting the following text verbatim into your favorite text editor (GEdit, nano, emacs, .. or vim ) and saving as crazyflie.yml. You can save it anywhere as long as you know where it is. The default location is probably your home directory. This file is a human-readable instruction file to tell conda what to install in your virtual environment.
Code: Select all
name: crazyflie
channels:
- defaults
dependencies:
- dbus=1.10.10=0
- expat=2.1.0=0
- fontconfig=2.12.1=3
- freetype=2.5.5=2
- glib=2.50.2=1
- gst-plugins-base=1.8.0=0
- gstreamer=1.8.0=0
- icu=54.1=0
- jpeg=9b=0
- libffi=3.2.1=1
- libgcc=5.2.0=0
- libiconv=1.14=0
- libpng=1.6.27=0
- libxcb=1.12=1
- libxml2=2.9.4=0
- openssl=1.0.2k=1
- pcre=8.39=1
- pip=9.0.1=py36_1
- pyqt=5.6.0=py36_2
- python=3.6.1=0
- qt=5.6.2=3
- readline=6.2=2
- setuptools=27.2.0=py36_0
- sip=4.18=py36_0
- sqlite=3.13.0=0
- tk=8.5.18=0
- wheel=0.29.0=py36_0
- xz=5.2.2=1
- zlib=1.2.8=3
- pip:
- appdirs==1.4.0
- "--editable=git+https://github.com/bitcraze/crazyflie-clients-python.git@b1045f561863fdd60999543dcfa50080fa3ff26d#egg=cfclient"
- cflib==0.1.2
- numpy==1.12.1
- pyqtgraph==0.10.0
- pyusb==1.0.0
- pyzmq==16.0.2
prefix: /home/H0stname/miniconda3/envs/crazyflie
Code: Select all
conda env create -f crazyflie.yml
5. Set udev permissions as per the github readme for cflib
https://github.com/bitcraze/crazyflie-l ... ermissions
You'll make some text files and paste rules in them. It's pretty straightforward, but be sure you type the filenames correctly else it won't work and the USB device not being detected/used properly is illusive.
6. Run the CFClient!
cd back to the directory you cloned the CFClient repo to
Code: Select all
cd ~/Github/bitcraze/crazyflie-clients-python
Code: Select all
cd /home/yourUsername/Github/bitcraze/crazyflie-clients-python
Code: Select all
source activate crazyflie
With the venv active, run the CFClient and get flying and developing!
Code: Select all
python bin/cfclient
Code: Select all
source deactivate
7. Discussions
What was done:
You used Git to pull/clone/download the latest version of the CFClient repository, reset the local files back to the version that this guide was made for denoted by that SHA-1 hash, created a conda virtual environment with static dependency versions included by using a file (also containing information linked to that version), activated this virtual environment, and ran the Crazyflie Client inside here. No hunting for specific dependencies or experiencing conflicts with other things installed on your computer because you used Miniconda, which contains nothing but Conda and Python, and all specific dependencies were described by a file.
8. Conclusions
Hope this was of some use, and that over time you learn where these instructions come from.. the importance of Git and version control, how that environment yml file pulls a specific version, more familiarity with Linux, speeding up your workflow with aliases and modifying your environment (both python and Linux itself) to better suit your liking etc. Also what hardware you have to play with and why the Crazyflie costs so much . Note that since you are cloning a specific version of things, it may contain bugs, and devs generally don't like users to use old version since they updated them for a reason. But this version (or commit in Github speak) worked for me, and was stable enough to get going quickly. Maybe this could be modified to contain yml files for major updates, to download and create virtual environments for these major updates in a quick and containable manner.
When you want to use or try the latest version, simply create a new virtual environment with a different name (an empty one, not from a file.. read google creating virtual environments with conda), and follow the setup instructions found on the crazyflie Wiki https://wiki.bitcraze.io/doc:crazyflie:indexor Github repo readmes to install necessary dependencies. You should just have to pull/clone the latest CFClient and run the setup, maybe also needing to install pyqt, easier with conda than apt. You can deactivate this new test virtual environment and active your old crazyflie one if something goes wrong. Or delete them all and simply follow the above procedure to recreate environment 'crazyflie' from a file.
Hopefully you will have learned more by then, and appreciate this very quick (<15 mins) setup for a specific version that can be replicated by lvl 1 noob by simply typing these commands verbatim. Then this lvl 1 noob will find it easier to lvl up in the future by having something to go back to and see the progress in action! Have fun out there, and feel free to post suggestions. Maybe I didn't do this as efficiently as I could have or something like that.