Odd behavior with Gamepad
Forums:
I am having an intermittent problem with Gamepad. My DiddyBorg has a PI 4 2Gb "brain" and when not roaming the house on its own is manually controlled by a PS3 controller and Gamepad. I last updated the RPi OS about a week ago.
Every now and again while manually driving the robot the software will stop responding to button presses from the controller. Strangely enough the axis commands from the joysticks will still function. The problem is resolved by a reboot of the Pi so I'm pretty sure it's not a problem with the controller.
The python3 script I am currently running is far too long and convoluted to post on here (with several different threads for the compass, lidar and camera) but I thought I would ask if anyone else had had this problem and could give me a pointer as to how to solve it?
piborg
Sat, 01/30/2021 - 11:53
Permalink
Button presses not responding
I have not seen that problem before, but we have seen some quirky behaviour from gamepads occasionally. The most obvious of these was a short phantom joystick reading when the gamepad had been left idle for a while, causing a quick nudge forward :(
One thought, did you try just restarting the script to see what happens?
If restarting the script on its own fixes the problem then it is probably a bug lurking in the script.
If restarting the script on its own makes no difference then the problem probably lives in either the drivers or the library which is reading the gamepad inputs.
il diavolo
Sat, 02/06/2021 - 21:02
Permalink
I've not solved this yet
Thanks for the suggestion, restarting the script rather than rebooting does fix the problem, until the next random time that it fails. I can also confirm that the controller is still sending button events when the fault occurs as I also have "qjjoypad" running in the background and that still responds to button presses. (Note that the fault first occurred before I installed qjoypad.)
As the axis/joysticks are processed by Gamepad Asynchronous mode and the buttons by Gamepad Event mode I guess that something in my code is stopping the Event mode from running in the background. It's not helped by the random way in which the fault occurs, sometimes quite soon after starting the script and other times it will run without fault.
I'll try "remming" out bits of my script that may be suspects but if you have any ideas I would be grateful.
piborg
Mon, 02/08/2021 - 13:17
Permalink
Gamepad events failing
It is possible that their might be a bug in the Gamepad library itself that we have not seen before...
Other things that might be worth checking:
removeAllEventHandlers
is being called somewhere and de-registering the event callbacks?il diavolo
Mon, 02/08/2021 - 22:06
Permalink
Thanks
Thanks piborg. I would be surprised if the problem is a bug in the Gamepad library as I have no problems when running other, earlier versions of my script. I would also discount item 2 in your list.
Items 1 and 3, however, are well worth further investigation. Strangely enough I had no problems this evening even though I spent an hour or so manually driving Diddy around recording new routes for him to follow. Of the two I suspect an unhandled exception is the most likely culprit. I shall add a few more "try - except" handlers.