PS3 Control with GoPiGo

PS3 Control with GoPiGo

 This project shows how control the GoPiGo with a PS3 Dualshock 3 controller.

The PS3 controller can be used to control the GoPiGO with a bluetooth adapter. You have to pair the PS3 with the GoPiGo first and you’ll have your own cool RC car.

You can try out his example to see how to control the GoPiGo with a PS3 adapter and adapt it into projects of your own.

Raspberry Pi PS3 Control with GoPiGo

Hardware needed:

Connecting the Bluetooth Adapter and the PS3 controller:

  • Connect the Bluetooth adapter to any of the USB ports.
  • Connect the PS3 controller to the Raspberry Pi with a USB Mini A/B cable.

Setting up the GoPiGo

Make sure that the GoPiGo is set up properly and you have the updated software and firmware. If you are not sure about this, follow the guide here.

If the GoPiGo is properly set up, connect to the GoPiGo via SSH or VNC and open terminal.

Running the example:

  1. Go to the PS3 Control folder:
     cd ~/Dexter/GoPiGo/Software/Python/Examples/PS3_Control/

     

  2. Next, connect your PS3 Controller to the Raspberry Pi, using the USB cable.  In the command line, make the program “sixpair” executable and run it.  This will pair the PS3 controller to the Bluetooth adapter.
    sudo chmod +x sixpair
    sudo ./sixpair

     

  3. Disconnect the USB cable which was connected to the PS3 controller.  Press the PS button on the PS3 controller (this is the round button in the middle, between the “Select” and “Start” button on the controller) and a couple of random buttons on the controller. The light on the Bluetooth adapter should become solid green from the blinking green earlier.PS3 Control of the Raspberry Pi with GoPiGo
  4. Start the bluetooth pairing method:
    sudo bluetoothctl
    discoverable on
    agent on
  5. Now, still in the bluetooth program, start to press buttons.  You should see something like this:
    [bluetooth]# agent on
    Agent registered
    [NEW] Device 64:D4:BD:3A:E1:95 64-D4-BD-3A-E1-95
    [CHG] Device 64:D4:BD:3A:E1:95 Connected: no
    [DEL] Device 64:D4:BD:3A:E1:95 64-D4-BD-3A-E1-95
    [NEW] Device 64:D4:BD:3A:E1:95 64-D4-BD-3A-E1-95
    [CHG] Device 64:D4:BD:3A:E1:95 Connected: no
    [DEL] Device 64:D4:BD:3A:E1:95 64-D4-BD-3A-E1-95
    [NEW] Device 64:D4:BD:3A:E1:95 64-D4-BD-3A-E1-95
    [CHG] Device 64:D4:BD:3A:E1:95 Connected: no
    [DEL] Device 64:D4:BD:3A:E1:95 64-D4-BD-3A-E1-95
    
    
    
    
  6. Note down the mac address of the device.  In our case, it’s 64:D4:BD:3A:E1:95
  7. Run the “connect” command, followed by the bluetooth mac address of your device. In our case, this will be connect 64:D4:BD:3A:E1:95
  8. Finally, set the device as trusted.  We’ll use the “trust” command:  `trust 64:D4:BD:3A:E1:95`
  9. Type quit to exit the bluetooth pairing program.
  10. Finally type sudo reboot to reboot the computer.
  11. Check that the PS3 controller has paired.  Press the PS button in the center of the controller again and type ls /dev/input/js*   You should see something like /dev/input/js0

Note: if you received ls: cannot access /dev/input/js*: No such file or directory try pairing your controller again by pressing the PS button.

Start the PS3controller example :

After pairing your PS3 controller with the Pi, we’re ready to run our code.

 cd ~/Dexter/GoPiGo/Software/Python/Examples/PS3_Control/
 sudo python ps3_gpg_example.pyRun the Ps3 Controller example 

To control the GoPiGo from the Ps3 controller:

    • Use the Up,Down,Left,Right buttons to control the motion of the GoPiGo.
    • Use L2 to increse the speed.
    • Use R2 to decrease the speed.
    • Use the left joystick to control the servo position.

You can easily adapt this example to any project which can make use of a PS3 controller with the GoPiGo.

Have a question? Go check out our support page here or post it on the forums here

{"cart_token":"","hash":"","cart_data":""}