Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

Writing messages using RunMessage() to UR5 Teach Pendant


I started playing with the Python API today. It's great! I was curious how to get the RDK.RunMessage() function correctly with our UR5 teach pendant.

Is this a matter of creating a definition in the UR post processor? It also looks like the UR Script API has a function called popup() which writes a message to the teach pendant. I am just to write a simple 'Hello World' message for right now. 

Any insight would be a great help. Below is the simple python code I've been experimenting with so far. 


from robolink import *    # RoboDK API

from robodk import *      # Robot toolbox
RDK = Robolink()

RDK.RunMessage('Hello world', message_is_comment = True)   #Writes to teach pendant

robot = RDK.Item('UR5')

home = RDK.Item('Home')
approach = RDK.Item('Approach')
target3 = RDK.Item('Target 3')
target4 = RDK.Item('Target 4')
target5 = RDK.Item('Target 5')

i = 0
while (i < 5): 

    i = i + 1

RDK.RunCode('Prog2', True) 
You can do the following:
    robot.RunInstruction("Your popup message (pause execution)", INSTRUCTION_SHOW_MESSAGE)

More information here:

the robot variable can also be a program generated using AddProgram.

So you can do things like:
program.RunInstruction('Setting the spindle speed', INSTRUCTION_COMMENT)
program.RunInstruction('SetRPM(25000)', INSTRUCTION_INSERT_CODE)
program.RunInstruction('Done setting the spindle speed. Ready to start!', INSTRUCTION_SHOW_MESSAGE)
program.RunInstruction('Program1', INSTRUCTION_CALL_PROGRAM)  

Make sure to update RoboDK as this has been improved recently:
Thank you for the response, Albert. For whatever reason, I keep getting this error when I attempt any RunInstruction() functions: 

Traceback (most recent call last):
  File "E:/", line 12, in <module>
    robot.RunInstruction("Your popup message (pause execution)", INSTRUCTION_SHOW_MESSAGE)
AttributeError: 'Item' object has no attribute 'RunInstruction'

Eventually I would to write RobotIQ gripper calls to the generated code, but I am not having luck with these basic calls. Any help would be appreciated. 

from robolink import *    # RoboDK API

from robodk import *      # Robot toolbox
RDK = Robolink()

robot = RDK.Item('UR5')

robot.RunInstruction("Your popup message (pause execution)", INSTRUCTION_SHOW_MESSAGE)
robot.RunInstruction('Setting', INSTRUCTION_COMMENT)
I'm sorry this created confusion. If you installed RoboDK a few weeks ago this function was called:
   robot.RunCodeCustom('Code or function', instruction_type)

The latest version of RoboDK keeps both versions (RunCodeCustom and RunInstruction) for backwards compatibility.

Users browsing this thread:
1 Guest(s)