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

Python Program Generation Issues (UR)

#1
Hi all,

Perhaps someone could help me figure this out. I've successfully written a simulation for pass/fail testing using only python. My next step is to trigger the logic using our UR5s DIO, but I can't seem to generate anything other than movements using the UR posts.

Specifically, I get only basic movements and none of the if/else logic, UR-specific commands or defined variables, etc.

I have tried all of the UR5 posts available in RDK, and it's still the same story.

Here is a quick example of what I'm seeing:

Snippet Python code:

from robolink import * # RoboDK API

from robodk import * # Robot toolbox
RDK = Robolink()
program = RDK.Item('IO_moveTest')

robot = RDK.Item('UR5')

approach_0 = RDK.Item('ap0')
approach_1 = RDK.Item('ap1')

def unitTest_IO():
global unit_pass_pin # passed unit digital pin
unit_pass_pin = 0

def getUnit():
RDK.RunMessage('Getting Unit', message_is_comment = False)

def testUnit():
program.waitDI(unit_pass_pin, 1)
robot.MoveL(approach_0)

unitTest_IO()
getUnit()
testUnit()

The generated Program using the UR Script post:

def IO_moveTest():

# Default parameters:
global speed_ms = 0.300
global speed_rads = 0.750
global accel_mss = 3.000
global accel_radss = 1.200
global blend_radius_m = 0.001

# Add any suprograms here
# Main program:
# Program generated by RoboDK v3.4.6 for UR5 on 13/06/2018 10:55:28
# set_reference(p[0.000000, -0.500000, 0.000000, 0.000000, 0.000000, 0.000000])
set_tcp(p[0.000000, 0.000000, 0.247000, 0.000000, 0.000000, 0.000000])
movel(p[0.080000, -0.580000, 0.100000, 0.000000, 3.141593, 0.000000],accel_mss,speed_ms,0,0)
# End of main program
end

IO_moveTest()

As you can see, none of my function calls, variables, or UR-commands appear in the generated script.
Any insight would be wonderful. Could there be something in RDK settings that I've missed?

Thanks!
Steve
#2
You should use:
robot.RunInstruction("Program1", INSTRUCTION_CALL_PROGRAM)

Other Examples:
robot.RunInstruction('Setting the spindle speed', INSTRUCTION_COMMENT)
robot.RunInstruction('SetRPM(25000)', INSTRUCTION_INSERT_CODE)


You can use RunInstruction on a robot item or a program item. If you call it on a program it will add the appropriate instruction as if you selected Program-Program Call Instruction, if you call it on a robot it will add appropriate code when generating your code.

More information here:
//www.sinclairbody.com/doc/en/PythonAPI/robo...nstruction

And a more complete example here:
//www.sinclairbody.com/doc/en/PythonAPI/exam...g-with-gui
#3
Program1 is in >>>. py How do I put progrma1.py in .script? to be available for the UR3 robot?

Code:
def Extruder_E():

#--------------------------


# Main program:
# Program generated by RoboDK v5.4.3 for UR3 on 03/07/2022 15:11:12
# Using nominal kinematics.

Extruder() <<
/ / / / /我pythone子程序,运行在RoboDK want to run a program on the robot


# End of main program
end

Extruder_E()




Users browsing this thread:
1 Guest(s)