Visual Components' Community

New Thinking for Factory Simulation
Welcome to Visual Components' Community Sign in | Help
in Search

CONTROL "PATH" and EVENTS USING PYTHON

Last post ti, loka 7 2008 9:45 by leonarul. 0 replies.
Page 1 of 1 (1 items)
Sort Posts: Previous Next
  • ti, loka 7 2008 9:45

    CONTROL "PATH" and EVENTS USING PYTHON

    Component creator and "PATH" are commonly use for interfacing and etc. I just want to share the idea that i got when using the python.

    Suppose we have a rotary plate that will rotates on once an "object" enter the path or trigger at the origin. The rotary plate will then rotates. The problem that i faced

    before is how to trigger the rotary plate using python. The code is like below which i build according to training #8 and and training #4 under the reseller portal:

    #THIS PROGRAM IS USE TO ENABLE THE ROTARY PLATE

    from vcScript import *

    def OnRun():
      time1=3.0 #define delay
      # Get handles to needed behaviours
      path = getComponent().findBehaviour("One-WayPath")
      servo = getComponent().findBehaviour("ServoController")
      inout_signal = getComponent().findBehaviour("BooleanSignal")
     
      # Main loop
      while True:
        
        # Turn path on
        path.Enabled = True
        path.CapacityAvailable = True

        # Wait for component to arrive
        triggerCondition(lambda: getTrigger() == inout_signal)
       
        # Turn path off and turn the table
        path.Enabled = False
        servo.moveJoint(0,-90)
        delay(time1)
        #delay(time) #this delay will give a time for robot to pick up the product
      
        servo.moveJoint(0,-270)
       
        delay(time1)
        # Wait until component leaves and turn the table
       
        servo.moveJoint(0,0)

    i have problem to upload the picture URL.later i will upload:)

    "ENGINEERING THE NEXT BREAKTHRU"
    Filed under:
Page 1 of 1 (1 items)