I wanted to get it running with my raspberry pi to use it on the go but ran into a few hiccups so I decided to put this doc together as guide for anyone whom has a PS3 Bluetooth controller at home (crazyfly has only documentation on xbox wired).
Things you need:
- Crazyflie
- Sony PS3 Controller
- USB Bluetooth adapter
- Crazyradio
- Raspberry Pi (with all necessary accessories)
- Start to assemble the crazyflie using the instructions at bitcrazy.
- Download and image an SD card with bitcraze pre-built raspberry pi crazy fly image: http://wiki.bitcraze.se/projects:crazyflie:binaries:raspberrypi.
- Boot up the Pi with the fresh baked image, update you pi and install any necessary tools you use (I usually install vim, lshw, screen, etc..)
- Install PS3 controller and other necessary libraries:
sudo apt-get upgrade
sudo apt-get install bluez-utils bluez-compat bluez-hcidump libusb-dev libbluetooth-dev joystick usbutil pyqt4-dev-tools - Check that the Bluetooth module is being detected:
pi@raspberrypi ~ $ hciconfig hci0: Type: BR/EDR Bus: USB
BD Address: 00:1F:81:00:06:20 ACL MTU: 1021:4 SCO MTU: 180:1
UP RUNNING PSCAN
RX bytes:1260 acl:0 sco:0 events:46 errors:0
TX bytes:452 acl:0 sco:0 commands:45 errors:0
If you see your USB Bluetooth adapter then you are good if not there is an issue with the Pi Recognizing your adapter
- Install the paring software to pair the controller with the Pi:
wget http://www.pabr.org/sixlinux/sixpair.c
gcc -o sixpair sixpair.c -lusb
- After you compile this file there will be a binary executable called “sixpair” which now you can execute, connect your PS3 controller using a USB cable to the Pi (You only have to do this once for the pairing)
Run the executable and you should see something like this:
crazyfly-pi ~ $ sudo ./sixpair
Current Bluetooth master: f0:f0:02:c7:f5:8e
Setting master bd_addr to 00:10:60:d2:c2:fe
- If you get that output that means your controller is now officially paired with the Pi. Now we have to install the controlling application that read the controller as an input device.
wget http://sourceforge.net/projects/qtsixa/files/QtSixA%201.5.1/QtSixA-1.5.1-src.tar.gz
tar xfvz QtSixA-1.5.1-src.tar.gz
cd QtSixA-1.5.1/sixad
make
sudo mkdir -p /var/lib/sixad/profiles
sudo make install - Now we can test to see if the controller is working first start the sixad daemon and initiate the controller:
sudo sixad --start
When Prompted Press the PS button and the 4 upper LED on controller will light up. - To test that you are indeed receiving input from the controller run jstester against the input:
sudo /usr/bin/jstest /dev/input/js0
You should be seeing the following values change and you press keys in the controller.
- We must tell now cfheadless that we are going to be using a PS3 Bluetooth controller edit the following file and Change PS3_Mode1 to PS3_Mod2 like so:
crazyfly-pi:~# cat /home/bitcraze/controller.conf
PS3_Mode_2
- Now we need to make that assures that cfheadless is always running, this assures that even if the crazyflie is not detected right away it will get configured the right way. Place the following script in /root/run_crazyfly.sh
- Now we make this run every minute
sudo -i
crontab -e
and add the following lines to it:
*/1 * * * * /root/run_crazyfly.sh
@reboot sixad -s
- You should be set now, restart your pi, make sure you turn on your crazyflie. Once the pi has booted give it 5 minutes and press the PS button on your ps3 controller. You should be able to controller your crazyflie with the controller.
6 comments:
How are you powering the raspberry pi when away from an outlet? some portable usb power or does the pi have a rechargeable battery?
Using an external battery pack:New Trent iCarrier 12000mAh Portable Dual USB Port External Battery... http://www.amazon.com/dp/B003ZBZ64Q/ref=cm_sw_r_udp_awd_Mr0Xsb178THTF
I'm about to give this a try. What do you mean by "all necessary accessories" for the Raspberry Pi? I'm starting from scratch so a list would be nice.
Thanks for putting this info out
"We must tell now cfheadless that we are going to be using a PS3 Bluetooth controller edit the following file and Change PS3_Mode1 to PS3_Mod2 like so: crazyfly-pi:~# cat /home/bitcraze/controller.conf
PS3_Mode_2"
How? It's a read only file. Everything worked as you wrote in your blog until I get here. I don't know how to make a read only file editable.
Thanks for the great guide, was hoping someone had done a bluetooth ps3 control setup. Can't wait to get my crazyflie!
Is there a how-to video on this?
Thanks for posting the instructions.
Post a Comment