Products
-
-
- Accessories
- Breakout boards
This is an old revision of the document!
You should setup the CF Headless client (see below) instead of the regular PC client on your Pi, since the UI seems to a bit too heavyweight for the Pi (controlling got very laggy during tests).
For the following installation instructions it is assumed that you are running the popular Raspbian distrubution on your Pi.
In order for the client to be able to access the dongle, you'll have to setup these udev rules.
Execute the following commands as your user of choice (for example the default user pi
):
cd sudo apt-get install mercurial python2.7 python-usb python-pygame python-qt4 hg clone https://bitbucket.org/bitcraze/crazyflie-pc-client cd crazyflie-pc-client hg up dev-cfheadless
This installs the necessary dependencies for running the client, checks out the current development version from BitBucket and then switches to the branch containing the headless client. If you want to use a custom configuration for the controller of your choice copy it to ~/crazyflie-pc-client/conf/input
. Then edit the file ~/crazyflie-pc-client/lib/cfheadless.py
. You'll need to change the URI of your Crazyradio and – if you want a different one than PS3_Mode_1
– configure the correct input mapping to use. The corresponding lines can be found at the end of the file:
app = HeadlessClient(sys.argv,link_uri="radio://0/10/250K", input_config="<your input config>")
Plugin your Crazyradio and your controller, power up the Crazyflie and start the client1):
/home/pi/crazyflie-pc-client/bin/cfheadless
The client should start up, hopefully find your Crazyradio dongle, your Crazyflie and your controller and start accepting commands:
pi@raspberrypi ~ $ ~/crazyflie-pc-client/bin/cfheadless Info: Using config path: /home/pi/crazyflie-pc-client/lib/../conf Info: sys.path= ['/home/pi/crazyflie-pc-client/lib', '/home/pi/crazyflie-pc-client/lib/../conf', '/home/pi/crazyflie-pc-client/bin', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.7'] Disabling standard output for libraries! INFO:cfclient.utils.config:Dist config read from /home/pi/crazyflie-pc-client/lib/cfclient/configs/config.json INFO:cfclient.utils.input:Parsing [PS3_Mode_1.json] INFO:cfclient.utils.input:Parsing [xbox360_mode1.json] INFO:cfclient.utils.input:Parsing [PS3_Mode_2.json] INFO:cfclient.utils.input:Parsing [Generic_OS_X.json] INFO:cfclient.utils.input:Parsing [<your input config>.json] DEBUG:cflib.crazyflie:Adding callback on port [5] to [<bound method Log._new_packet_cb of <cflib.crazyflie.log.Log instance at 0x82ff08>>] DEBUG:cflib.crazyflie:Adding callback on port [0] to [<bound method Console.incoming of <cflib.crazyflie.console.Console instance at 0x90f0f8>>] DEBUG:cflib.crazyflie:Adding callback on port [2] to [<bound method _ParamUpdater._new_packet_cb of <_ParamUpdater(Thread-2, initial daemon)>>] INFO:cflib.crazyflie:Callback->Connection initialized[radio://0/10/250K] INFO:cflib.crazyflie:We are connected[radio://0/10/250K], request connection setup DEBUG:cflib.crazyflie.toc:[5]: Start fetching... DEBUG:cflib.crazyflie:Adding callback on port [5] to [<bound method TocFetcher._new_packet_cb of <cflib.crazyflie.toc.TocFetcher instance at 0x90fad0>>] DEBUG:cflib.crazyflie:ExpectAnswer: Will expect answer on port [5] Found [Xbox Gamepad (userspace driver)] Will use [Xbox Gamepad (userspace driver)] for input DEBUG:cflib.crazyflie:ExpectAnswer: No answer on [5], do retry DEBUG:cflib.crazyflie:ExpectAnswer: Will expect answer on port [5] WARNING:cflib.crazyflie:ExpectAnswer: ERROR! Older timer whas running while scheduling new one on [5] DEBUG:cflib.crazyflie:ExpectAnswer: No answer on [5], do retry DEBUG:cflib.crazyflie:ExpectAnswer: Will expect answer on port [5] WARNING:cflib.crazyflie:ExpectAnswer: ERROR! Older timer whas running while scheduling new one on [5] DEBUG:cflib.crazyflie:ExpectAnswer: No answer on [5], do retry DEBUG:cflib.crazyflie:ExpectAnswer: Will expect answer on port [5] WARNING:cflib.crazyflie:ExpectAnswer: ERROR! Older timer whas running while scheduling new one on [5] INFO:cflib.crazyflie:Callback->Connected to [radio://0/10/250K] ERROR:cflib.crazyflie.toc:Got packet that was not on TOC channel, TOC fetch will probably not succeed DEBUG:cflib.crazyflie:ExpectAnswer: Got answer back on port [5], cancelling timer DEBUG:cflib.crazyflie.toc:[5]: Got TOC CRC, 9 items and crc=0x892049D2 INFO:cflib.crazyflie.toc:TOC for port [5] found in cache DEBUG:cflib.crazyflie:Removing callback on port [5] to [<bound method TocFetcher._new_packet_cb of <cflib.crazyflie.toc.TocFetcher instance at 0x90fad0>>] DEBUG:cflib.crazyflie.toc:[5]: Done! INFO:cflib.crazyflie:Log TOC finished updating DEBUG:cflib.crazyflie.toc:[2]: Start fetching... DEBUG:cflib.crazyflie:Adding callback on port [2] to [<bound method TocFetcher._new_packet_cb of <cflib.crazyflie.toc.TocFetcher instance at 0x926968>>] DEBUG:cflib.crazyflie:ExpectAnswer: Will expect answer on port [2] DEBUG:cflib.crazyflie:ExpectAnswer: Got answer back on port [2], cancelling timer DEBUG:cflib.crazyflie.toc:[2]: Got TOC CRC, 27 items and crc=0x27A2C4BA INFO:cflib.crazyflie.toc:TOC for port [2] found in cache DEBUG:cflib.crazyflie:Removing callback on port [2] to [<bound method TocFetcher._new_packet_cb of <cflib.crazyflie.toc.TocFetcher instance at 0x926968>>] DEBUG:cflib.crazyflie.toc:[2]: Done! INFO:cflib.crazyflie:Param TOC finished updating INFO:cflib.crazyflie:Callback->Connection setup finished [radio://0/10/250K]
Marcus added the following things to note when using the headless client since it is a very early version:
Starting (and killing) the client automatically upon Crazyradio insertion/removal can be done via udev.
Adjust your Crazyradio udev rule (e.g. /etc/udev/rules.d/99-crazyradio.rules
) to look like the following:
SUBSYSTEM=="usb", ATTRS{idVendor}=="1915", ATTRS{idProduct}=="7777", MODE=="0664", GROUP="plugdev", RUN+="/root/bin/cfheadless"
and (as root) create a file /root/bin/cfheadless
with the following contents:
#!/bin/sh if test "$ACTION" = "add" then /usr/bin/sudo -u pi /home/pi/crazyflie-pc-client/bin/cfheadless > /tmp/cfheadless.log 2>&1 & 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
Don't forget to make it executable: chmod +x /root/bin/cfheadless
. This should now take care to startup the headless client when you plug in the dongle and (hopefully ) kill it again when you unplug. If you need any additional setup to get your controller working, you can add a similar udev-rule for that to take care of everything upon plugging in the controller as well. An example for the Microsoft Wireless XBox360 controller for PC can be found in this forums post.
Important
Due to the current state of the client, you must make sure to first connect (and – if it's wireless – also power up) your controller and power up the Crazyflie before connecting the Crazyradio dongle and thus starting the client. If the client can't find either controller or Crazyflie, it will just hang and you'll have to re-plug the dongle again.
If you want to you can make your base station completely portable simply by using a portable USB power supply (e.g. the Anker3 10.000mAh) for powering the Pi. Putting everything into some case and attaching it somewhere on yourself (e.g. your belt) makes you completely mobile while piloting your Crazyflie
python2
could not be found, edit ~/crazyflie-pc-client/bin/cfheadless
and change the python2
in the first line to python