ps3 ghost controller

has anyone else ever experianced ghost controllers? when i connect my ps3 controller it almost always connects to js1 not js0 and the light on the controller shows player 2? sometimes when i connect to diddyredjoy.py it says the controller is connected but i get no movement from the sticks, also if running sudo ./diddyredjoy.py from terminal and the controller is not connected already it will say its connected and the diddy will drive around in circles with one side running the other still... anyone else experianced this?

piborg's picture

That is unusual...

We have not seen this here, and we do have a fair number of PS3 controllers lying around.

Have you ever had a different controller connected to this Raspberry Pi in the past?

first pi ive used, first controller connected to it, im very confused because i looked into removing the js* devices, i was unable to work it out so i did a complete format and reinstall.
i assumed during my setup i must of done something wrong? running through set up was quicker then the 1st time. didnt see any issues. however when i run bluetoothctl it already said controller connected:yes.
controller still pairs to 2... is your ps3 controller guide "up-to-date"?

piborg's picture

The last version we have tested with was the March release.

We have been too busy with our Kickstarter release the past couple of weeks to check the new version they have made available.
It is possible there is a difference here that we do not yet know about.

Did you just run the "Setup for Jessie and Jessie Lite" instructions, or did you do the "Setup for Wheezy" part as well?

Pretty sure I only ran the Jessie setup, I can imagine you guys have set up a fair few of these machines, you've never experienced it before? Do you know how to remove js devices?

piborg's picture

Usually the first device connected is given js0, the next js1 and so on.

If you are running with the GUI installed you can try jstest-gtk to get a list of joysticks.
Install with:
sudo apt-get -y install jstest-gtk
Then run this line in a terminal within the graphical desktop:
jstest-gtk
This should show a list of joysticks attached to the system as well as some live feedback if you go into properties.

so i ran `jstest-gtk` as you suggested... it shows the microsoft 2.4 transciever as device `/dev/input/js0` and ps3 controller as device `/dev/input/js1` im wondering if this is due to using pi3 and its onboard bluetooth controller. i plan on getting another pi3 soon so i will run comparisons... when setting up the controller in pygame do you specify which device it should be looking at?

piborg's picture

How interesting, I guess it provides a joystick output even without a controller or joystick connected to it at the time.

You can change which joystick is used fairly easily.
Look for this line in the script:
joystick = pygame.joystick.Joystick(0)
the "0" refers to "/dev/input/js0".
If you change it to a "1":
joystick = pygame.joystick.Joystick(1)
it will try to connect to "/dev/input/js1" instead.

The line appears more than once in most of the scripts, you want to change all of them.

thanks ill get on that, ill let you know how i get on...
by the way i have been working on a (almost) complete script for diddyborg red. its python3, using PicoBorgRev3 it has ps3 controller with shutdown, epo reset, take picture, start recording, stop recording and set/unset auto mode buttons (auto mode doesnt do anything right now, im planning on having it control diddyborg using just the ultrasound sensors but ive only got one (3 on order from you guys) and ive only just started looking at it)

would you like me to attach a copy for your use? it uses diddyredjoyball.py as its back bone just modified slightly.

edit:
when i was writing the above meantioned script, i had lots of errors with opencv seeing the ball, hence why i have taken it out of my version, i was using opencv 3.1.0 when debugging i noticed the one of the lines would error on unpacking variables, unpacking 3 into only 2 supplied varibles. i fixed this error but since then the ball would only be seen if directly infront of the camera, about 3 inches away. has any of this been tested on python3 or am i in new territory?

piborg's picture

As you have probably guessed we have not really done any testing with Python 3.
It is actually quite hard to keep everything working with both 2 and 3, so we made a choice and stuck with the version that comes up when someone enters python in the terminal by default.

The ball following code can be a little bit fickle and lighting dependent.
This is a side effect of trying to keep the example as simple as possible :)

The line you probably need to attack is:
red = cv2.inRange(image, numpy.array((115, 127, 64)), numpy.array((125, 255, 255)))
The values are:

  1. Hue - the shade of the rainbow for the colour, runs from 0 to 180.
    It is probably most important to get this right, pure red should be around 120.
    This is represented as the circle in the colour wheel below.
  2. Saturation - lower means the colour is more grey, runs from 0 (greys) to 255 (bright colour).
    In lower light levels this will be lower than normal.
    This is represented by the position between the white / black line and the opposite corner of the triangle in the colour wheel below.
  3. Value - How bright the colour is, runs from 0 (black) to 255 (full brightness)
    In lower light levels this will be lower than normal.
    This is represented by the white / black line of the triangle in the colour wheel below.

The first set of 3 are minimums, the second set are maximums.

Images: 
piborg's picture

We would like to see your script :)

You can either attach it to a forum post (rename to .txt first) or share it using something like Pastebin or GitHub.

thanks, ill look into the opencv issue. it might be something to do with using a nightvision camera? i can imagine it wont be helping!

attached is the improved script, any issues let me know. im eager to hear if you have any improvement ideas?

update:
just remembered this obviously relies on PicoBorgRev3 and it requires a "media" folder with "pictures" and "videos" inside of that. the media folder and this script should be in the same folder

Subscribe to Comments for "ps3 ghost controller"