Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python API: setDO and waitDI cause crash
#1
Hi,
I would like to set digital input or output instructions using the API, but RoboDK keeps crashing when I try.
For testing purposes I created a program which contains program calls (see attachment). These program calls trigger a python script and the python script is supposed to manage the IO instructions. Here is the python code:

Code:
from robolink import *

RDK = Robolink()

itemtype = 2
robot=RDK.Item('KUKA KR 6 R900',itemtype)

io_var = 6
io_value = 1

robot.setDO(io_var,io_value)
The robot is connected and in general the IO instructions work fine, but not if they are excecuted by the python script. For some reason RoboDK can not handle the instructions that way. Is this procedure not supported by RoboDK or is it my programming that is wrong? Please let me know if I left something unclear.


Attached Files Thumbnail(s)
   
Best regards
David
#2
Hi David,

This is supposed to work. I was unable to reproduce the crash.

If you want to manipulate inputs/outputs on the robot (Run on robot option) you can trigger robot.Connect() before you operate on the robot variable.

Another option would be to add this snippet of code to force changing the run mode if you are connected to the robot:

Code:
status, message = robot.ConnectedState()
if status == ROBOTCOM_READY:
# RDK.setRunMode(RUNMODE_RUN_ON_ROBOT)
   robot.Connect() # this already changes the run mode

Can you provide an RDK project that reproduces your crash?

Albert
#3
Hi Albert,
that could already be the solution. I do not call robot.Connect() or RDK.setRunMode in the python script because the robot is already connected via the GUI and I expected that to be sufficient. I will try your fix tomorrow and get back here with the results.
Thanks a lot.
Best regards
David
#4
I have tried several versions, but none of them is working. The attached RDK project contains five programs that call five slightly different python scripts, all of them cause RoboDK to crash. Please note that I changed your suggested code from RUNMODE_RUN_ON_ROBOT to RUNMODE_RUN_ROBOT.


Attached Files
.rdk   KRC_DO_online.rdk (Size: 318.47 KB / Downloads: 40)
Best regards
David
#5
The crash happens because the robot name you provide doesn't exist:
robot=RDK.Item('KUKA KR 6 R900',itemtype)
If you specify a name there has to be a name match (KUKA KR 6 R900 sixx in this case).

Alternatively, you can just provide an empty string:
robot=RDK.Item('',itemtype)

We just published a new update to avoid the RoboDK crash. However, you'll still get an error in your code so the easiest will be to just provide an empty string when you get the robot.
#6
Sorry for bothering you with that and thank you for looking into the issue. In every other script I got this correct but obviously did not copy paste it in this case...
Best regards
David
  




Users browsing this thread:
1 Guest(s)