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

Writing messages using RunMessage() to UR5 Teach Pendant

#1
Greetings, 

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. 

Thanks!


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): 
    robot.MoveJ(home)
    robot.MoveJ(approach)
    robot.MoveL(target3)
    robot.MoveL(target4)
    robot.MoveL(target5)
    robot.MoveL(approach)

    i = i + 1

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

More information here:
https://robodk.com/doc/en/PythonAPI/robo...nstruction

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:
https://robodk.com/download
#3
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:/Prog5.py", 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)
#4
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)