Controlling Raspberry Pi powered robot using PS3 controller and plot drawing using Turtle and Python code.
Have used Google Voice Hat for motor control, you can use any other motor DC motor HAT (eg Adafruit DC Motor HAT )
if in case you are using Google AIY voice HAT ensure you isolated power jumper from raspberry pi power, Read AIY manual
Also you need 2DW robotic base, GoPiGo based, i have build some additions to manage the Pan Tilt which i am planning to use it for this project upgrade.
Follow the PIN diagram specified in the AIY manual. I have used GPIO 04 and GPIO 17 to drive the DC motors , powered by battery power pack
Before connecting PS3 controller to Rapberry pi ensure you powered off PS3 station as the bluetooth auto conflict with connectivity.
Once you booted Raspberry Pi connect the PS3 controller via USB cable and run following command
jstest /dev/input/js0
this command should list all the buttons and values configurations from PS3. if you have the already a joystick driver in place
, if in case you want to calibrate use command -->
jscal -c /dev/input/js0
to install the joystick driver and pygame , Refer sixpair instructions for more
sudo apt-get -y install libusb-dev joystick python-pygame
cd ~
wget http://www.pabr.org/sixlinux/sixpair.c
gcc -o sixpair sixpair.c -lusb
as said, ensure you disconnect PS3 console before you press PS3 button in PS3 controller and run following commands to pair
sudo ~/sixpair
Result Screen Current Bluetooth master: b8:27:eb:cb:33:9c Setting master bd_addr to b8:27:eb:cb:33:9c
sudo bluetoothctl
Result screen
[NEW] Controller B8:27:EB:CB:33:9C raspberrypi [default]
[NEW] Device CC:B1:1A:DA:B5:F1 [TV] Samsung 5 Series (32)
[NEW] Device E0:AE:5E:A8:A0:89 PLAYSTATION(R)3 Controller
[bluetooth]# discoverable on
Changing discoverable on succeeded
[CHG] Controller B8:27:EB:CB:33:9C Discoverable: yes
[bluetooth]# agent on
Agent registered
Type trust command on the identified device code on [bluetooth]#
trust E0:AE:5E:A8:A0:89
Result [CHG] Device E0:AE:5E:A8:A0:89 Trusted: yes Changing E0:AE:5E:A8:A0:89 trust succeeded [CHG] Device E0:AE:5E:A8:A0:89 Connected: yes [PLAYSTATION(R)3 Controller]#
I have re-used the code from JoyBorg, and have removed the pygame screen and replaced with turtle screen for interactive drawing experience. the idea was to draw turtle drawing in the screen in which Robot would replicate in parallel.
git clone https://github.com/sgmoorthy/PS3RasPiRobot.git
cd PS3RasPiRobot
python3 Ps3RaspiRobot.py