Combining Tool with a Product Creator

Hello everyone,

I am currently trying to combine or rather include a product creator and a container with a tool I mounted onto a robot. The task the robot is suppose to carry out is to place a nut as well as a disc onto a screw and that multiple times. So my idea was to include a product creator within the tool and generate at the start of the sim a certain amount of components as a stack. Then, as the robot goes from screw to screw, the robot should release the nut and the disc. Until now I have added a product creator and a container where the nuts and the discs are stored temporarily. The components are generated at a designated frame.

The problem is, that although the product creator generates the components at the frame I placed, the tool is not able to release the component on command. Can anyone help me with that? :slight_smile:

Best
maru

hi maru, can you share your file?

Hey Jesper,

thank you very much for replying. :slight_smile:
Unfortunately, some parts within my sim are under NDA so its not really a possibiliy for me to publish it here in the forum.

I revisited my idea and now integrated a product creator with the tree of the robot and connected the product creator with the grasp container, which will spawn or generate the desired component at a frame I possitioned at the TCP. The problem still remain unfortunately, that my robot still can’t release the component when I set the signal [1] for grasp/release to false. I somehow have to get the component connected to one of the tool frames or the TCP itself for the robot to release the component. If I am wrong please correct me.

Maybe this helps somehow to understand my problem better.

Best
maru

Hi,

The reason for the robot being unable to release on signal 1 is most likely because it didn’t successfully grab it with signal 1 in the first place (via the program tab). This could be due to the generated product already being on the container, or robot grasp detection volume simply missing its target.

The signals 1-99 are inherently quite related to the action script itself that you can take a look at your installation folder. The short explanation on how it works is that it remembers the tool names and maps them to the product. Everything is more or less placed on the same container because the capacity is 9999 or so, meaning the system just has to remember what tool grabbed which part.

Skipping some of the “grasp/release” steps may or may not cause the whole action script to not activate on some situations which unfortunately seem to be what is causing your issue. There are, however, some workarounds that might work.

What I would suggest that once you generate your product, immediately grab the product to the correct container with python. Then in order to release with the correct “tool” we could listen to the internal signals you send with the robot in the program tab. For example, once you send signal 1, we can release everything associated with tool 1. The association needs to be constructed on your side though.

I have generated a simple example layout to showcase how to listen to internal signals and how to grab a static product as well as how to extend the events to obtain more variables (such as strings which can be tool names). If it’s enough to work with one tool only, the logic can be quite simple.

  1. You grab the generated product with python
  2. You generate code to listen to signals
  3. You release/grasp based on the listened signal

Please see the attached .vcmx. It will grab naturally first, wait for 5 seconds and then steal the product from the tool into the end effector of the robot (you can see this if you remove the tool). The commented part of the code shows how to extend events to push in more arguments if needed.

br,
lefa
container_swap.vcmx (758.6 KB)

Hey Lefa,

thank you very much for your detailed answer. It really helps alot. :slight_smile:
I will try your recommendation and have a look if it is applicable.
I also had a look at the action script and tried some code, but for now it didn’t really work.
I have high hopes that your solution will work. If not I will post it here.

Best regards
maru

Hey Lefa and everyone else that might stumble upon this thread,

so I tried your method, but couldn’t really use it for my case.
But, after working on that problem now for a couple of hours I found the final solution for my specific problem.
I tried this before but back then I must have done something wrong or otherwise.

What I did is I added a component creator and a component container to the tool.
The output of the creator is connected to the input of the container as it should and the container is located at a frame I placed where the TCP is located.
Now, I also added a python script with the following code:

from vcScript import *

comp = getComponent()
app = getApplication()
sim = app.getSimulation()

world_container = sim.World.getBehavioursByType(VC_CONTAINER)[0]
local_cont = comp.findBehaviour("ComponentContainer")

creator = comp.findBehaviour("ComponentCreator")

frame = comp.findFeature("Origin")

  
def OnSignal( signal ):
  if signal.Type == VC_BOOLEANSIGNAL:
    if signal.Name == "screw_signal" and signal.Value == True:
      creator.Limit = 1
      part = creator.create()
      if part: # test if part creation was successful
        local_cont.grab(part)
        part.PositionMatrix = frame.NodePositionMatrix
        world_container.grab(part)
        creator.Limit = 0
      else:
        print("Part not detected. Most likely creation failed!")

      signal = False


def OnStart():
  creator.Interval = 0 #Defines the interval (in seconds) for creating components.
  creator.Limit = 0 #Defines the maximum number of components that can be created by creator during a simulation.
  
  '''
  Tip: Set the Limit property to zero in order to disable
  the internal logic of the creator.
  
  '''

Screenshot 2025-01-30 151546

So what’s happening here?

First as the sim starts I set the limit of the creator to 0 as it is advised.
I also set the interval to 0, as I only what to generate one component at the time.
If the signal is triggered, the signal function will automatically be triggered as well and first sets the limit to 1, because I want to create one part.
The created part then is grabed by the container and the position is adjusted accordingly.
After creating the component and assigning the component to the container the component will be immediately by graped by the world or rahter be released at the position the component is generated.
In the end the limit is reseted and the signal is turned off.
By combining the signal to the robot it is possible to create a part or component on command at the position of the TCP and release it immediately.

I will open a new forum thread and ask there if some admin can explain to me why the limit has to be set to 0, because it is not obvious to me.

Best regards
maru