Inconsistent joystick operation in application
Ältere Kommentare anzeigen
Hi,
I've got a MatLab application (i.e. Matlab source code not a model) and want to use an X-Box controller to control various features. I open the connection using vrjoystick and then use read on a regular basis to get the values. The strange bit is that it only works reliably when I put a breakpoint somewhere in the loop.
I have a number of tabs to display different items and only one tab is using the joystick data. If I put a breakpoint in and then remove it the display updates fine as I move the joysticks. If I change to a different tab and then change back to the original tab the joystick doesn't provide any inputs until I add/remove a breakpoint.
I've tried closing and opening vrjoystick each time but that makes things worse. I get no values in my program, but I do get values when doing a read from the console.
The joystick is in it's own class and updates data in the MVC way, so is only indirectly connected to the tabs.
Any ideas would be gratefully appreciated.
Thanks in advance
Adrian
I've got sample code that shows the problem. Running this just shows 0 even when moving the left joystick horizontally. Adding a breakpoint and then re-running then shows the value changing with the stick movement.
fig = uifigure;
steer = uieditfield(fig, "numeric");
controller = vrjoystick(1);
while true
[ca, cb, cp] = read(controller);
steer.Value = double(ca(1));
pause(0.2);
end % while
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Polygons finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!