I saw recantha’s post pointing people at Brian Corteil’s post on how to control your robot and was surprised to see that the method I used for Metabot last year wasn’t listed. So the obvious thing to do is to document it here, right? 🙂
- Connect a cheap USB wifi dongle to the Pi
- Set the Pi up as a WiFi access point
- Connect a laptop to the Pi’s access point
- Connect an xbox 360 joypad to the laptop
- Write the robot’s controlling python script – it listens for TCP on a port
- The laptop runs a very simple pygame script which listens for joystick inputs:
- These come into the script from the Pygame library as a dictionary.
- The script then converts this dictionary to JSON (using the python json library)
- and sends the JSON over TCP to the IP address/port that the robot is listening on
- The robot then converts the JSON back into a dictionary and reads the joystick values out of it.
Note that if you want an easy control method, I do NOT recommend our one – it can be a pain to set up the wifi access point and the method you use depends on the chipset of the WiFi dongle you have.
Instead, I recommend the bluetooth/wiimote method: this tutorial explains it better than I can and with code examples too. My experience with bluetooth dongles and wiimotes is that Genuine Nintendo wiimotes are required – I tried using a cheap knockoff wiimote and it wouldn’t pair with the dongle, but my genuine ones worked fine.