GoPiGo3 PyGame and PS3

pygame

#1

When attempting to run a PS3 Controller script on the GoPiGo3 with DexterOS, I get an error thrown by pygame.event.get() (the line which causes pygame to pull an update from the controller): pygame.error: video system not initialized. I checked, and I am calling pygame.init() (which is the usual culprit of this error). Ok, not a problem, the video library did not initialize properly. Therefore, I added pygame.display.init() to my code. PyGame then raised a different error: pygame.error: unable to raise a console terminal. The program is being launched by calling either python ps3Controller.py or python3 ps3Controller.py from a terminal session in the browser GUI under http://mygopigo.com/python. Upon checking the provided files ps3.py and ps3_gpg_example.py, and updating them to the current python syntax, I noted that they also use the pygame.event.get() function call. Based on what I’ve seen, I believe this to be a DexterOS issue with pygame integration (as several years ago, pygame did not need the display module for pygame.event.get() to work). Perchance has a workaround been developed, or a different way to launch the program, which allows pygame to function properly?

An additional note: I have considered using Raspbian and loading all of the required modules (and have in the past, though getting proper integration with the GoPiGo3 board is a pain), however, these robots that I have are being used as teaching tools, and therefore the administration would prefer that we stay on DexterOS. Due to this, I would prefer to keep development of demos in DexterOS to maintain all the robots in the proper configuration for classroom use.


#2

Hi @AzureUmbra,

I’ve got 2 things to tell you:

  1. The last time we looked at the PS3 controller script, things didn’t turn out so well - the problem with it is that it no longer works on the Raspberry Pi and there’s really no support coming for the controller to make it work again. If I remember correctly, the synchronization between the Pi and the controller no longer occurs.

  2. I don’t think the pygame package was meant to be used within a GUI terminal. There’s no window that it can launch and hence that initialization is going to fail. We mainly added it to be able to access the microphone within Python.

Here’s the documentation I found about this initialization method. By reading this I understand that the application needs some sort of permissions to open up a window, or at least embed it into an existing window. On DexterOS, you don’t get this capability:
https://www.pygame.org/docs/ref/display.html#pygame.display.init

Thank you!