monsterJoy video system not initialised

Second problem now. I got my controller and connected it.

I have then tried to start runMonsterJoy.py and I get the following error:

Loading ThunderBorg on bus 1, address 15
Found ThunderBorg at 15
ThunderBorg loaded on bus 1
Battery monitoring settings:
Minimum (red) 6.98 V
Half-way (yellow) 21.00 V
Maximum (green) 35.02 V

Current voltage 13.95 V

Waiting for joystick... (press CTRL+C to abort)
Joystick found
Press CTRL+C to quit
Traceback (most recent call last):
File "/home/pi/monsterborg/monsterJoy.py", line 120, in
events = pygame.event.get()
pygame.error: video system not initialized

piborg's picture

Unfortunately this is a bug with pygame where some versions need an extra call to make them work without a GUI.

Fortunately it is very simple to fix :)

Open monsterJoy.py and look for this line:

#pygame.display.set_mode((1,1))

Remove the # symbol so the line is run:

pygame.display.set_mode((1,1))

Thank you for the response.

Unfortunately that just gave me a different error:


Traceback (most recent call last):
File "./monsterJoy.py", line 77, in
pygame.display.set_mode((1,1))
pygame.error: Unable to open a console terminal

I guess this has something to do with it being run headless through SSH.

piborg's picture

We have seen problems using SSH before as well...

Try this alternative pygame setup code instead:

# Setup pygame and wait for the joystick to become available
TB.MotorsOff()
TB.SetLedShowBattery(False)
TB.SetLeds(0,0,1)
os.putenv('SDL_VIDEODRIVER', 'fbcon')
pygame.display.init()
pygame.init()
print 'Waiting for joystick... (press CTRL+C to abort)'

If you get a permission error you might have to run the script with sudo as well.

Unfortunately I seem to get the same error:

pi@thunderborg:~/monsterborg $ ./runMonsterJoy.sh
Loading ThunderBorg on bus 1, address 15
Found ThunderBorg at 15
ThunderBorg loaded on bus 1
Battery monitoring settings:
    Minimum  (red)     6.98 V
    Half-way (yellow)  21.00 V
    Maximum  (green)   35.02 V

    Current voltage    13.70 V

Traceback (most recent call last):
  File "/home/pi/monsterborg/monsterJoy.py", line 76, in 
    pygame.display.init()
pygame.error: Unable to open a console terminal
piborg's picture

Try commenting out the pygame.display.init() line, it might not be needed.

piborg's picture

You could also try using this command before running the script:

export DISPLAY=:0

You might need to put the script back to the original code as well.

I had the exact same sequence of problems (video and then console). This export fixed it for me. Thanks!

Unfortunately not. Still not working.

Surely I can't be the only person having this issue. Is there no way of running the joystick control without a screen attached?

How is everyone else doing it?

piborg's picture

When we have had this problem in the past one of the above suggestions has fixed the issue :(

Unfortunately this seems to be a problem that only occurs for some people and we have not been able to figure out exactly how to stop it.

You can probably get it to work if you enable X11 forwarding on SSH. If you are using PuTTY this guide explains how: https://www.cpdforteachers.com/resources/setting-up-ssh-and-x-forwarding...

piborg's picture

we have had some discussion around the office and have a plan to make our own joystick input code without the need for pygame at all.

The good news is that this will completely remove the problem you are seeing as our code will not be trying to do anything with the screen. It just talks to the controller :)

The bad news is that I am not sure how long it will take. We have a lot of great ideas and some improvements on the existing pygame API which should make the scripts easier to understand and modify.

Hopefully when it is ready we will have a library which is focused on controllers and easier to use for people writing code for their robots.

I've had the same issue but I found this page that really got to the root of the problem and solved it for me:
https://unix.stackexchange.com/questions/58961/how-do-i-let-an-sdl-app-n...

Subscribe to Comments for "monsterJoy video system not initialised"