Protobot - Raspberry Pi + Wifi + Xbox + IMU + Picamera

by lawsonkeith in Circuits > Raspberry Pi

6644 Views, 15 Favorites, 0 Comments

Protobot - Raspberry Pi + Wifi + Xbox + IMU + Picamera

protobot.JPG

RC Car controlled over wifi using an XBox controller featuring:

1. Haptic feedback

2. Pi Camera video feedback

3. Wireless XBox360 control

4. Wifi Telemetry

Full wiki on:

https://github.com/lawsonkeith/Protobot

MPU6050

Screenshot.png

The PI uses a MPU6050 IMU. First off you have to enable I2C on the pi, wire it up then test it using the commands in 'scripts'. Again there may be some dependencies. The server transmits impacts back to the client to transmit to the operator as haptic feedback using the XBOX force feedback.

https://www.instructables.com/id/Reading-I2C-Inputs...

Install i2c tools...

sudo apt-get install libi2c-dev

Edit the i2c On the pi's BIOS then reboot.

sudo raspi-config

sudo nano /etc/modules

sudo nano /etc/modprobe.d/raspi-blacklist.confsudo i2cdetect -y 1

The MPU605 should appear as 68.

Downloads

Pi Blaster

Raspberry-Pi-GPIO-pinouts.png

The PWM on the Pi is done with the Pi blaster Daemon. The server sends data to the servos direct from the Pi and in software to the PI-BLASTER FIFO.

FIFO is at /dev/pi-blaster

To completely turn on GPIO pin 17:

echo "17=1" > /dev/pi-blaster

To set GPIO pin 17 to a PWM of 20%

echo "17=0.2" > /dev/pi-blaster

To test just use a multimeter and some echo commands, write down on paper what you need to send to your servos to get them to do what you want. Check my server code for my values, yours will be close luckily you can control them with the 0-3.3V offered by the PI as the control signal is unipolar.

For the wiring loom I used an IDC connector and some 2.54mm header.

NOTE - (1) I've had issues with this interfering with the PIs windows environment in the past with lockups so I don't tend to boot into the PI X windows interface.(2) sudo chown root test.sh, then sudo chmod +s test.sh to allow scripts to acces GPIO as non root

Wifi

router.png

Follow adafruits guide to seting up the wifi using the terminal on the Pi. I found it easier to do it via the command line and had issues with the GUI in x windows.

sudo cp interfaces /etc/network/

XBOX 360 Controller Testing

Capture2.JPG

Acquire the windows XBOX wireless driver and install the drivers. There's a tutorial here http://www.s-config.com/archived-xbox-360-receiver-install-for-win-xp-and-win-7/ if you buy a cheap Chinese copy and can't get it working. The LED on the controller will indicate when it's paired. The drivers should already be on linux if it's a recent release, I used Xubuntu 15. Use the following commands to look for or test the XBOX controller.

use cat /proc/bus/input/devices, look at 'Handlers' if unsure!fftest /dev/input/event3, this tests force feedback.jstest /dev/input/js0, this test analogs.ls /dev/input, you should see the joystick FIFOs here.I didn't have to install anything in linux (apart from maybe jstest), all the pain was in windows. Test it in windows first, in 'devices and printers' you can check all the controls work on the gamepad. Then test in linux with jstest and fftest.

Installing Gstreamer & Picamera on the Pi

DSC_0422.JPG

For gstreamer generally I used:

https://sparkyflight.wordpress.com/2014/02/22/rasp... as a reference.

Once you are happy you can test the Protobot script cd ~/Protobot./runclient.sh 192.168.1.6

The server (robot) runs automatically once setup.