This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
misc:hacks:rasberrypi [2013-05-17 16:43] skube [Install the headless client] |
misc:hacks:rasberrypi [2021-06-24 16:45] (current) kimberly |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | <WRAP center round important 60%> | ||
+ | This page has deprecated and will be archived. Please go to [[https:// | ||
+ | </ | ||
====== Using the Raspberry Pi as a base station for flying ====== | ====== Using the Raspberry Pi as a base station for flying ====== | ||
- | You should setup the CF Headless client (see [[# | + | In order to make it easy for users that have a Raspberry Pi to test out our headless client we prepared an SD-card image that is ready to use out of the box. |
+ | |||
+ | The full SD-card image, and instructions on how to install it are located [[http:// | ||
+ | |||
+ | Instead of the official Python headless client, there is also a working Ruby version of the headless client, developed by a user. This version, called Crubyflie, can be installed on top of the SD-card image described above or on a standalone version of Linux/ | ||
+ | |||
+ | ====== Manual Installation ===== | ||
+ | |||
+ | As an alternative to a full SD-card image, you can manually install the headless Python client as a program on your Pi. | ||
For the following installation instructions it is assumed that you are running the popular [[http:// | For the following installation instructions it is assumed that you are running the popular [[http:// | ||
Line 21: | Line 32: | ||
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. | 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. | ||
- | **Note**: you'll need to change the URI of your Crazyradio from the default 1M to 250K (make sure the K is uppercase). | + | If you are using an XBox Controller w/ Wireless Gaming Receiver, you might need to also install |
- | <code python> | + | sudo apt-get install xboxdrv |
- | app = HeadlessClient(sys.argv, | + | |
- | | + | and start it: '' |
- | </ | + | |
+ | <WRAP center round tip 80%> | ||
+ | **NOTE** | ||
+ | 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. | ||
+ | </ | ||
- | If you are using an XBox Controller w/ Wireless Gaming Receiver, you might need to also install drivers: | ||
- | sudo apt-get install xboxdrv | ||
Plugin your Crazyradio and your controller, power up the Crazyflie and start the client (via SSH and Ethernet or by using an USB hub to connect Crazyradio, controller and keyboard)((If you get an error message that '' | Plugin your Crazyradio and your controller, power up the Crazyflie and start the client (via SSH and Ethernet or by using an USB hub to connect Crazyradio, controller and keyboard)((If you get an error message that '' | ||
- | python ~/ | + | python ~/ |
The client should start up, hopefully find your Crazyradio dongle, your Crazyflie and your controller and start accepting commands: | The client should start up, hopefully find your Crazyradio dongle, your Crazyflie and your controller and start accepting commands: | ||
< | < | ||
- | pi@raspberrypi ~ $ ~/ | + | pi@raspberrypi ~ $ ~/ |
Info: Using config path: / | Info: Using config path: / | ||
Info: sys.path= ['/ | Info: sys.path= ['/ | ||
Line 87: | Line 99: | ||
INFO: | INFO: | ||
</ | </ | ||
+ | |||
+ | ===== Manually Customizing Your .json Configuration File ===== | ||
+ | If you created a customized .json file for your xbox controller using a Windows PC and the cfclient GUI and are planning to copy it over to your Raspberry Pi, here is some advice: | ||
+ | |||
+ | -save the new .json file as something different than the default, so you can recognize it easily. | ||
+ | |||
+ | -the new .json file is not located in the Program Files(x64)/ | ||
+ | |||
+ | -copy your new .json file into the correct RPi folder: / | ||
+ | |||
+ | < | ||
+ | |||
+ | Verify netatalk was installed successfully on your RPi by checking the Finder window on your Mac for a " | ||
+ | |||
+ | -the cfheadless client on RPi may not recognize the same controller channel " | ||
+ | |||
+ | Xbox Controller Input = id# | ||
+ | |||
+ | Left stick vertical = 1 | ||
+ | |||
+ | Left stick horizontal = 0 | ||
+ | |||
+ | Right stick vertical = 3 | ||
+ | |||
+ | Right stick horizontal = 2 | ||
+ | |||
+ | Right trigger = 4 | ||
+ | |||
+ | Customize your flying configuration anyway you like using the inputs/ | ||
+ | |||
+ | **Note**: If you have more than one controller attached, you can select the one to use using the commandline parameter '' | ||
+ | |||
+ | < | ||
+ | usage: cfheadless [-h] [-u URI] [-i INPUT] [-d] [-c CONTROLLER] | ||
+ | [--controllers] | ||
+ | |||
+ | optional arguments: | ||
+ | -h, --help | ||
+ | -u URI, --uri URI URI to use for connection to the Crazyradio dongle, | ||
+ | defaults to radio:// | ||
+ | -i INPUT, --input INPUT | ||
+ | Input mapping to use for the controller, defaults to | ||
+ | PS3_Mode_1 | ||
+ | -d, --debug | ||
+ | -c CONTROLLER, --controller CONTROLLER | ||
+ | Use controller with specified id, id defaults to 0 | ||
+ | --controllers | ||
+ | </ | ||
+ | |||
+ | **Note**: If you still have an old version of the headless client you'll need to manually change the URI of your Crazyradio from the default 1M to 250K (make sure the K is uppercase). If you want to use a custom configuration (other than '' | ||
+ | |||
+ | <code python> | ||
+ | app = HeadlessClient(sys.argv, | ||
+ | | ||
+ | </ | ||
+ | |||
+ | You can then startup the client without any command line arguments and it should hopefully work as well: '' | ||
===== Current state of the headless client ===== | ===== Current state of the headless client ===== | ||
[[http:// | [[http:// | ||
- | * Still dependent on QT (the plan is to remove this very soon) | + | * <del>Still dependent on QT (the plan is to remove this very soon)</ |
- | * Not much error handling yet (the plan is to improve this) | + | * <del>Not much error handling yet (the plan is to improve this)</ |
- | * Values are still hardcoded in the script (like mapping and URI for Crazyflie). They can be changed at the bottom in lib/ | + | * <del>Values are still hardcoded in the script (like mapping and URI for Crazyflie). They can be changed at the bottom in lib/ |
- | * The headless client will open the first input-device found (so don't plug more than one) | + | * <del>The headless client will open the first input-device found (so don't plug more than one)</ |
- | * No good way to quit it yet so you will have to kill the process | + | * <del>No good way to quit it yet so you will have to kill the process</ |
===== Make the client startup automatically on Crazyradio plug in ===== | ===== Make the client startup automatically on Crazyradio plug in ===== | ||
Line 106: | Line 174: | ||
</ | </ | ||
- | and (as root) create a file ''/ | + | and (as root) you will create a file ''/ |
<code bash> | <code bash> | ||
Line 112: | Line 180: | ||
if test " | if test " | ||
then | then | ||
- | / | + | / |
echo $! > / | echo $! > / | ||
else | else | ||
Line 124: | Line 192: | ||
</ | </ | ||
- | Don't forget to make it executable: '' | + | You can only create the cfheadless file above in the /root/bin/ folder by being root--not pi or any other user name. Switch to root: '' |
+ | |||
+ | For the XBox360 Controller (after an " | ||
+ | |||
+ | Create a udev file ''/ | ||
+ | <code bash> | ||
+ | |||
+ | and (as root) create a file ''/ | ||
+ | <code bash># | ||
+ | if test " | ||
+ | then | ||
+ | / | ||
+ | else | ||
+ | killall -9 xboxdrv | ||
+ | fi</ | ||
+ | |||
+ | Don't forget to make your files executable | ||
+ | |||
+ | <code bash> | ||
+ | </ | ||
+ | |||
+ | The -h halts all processes, the -r is the command to reboot after shutdown. | ||
+ | |||
+ | 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. | ||
+ | |||
+ | :!: **Important** :!: Due to the current state of the client, you **must** make sure to first connect your controller | ||
+ | |||
+ | **Troubleshooting** | ||
+ | If it still doesn' | ||
+ | * /tmp/cfheadless.log (If this log indicates that there' | ||
+ | * /var/ | ||
+ | |||
+ | Also, if xboxdrv can't be run without the sudo command, or there are other permissions issues with the xbox wireless usb controller, try adding the the xbox360 wireless receiver to a group you created that has root privileges, like ' | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | Also, if running the xboxdrv command from a terminal window gives you the following error: | ||
+ | |||
+ | <code bash> | ||
- | :!: **Important** :!: Due to the current state of the client, | + | ...your controller may very well have already started automatically per the udev rule you created above and could be working correctly and currently is in use. Make sure your wireless |
===== Make your base station portable ===== | ===== Make your base station portable ===== |