Developer Environment and Client on a Raspberry Pi 3 with Jessie

Firmware/software/electronics/mechanics
PhilipMC
Beginner
Posts: 6
Joined: Wed Mar 30, 2016 6:34 pm
Location: Kent, UK

Developer Environment and Client on a Raspberry Pi 3 with Jessie

Post by PhilipMC »

I have set up the Crazyflie Development System and PC-Client on a Raspberry Pi 3 using the new Jessie operating system, following the Crazyflie VM as a guide.
I can access it both using VNC from my PC and on an attached "Pi Official Touchscreen Display" with a pannable larger virtual desktop.


This is how I set up the Crazyflie components,
I hope someone finds it useful!

To install the PC-Client:
https://github.com/bitcraze/crazyflie-c ... /README.md
Install dependencies

Code: Select all

sudo apt-get update
sudo apt-get install python3 python3-pip python3-pyqt4 python3-zmq 
sudo pip-3.2 install pyusb==1.0.0b2 
pip3 install pyqtgraph 
Install client

Code: Select all

sudo apt-get install git
mkdir crazyflie
cd crazyflie
git clone https://github.com/bitcraze/crazyflie-clients-python.git
cd crazyflie-clients-python
sudo python3 setup.py install
cd ..
Install cflib
https://github.com/bitcraze/crazyflie-lib-python

Code: Select all

cd crazyflie
git clone https://github.com/bitcraze/crazyflie-lib-python.git
cd *lib*
sudo python3 setup.py install
Set udev permissions

Code: Select all

sudo groupadd plugdev
sudo usermod -a -G plugdev pi

Code: Select all

sudo nano /etc/udev/rules.d/99-crazyradio.rules
Insert the following:

Code: Select all

SUBSYSTEM=="usb", ATTRS{idVendor}=="1915", ATTRS{idProduct}=="7777", MODE="0664", GROUP="plugdev"
sudo nano /etc/udev/rules.d/99-crazyflie.rules
SUBSYSTEM=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="5740", MODE="0664", GROUP="plugdev"
[CTRL][X] followed by [Y] [Return] to save and exit

Create Desktop Link (to crazyflie client)
http://www.raspberry-projects.com/pi/pi ... -shortcuts

Code: Select all

sudo nano ~/Desktop/crazyflie.desktop
Insert the following:

Code: Select all

[Desktop Entry]
Name=Crazyflie Client
Comment=Opens the PC Client
Icon=/usr/local/cfclient/icon-256.png
Exec=/usr/local/bin/cfclient
Type=Application
Encoding=UTF-8
Terminal=false
Categories=None;
[CTRL][X] followed by [Y] [Return] to save and exit

To install the Eclipse based development system
https://wiki.bitcraze.io/projects:virtu ... :create_vm
Install tools

Code: Select all

sudo apt-get -y install git kicad sdcc python2.7 python-usb python-qt4 qt4-designer kicad build-essential python-pip libsdl2-dev python-pyqtgraph openocd
sudo pip install pysdl2
sudo apt-get -y install gitg meld leafpad
sudo apt-get install gcc-arm-none-eabi
Add udev rule

Code: Select all

sudo nano /etc/udev/rules.d/99-crazyradio.rules
Add this below the previous one...

Code: Select all

SUBSYSTEM==\"usb\", ATTRS{idVendor}==\"1915\", ATTRS{idProduct}==\"0101\", MODE=\"0664\", GROUP=\"plugdev\"
[CTRL][X] followed by [Y] [Return] to save and exit.

Add the projects

Clone the repos as follows

Code: Select all

cd
mkdir ~/projects
cd ~/projects
git clone git://github.com/bitcraze/crazyflie-clients-python.git
git clone git://github.com/bitcraze/crazyflie-firmware.git
git clone git://github.com/bitcraze/crazyflie-bootloader.git
git clone git://github.com/bitcraze/crazyradio-firmware.git
git clone git://github.com/bitcraze/crazyflie-android-client.git
git clone git://github.com/bitcraze/crazyflie2-exp-template-electronics.git
git clone git://github.com/bitcraze/crazyflie2-stm-bootloader.git
git clone git://github.com/bitcraze/crazyflie2-nrf-bootloader.git
git clone git://github.com/bitcraze/crazyflie2-nrf-firmware.git
Install PyCharm
https://www.jetbrains.com/pycharm/downl ... on=windows
put in Downloads directory

Code: Select all

cd /home/pi/Downloads
sudo tar -xf pycharm-community*tar.gz -C /opt/
echo -e "\nPATH=\$PATH:/opt/pycharm-community-4.0.2/bin" >> ~/.bashrc
source ~/.bashrc
Install Eclipse

Code: Select all

sudo apt-get update
sudo apt-get install eclipse
sudo apt-get install eclipse-cdt g++

sudo apt-get upgrade
sudo reboot
Add the Update All Projects script and desktop link
https://wiki.bitcraze.io/projects:virtu ... :create_vm

Code: Select all

cd /home/pi/crazyflie
mkdir crazyflie-scripts
nano /home/pi/crazyflie/crazyflie-scripts/update-all-projects.sh
Add the following modified from the crazyflie wiki

Code: Select all

#!/bin/bash
#
# Simple script to update all the repos to the latest version.

for f in /home/pi/projects/*
do
        if [ -d "$f" ]; then
                echo "Updating $f"
                cd $f
                git pull
                cd ..
        fi
done
read -p "Press any key to exit" -n1 -s
[CTRL][X] followed by [Y] [Return] to save and exit.

Make script executable

Code: Select all

chmod 555 /home/pi/crazyflie/crazyflie-scripts/update-all-projects.sh
Desktop Link to Update All Projects

Code: Select all

sudo nano ~/Desktop/update-all-projects.desktop
Insert the following:

Code: Select all

[Desktop Entry]
Name=Update All Projects
Comment=Updates All Projects
Icon=/usr/local/cfclient/icon-256.png
Exec=/home/pi/crazyflie/crazyflie-scripts/update-all-projects.sh
Type=Application
Encoding=UTF-8
Terminal=true
Categories=None;
[CTRL][X] followed by [Y] [Return] to save and exit.

Reboot and try...

Code: Select all

sudo reboot
Last edited by PhilipMC on Mon May 16, 2016 6:16 pm, edited 2 times in total.
chad
Expert
Posts: 555
Joined: Sun Sep 28, 2014 12:54 am
Location: New York, USA
Contact:

Re: Developer Environment and Client on a Raspberry Pi 3 with Jessie

Post by chad »

Very nice write up! It will certainly be useful to many people!! :)
Crazyflier - my CF journal...
4x Crazyflie Nano (1.0) 10-DOF + NeoPixel Ring mod.
3x Crazyflie 2.0 + Qi Charger and LED Decks.
Raspberry Pi Ground Control.
Mac OS X Dev Environment.
Walkera Devo7e, ESky ET6I, PS3 and iOS Controllers.
kristoffer
Bitcraze
Posts: 630
Joined: Tue Jun 30, 2015 7:47 am

Re: Developer Environment and Client on a Raspberry Pi 3 with Jessie

Post by kristoffer »

Cool!
If you feel inclined, I think this would be a perfect write up for https://www.hackster.io/bitcraze/projects. Especially the client part. That makes an awesome portable client setup!
PhilipMC
Beginner
Posts: 6
Joined: Wed Mar 30, 2016 6:34 pm
Location: Kent, UK

Re: Developer Environment and Client on a Raspberry Pi 3 with Jessie

Post by PhilipMC »

I found an error in: The script section
Add the Update All Projects script and desktop link
which advises you to use the script from bitcraze. This has a file structure with the user home 'bitcraze', whereas my installation has the user home 'pi'.
I have corrected the script in my original post to reflect the user home 'pi' being used.
hittstick
Beginner
Posts: 27
Joined: Thu Apr 06, 2017 7:26 am

Re: Developer Environment and Client on a Raspberry Pi 3 with Jessie

Post by hittstick »

Hi! First I should say that I am using Ubuntu Mate 16.04 on the rpi3. Your instructions went without a hitch, with everything installing smoothly. After the final reboot, I attempted to run the cfclient from the terminal, after which it promptly announced that it did not detect a pyqt5 installation. This contradicts apt-get, which shows python3-pyqt5 as being installed. Any ideas about how I can resolve this error? Thanks in advance, I want to make sure I can get this up and running before I purchase the happy hacker bundle :)

####UPDATE####

I tinkered around a little bit without much headway, and then used

sudo apt-get purge python3-pyqt5 -y && sudo apt-get autoremove -y && sudo apt-get update -y && sudo apt-get install python3-pyqt5 -y

and voila, the client is up and running, and i can even run it remotely through ssh with X11 forwarding.

Now to scrape together some cash for the bundle.
Last edited by hittstick on Thu Apr 06, 2017 9:04 pm, edited 1 time in total.
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: Developer Environment and Client on a Raspberry Pi 3 with Jessie

Post by arnaud »

Did you install the client with "pip3"? what you are describing could be because you are running the client with python2 instead of python3.
hittstick
Beginner
Posts: 27
Joined: Thu Apr 06, 2017 7:26 am

Re: Developer Environment and Client on a Raspberry Pi 3 with Jessie

Post by hittstick »

That was a strange thing about it, while trying to get it to work after the final reboot I tried installing with pip3, but it would throw errors,

sudo -H pip3 install PyQt5
and
sudo -H pip3 install python-qt5

both failed, reinstalling with apt-get got the user interface up and running. Now I just need to get the drone and test it out.

Other than that, we now know that the installation instructions work for both Raspbian and Ubuntu Mate :mrgreen:
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: Developer Environment and Client on a Raspberry Pi 3 with Jessie

Post by arnaud »

Thanks for the update. Good to know that the instruction works on Raspberry pi too.

The fact that installing pyqt5 with pip does not work is not surprising since this is a binary package and it is only compiled for x86_64 (https://pypi.python.org/pypi/PyQt5/5.8.2).
PhilipMC
Beginner
Posts: 6
Joined: Wed Mar 30, 2016 6:34 pm
Location: Kent, UK

Re: Developer Environment and Client on a Raspberry Pi 3 with Jessie

Post by PhilipMC »

It is interesting that the modified solution works with Ubuntu Mate. But then Raspbian and Ubuntu are from the same stable.

In coming to the original solution I had to resolve problems with python versions and java versions (for Eclipse).
With python it was a matter of checking as two versions are in use at the same time.
With java the following commands were very useful in identifying the versions present and permitting one to be identified as the default.

Check Java versions:

Code: Select all

apt-cache search oracle-java
Found 1.7 and 1.8

Select chosen java version from those installed

Code: Select all

sudo update-alternatives --config java
Chose v 1.8 WORKS

I hope this helps if those problems should arise.

Philip
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: Developer Environment and Client on a Raspberry Pi 3 with Jessie

Post by arnaud »

Thanks for the update.

How is eclipse working in the raspberry pi? I would expect it to run out of memory very quickly.
Post Reply