User Tools

Site Tools


projects:crazyflie:pc_utils:raspberrypi

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
projects:crazyflie:pc_utils:raspberrypi [2015-02-20 04:59]
chad Added a 'cd' at the beginning of the section about creating the start_cfheadless file to ensure user is in /home/bitcraze first.
projects:crazyflie:pc_utils:raspberrypi [2021-06-24 16:47] (current)
kimberly
Line 1: Line 1:
 +<WRAP center round important 60%>
 +This page has deprecated and will be archived. Please go to [[https://www.bitcraze.io/]].
 +</WRAP>
 +====== 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 [[misc:hacks:rasberrypi|hacks section]].
  
 +<WRAP center round info>
 +//**Note**//
 +Since version 2015.3 you can setup your own SDCard in [[projects:crazyflie:binaries:raspberrypi#installing_in_an_existing_raspbian_sdcard|one command]].
 +</WRAP>
 +
 +
 +Before you get started with this you need a few things:
 +  * An SD-card that's at least 4GB
 +  * 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 [[http://elinux.org/RPi_Easy_SD_Card_Setup#Create_your_own|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.
 +
 +<WRAP center round tip>
 +//**Info**//
 +All modern Linux distribution now have a kernel driver for the x-box gamepad. Thus it is unlikely the //xboxdrv// user-space driver is needed.
 +</WRAP>
 +
 +
 +Lets install everything that we might need fro running the Crazyradio, controllers and the headless client.
 +<code>
 +sudo apt-get -y install python-usb xboxdrv
 +</code>
 +
 +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:
 +<code>
 +sudo touch /etc/udev/rules.d/99-crazyflie.rules
 +sudo nano /etc/udev/rules.d/99-crazyflie.rules
 +</code>
 +
 +Put the following text in the file:
 +<code>
 +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"
 +</code>
 +
 +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.
 +<code>
 +sudo nano /etc/udev/rules.d/99-xboxdrv.rules
 +</code>
 +Put the following into the text file:
 +<code>
 +SUBSYSTEM=="usb", ATTRS{idVendor}=="045e", ATTRS{idProduct}=="0719", GROUP="plugdev", RUN+="/root/bin/xbox360"
 +</code>
 +
 +Now we should create the file used to launch/kill the cfheadless client. Create the file and edit it:
 +<code>
 +sudo mkdir /root/bin/
 +sudo touch /root/bin/cfheadless
 +sudo chmod +x /root/bin/cfheadless
 +sudo nano /root/bin/cfheadless
 +</code>
 +
 +And add the following text:
 +<code>
 +#!/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
 +</code>
 +
 +<code>
 +sudo touch /root/bin/xbox360
 +sudo chmod +x /root/bin/xbox360
 +sudo nano /root/bin/xbox360
 +</code>
 +
 +Also create the script to start/stop the xboxdrv for the wireless xbox360 controller.
 +<code>
 +#!/bin/sh
 +if test "$ACTION" = "add"
 +then
 +        /usr/bin/xboxdrv &
 +else
 +        killall -9 xboxdrv
 +fi
 +</code>
 +
 +Go to the pi users home directory and clone the PC client and Crazyradio firmware projects.
 +<code>
 +cd
 +mkdir projects
 +cd projects
 +git clone https://github.com/bitcraze/crazyflie-clients-python.git
 +</code>
 +
 +Create the script that will execute when the Crazyradio is inserted. This will launch the cfheadless client.
 +<code>
 +cd
 +touch start_cfheadless
 +chmod +x start_cfheadless
 +nano start_cfheadless
 +</code>
 +Insert the following text into the file:
 +<code>
 +/home/pi/projects/crazyflie-clients-python/bin/cfheadless -u `cat /home/pi/link.conf` -i `cat /home/pi/controller.conf` > /tmp/cfheadless.log 2>&1
 +</code>
 +
 +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:
 +<code>
 +echo PS3_Mode_1 > /home/pi/controller.conf
 +echo radio://0/10/250K > /home/pi/link.conf
 +</code>
 +
 +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.
 +
 +{{tag>update_on_pi_release}}