Grasp Trigger / Objet knows it has been grasped

Is it possible for an object/component to know it has been grasped? Is there a Grasp trigger?

In fact, in some cases, you can know whether it has been grabbed by accessing the method of the parent component of the component. Of course, I find it weird. If you just need to send a signal when it is fetched, you can use the fetch implementation component. After all, it’s easier for components to think about whether a component captures something than whether a component is captured by something.

1 Like

Thank you for the reply. My objective is to try to not modify any robot script and work strictly with grabbed objects.
I’m encountering a new issue though. When using the “OnContainerTrasnition” Event the system will execute the trigger code on positive (false to true). But when the component exits the Container the Event doesn’t execute the code until the next positive flank.

When the workpiece has been transferred, there will be another true signal, which imply leaving the previous container. The script is embed in the workpiece. Something like this. This will record each parent, sim time, and interval time. You can modify it to what you need.

from vcScript import *

def OnRun():
  travelNote.Note = "## Parent, Arrive, Interval\n"
  oldTime = sim.SimTime

def recordTraveling(container, arrive):
  if arrive:
    parent = container.Parent
    if parent.Type == VC_NODE:
      component = parent.Component
    elif parent.Type == VC_WORLD:
      component = parent
    elif parent.Type == VC_COMPONENT:
      component = parent
    global oldTime
    newTime = sim.SimTime     
    travelNote.Note += "%s, %s, %s\n" % (component.Name, round(newTime, 2), round(newTime - oldTime, 2))
    oldTime = newTime

oldTime = 0.0
comp = getComponent()
sim = getSimulation()
comp.OnContainerTransition = recordTraveling
travelNote = comp.findBehaviour("TravelNote")  
1 Like

Thanks for the reply. I’ve been using this and it works when transferring to another component with a container, such as a conveyor, but I cannot seem to release it to World. Even if the robot has the “Release to World” property selected. Is there a way to force releasing to World, or is there a different global event available?

It seems that it’s related to robot, do you have sample layout?

Sure, it is based on KUKA.Sim and using catalog robots.
Sample.vcmx (16.8 MB)
These robots have a PropertyTab called SignalActions where you can select a “ReleaseToWorld” property. I have checked the robot ActionScript and it seems like it should be able to release to world by defining the release node as Simulation.World.

@DMartyn I checked, it seems that workpiece is attach to world node, but not container, I think that’s why it’s not detected, also tried OnNodeTransform, still could not detect it.

I can only think of 2 workaround right now, add extra python script in the robot, then you don’t need to modified the existed python script, create a add-on for it, execute the add-on to create extra python script, this can get precise sim time, the other one would be OnSimulationUpdate, check workpiece parent all the time, when parent become ROOT, update message to the note, I guess it will be necessary to prevent repeated messages.

1 Like