Part to drive your donkeycar with a bluetooth game controller.
Switch branches/tags
Nothing to show
Clone or download

README.md

Build Status

Bluetooth Game Controller

This is a library to connect a Wii-U (and possibly others) bluetooth game controller to your donkeycar.

See the bottom of the page for tested controllers and brands. Beware of knockoffs!

Install

Install the library.

git clone https://github.com/autorope/donkeypart_bluetooth_game_controller.git
pip install -e ./donkeypart_bluetooth_game_controller

Connect your bluetooth controller to the raspberry pi.

  1. Start the bluetooth bash tool on your raspberry pi.
sudo bluetoothctl
power on
scan on
  1. Turn on your controller in scan mode and look for your controllers name in the bluetoothctl scan results. This is done by turning over the controller and pushing the sync button until the 4 blue buttons blink
  2. Connect to your controller using its id (my controller id is 8C:CD:E8:AB:32:DE) once you've found it's id. You may have to run these commands several times.
pair 8C:CD:E8:AB:32:DE
connect 8C:CD:E8:AB:32:DE
trust 8C:CD:E8:AB:32:DE
  1. Now your controller should show that your controller is connected - the 4 blinking lights turns to one solid light.

  2. Run the part script to see if it works. You should see all the button values printed as you press them. Like this.

python ./donkeypart_bluetooth_game_controller/donkeypart_bluetooth_game_controller/part.py


LEFT_STICK_Y 0.00234375
LEFT_STICK_Y 0.0015625
LEFT_STICK_Y 0.00078125
A 1
A 0
Y 1
Y 0
X 1
X 0
  1. Assuming you can see the button outputs, you can now plug this in as your donkeycar controller in the manage.py script...
from donkeypart_bluetooth_game_controller import BluetoothGameController

# then replace your current controller with...
ctl = BluetoothGameController()

Add a new type of bluetooth controller.

If you don't have a different type of controller these same instructions should work but the button mappings will be different.

  1. Use the this same script to show the live output of your controller...
python ./donkeypart_bluetooth_game_controller/donkeyblue/part.py log
  1. Copy the WiiU config file and update it with your controllers values.

  2. Now you can use your game controller with these new button mappings like this:

from donkeypart_bluetooth_game_controller import BluetoothGameController
ctl = BluetoothGameController(config=/path/to/your/config/file)
  1. Make a pull request with your button mappings so other people can use it.

Tested Controllers

Works

  • Wii U Pro Controller by Nintendo

Kind of Works (Not Recommended)

  • Wii U Pro Controller by SIBIONO - This controller seems laggy give the refresh rate from the controller is half of what better controllers give.

Test a New Controller

Run the profile script to see the number of events per second you recieve from the controller. Then make a pull request to update this document to help others.

python ./donkeypart_bluetooth_game_controller/donkeyblue/part.py log