Randomly send

Hello, I recently started learning about VC.

I want to randomly send a collaborative robot to each of the 12 compartments, as shown in the picture. The robot’s name is ‘RB3 1200’.

How should I write the Python script?
Please help me.


hi

maybe do it with a warehouse in PM:

Hi,

If you want to do it in python, you can do something like this.

robot.jointMoveToPosition(x, y, z, Rx, Ry, Rz) moves the robot to the specified coordinates.

You need the coordinates of every one of your 12 points, and complete the “if… elif…” sequence below.

from vcScript import *
from vcHelpers.Robot2 import *
import random

def OnRun():
  robot = getRobot()
  
  #get a random number between 0 and 11
  randomNumber = random.randrange(12)  

  if randomNumber == 0:
      robot.jointMoveToPosition(500,100,1000,0,0,0)
  elif randomNumber == 1:
    robot.jointMoveToPosition(600,100,500,0,0,0)
  
  #...continue until 11

Hope this helps

Thank you for your response.
Is this method how objects are generated in each locker? Could you explain it in more detail?

Thank you for your response.
I tried what you suggested, but the robot is not moving.
Could you provide more detailed guidance?

Create a flow with feeder, warehouse and sink in PM.
Transport from the warehouse to sink is handled by the robot’s transport controller.
The BufferNeedMode default value (from feeder to warehouse) is already chaotic, it is okay to leave BufferFeedMode on FIFO.
see attached example.

Randomly send.vcmx (746.4 KB)

Thank you very much for your response. I recreated the example you provided, but the can is not being generated from the locker. Could you please check if there’s something wrong?

Q2.vcmx (208.3 KB)

Did you delete the existing buffer statement in the routine and add a new one?
Don’t do that, use the buffer statement as it is available via the component from the eCatalog.

Hi,

The script looks good.
However, as you can see in the output panel, the point is too far and the robot cannot reach it, so it doesn’t move.
You need to move the robot closer to the points or move the points themselves

Thank you for your great answer. Thanks to you, I was able to solve the problem.

I have an additional question. How can I position the coordinates of P1 closer to the locker, as shown in the picture?

Thank you, I will give it a try.

you can rotate your warehouse, it seems as if the robot is trying to pick from the other side of the warehouse.

Or you can change the PickApproachDirection in the transport link:

Thanks to you, I solved the problem. I really appreciate it.