Struttering and refresh delay using python realtime control- Printable Version +- RoboDK Forum (//www.sinclairbody.com/forum) +-- Forum: RoboDK (EN) (//www.sinclairbody.com/forum/Forum-RoboDK-EN) +--- Forum: RoboDK API (//www.sinclairbody.com/forum/Forum-RoboDK-API) +--- Thread: Struttering and refresh delay using python realtime control (/Thread-Struttering-and-refresh-delay-using-python-realtime-control) |
Struttering and refresh delay using python realtime control-Kees12Programming-04-21-2023 Hello, I am trying to control a kuka using a spacemouse. I do this through roboDK and Python. I have a link between my Python script and the kuka, I can real-time control the kuka using the Python script. But I'm experiencing weird delays and stuttering. The stuttering: When I run my script unconnected to the kuka, the roboDK simulation shows pretty smooth movements. But when I connect to the kuka, it moves really weirdly. It constantly pauses and accelerates. The simulation then also stutters, following the kuka accurately. The delay: I use a 3D spacemouse, and read the values of that mouse. When I read the values of the spacemouse without a roboDK link, it works really well. No delays between my physical movement and the program variables. But my variables fail to properly update as soon as I connect to roboDK(even without a connection to the kuka). When I'm not touching the mouse, my inputs still stay high instead of going to 0. I tried putting in pauses in case I was refreshing too fast, but it only causes weird stuttering pauses and still has a read delay.
Code:
from robodk.robolink import Robolink
it's still incredibly basic, and I plan to add a lot more computing in the future. I can't imagine the software not being powerful enough to calculate and update this fast, so I must be using it wrong. The spacemouse outputs variables between -1 and 1. 0 being the passive state, it's pretty sensitive, so everything between -0.3 and 0.3 I see as an accidental movement. When I run the code, I tap the mouse and it instantly shows a correct reading. when I release the mouse, it remains at the same value for a long time, even though it should be reading 0 again. using: kuka kr10, kr c4 controller, python 3.11, pycharm IDE, roboDK, 3D spacemouse (connexion), windows, kukaproxyvar as connection method between roboDK and kuka. RE: Struttering and refresh delay using python realtime control-Sam-04-21-2023 Nice project! You are stacking MoveJ commands at a high rate while the robot is moving (blocking=False). Calling MoveJ again with the driver does not cancel the previous motion command, the robot will finish its movement. 你可以获取鼠标位置在一个单独的thread and store it in a queue. If you want to exactly trace the motion that was made with the spacemouse, then empty the queue using non-blocking MoveJs (or take one and empty the queue to have the latest). This is analog to our Game Controller. Although we are using the D-pad, and the joysticks would be closer to what you are trying to do, you might find some insights there: https://github.com/RoboDK/Plug-In-Interface/blob/master/PluginAppLoader/Apps/GameController/GameController.py |