User Tools

Site Tools


projects:crazyflie:pc_utils:raspberrypi

This is an old revision of the document!


Modifying the Raspian Wheezy image

Here's a step by step guide to what we added. So if you don't want to use our image, you can get another one and set it up yourself. Most of this stuff is based of the contributed instructions from the hacks section.

Before you get started with this you need a few things:

  • An SD-card that's at least 2GB
  • An ethernet cable to connect the Pi to your network
  • A power cord to power it
  • An SD-card reader for a computer

First of all you have to write the image to the SD-card. There are good instructions on how to do this here.

Now plug the SD-card into the Pi, attach all the cables and SSH to it. Log in user the username pi and the password raspberry and accept the fingerprint.

Most of these commands require root user, so switch to root:

sudo su

Let's create a user named bitcraze with the password crazyflie and add it to all the user groups.

useradd bitcraze -m -p crazyflie -G adm,dialout,cdrom,sudo,audio,video,plugdev,games,users,netdev,input

Now install everything that we might need fro running the Crazyradio, controllers and the headless client.

apt-get -y install mercurial python2.7 python-usb python-pygame xboxdrv

The shebang in the cfheadless client uses /usr/bin/pyton2 which isn't available in the original image so create a symbolic link for it.

cd /usr/bin
ln -s python2.7 python2

In order to be able to use the Raspberry Pi without having any keyboard/screen let's add a udev rule that starts up the client when the Crazyflie is inserted and kills it when it's removed. We should also have a rule that allows us to use the Crazyradio bootloader with out being root. Create the file and edit it:

touch /etc/udev/rules.d/99-crazyflie.rules
nano /etc/udev/rules.d/99-crazyflie.rules

Put the following text in the file:

SUBSYSTEM=="usb", ATTRS{idVendor}=="1915", ATTRS{idProduct}=="7777", MODE=="0664", GROUP="plugdev", RUN+="/root/bin/cfheadless"
SUBSYSTEM=="usb", ATTRS{idVendor}=="1915", ATTRS{idProduct}=="0101", MODE=="0664", GROUP="plugdev"

In order for the Xbox 360 wireless controller to work the xboxdrv utility has to be installed and launched when the controller is connected. So add a new udev rule for this.

touch /etc/udev/rules.d/99-xboxdrv.rules
nano /etc/udev/rules.d/99-xboxdrv.rules

Put the following into the text file:

SUBSYSTEM=="usb", ATTRS{idVendor}=="045e", ATTRS{idProduct}=="0719", GROUP="plugdev", RUN+="/root/bin/xbox360"

Now we should create the file used to launch/kill the cfheadless client. Create the file and edit it:

mkdir /root/bin/
touch /root/bin/cfheadless
chmod +x /root/bin/cfheadless
nano /root/bin/cfheadless

And add the following text:

#!/bin/sh
if test "$ACTION" = "add"
then
        /usr/bin/sudo -u bitcraze /home/bitcraze/start_cfheadless &
        echo $! > /tmp/cfheadless.pid
else
        killall -9 cfheadless
        if test -f /tmp/cfheadless.pid
        then
                PID=`cat /tmp/cfheadless.pid`
                kill -9 $PID
        fi
fi
touch /root/bin/xbox360
chmod +x /root/bin/xbox360
nano /root/bin/xbox360

Also create the script to start/stop the xboxdrv for the wireless xbox360 controller.

#!/bin/sh
if test "$ACTION" = "add"
then
        /usr/bin/xboxdrv &
else
        killall -9 xboxdrv
fi

Now we are finished with the system setup so switch to the newly created bitcraze user by first exiting switching back to the pi user and then bitcraze:

exit
sudo su bitcraze

Go to the bitcraze users home directory and clone the PC client and Crazyradio firmware projects.

cd
mkdir projects
cd projects
hg clone https://bitbucket.org/bitcraze/crazyflie-pc-client
hg clone https://bitbucket.org/bitcraze/crazyradio-firmware

Create the script that will execute when the Crazyradio is inserted. This will launch the cfheadless client.

touch start_cfheadless
chmod +x start_cfheadless
nano start_cfheadless

Insert the following text into the file:

/home/bitcraze/projects/crazyflie-pc-client/bin/cfheadless -u `cat /home/bitcraze/link.conf` -i `cat /home/bitcraze/controller.conf` > /tmp/cfheadless.log 2>&1

Now the last part, the configuration. The script above will launch the cfheadless client with the controller and link configuration that is written in the two files 'controller.conf' and 'link.conf'. This configuration is written using the following commands:

echo PS3_Mode_1 > /home/bitcraze/controller.conf
echo radio://0/10/250K > /home/bitcraze/link.conf

If you are using another controller configuration or another link, just use the same commands as above but replace it with your own settings.

That's it! Now you can connect the controller, start the Crazyflie and insert the Crazyradio and you are ready to fly.

projects/crazyflie/pc_utils/raspberrypi.1373180633.txt.gz · Last modified: 2015-07-15 16:30 (external edit)