Python Program Generation Issues (UR)- Printable Version +- RoboDK Forum (//www.sinclairbody.com/forum) +-- Forum: RoboDK (EN) (//www.sinclairbody.com/forum/Forum-RoboDK-EN) + - - -论坛:通用RoboDK问题(//www.sinclairbody.com/forum/Forum-General-questions-about-RoboDK) +--- Thread: Python Program Generation Issues (UR) (/Thread-Python-Program-Generation-Issues-UR) |
Python Program Generation Issues (UR)-robo.senn-06-13-2018 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 RE: Python Program Generation Issues (UR)-Albert-06-15-2018 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/robolink.html#robolink.Item.RunInstruction And a more complete example here: //www.sinclairbody.com/doc/en/PythonAPI/examples.html#offline-programming-with-gui RE: Python Program Generation Issues (UR)-robo1973-07-03-2022 Program1 is in >>>. py How do I put progrma1.py in .script? to be available for the UR3 robot?
Code:
def Extruder_E():
|