Using python script to attach object

Hi,
I have closed conveyor system that loops around with two sledges on the conveyor. Both sledges also have small box on them that I want to first pick up with a robot when sledge reaches sensor on the conveyor belt that stops conveyor until robot has picked the box. When both boxes are picked up I want to place them back to the sledges when they arrive to the sensor when they are empty. The problem is when I place box back to sledge it doesn’t attach to the sledge so it won’t start moving with it when the conveyor starts again. I know there is python command “robot.releaseComponent()” that would fix it but I don’t know how I would use it. I’m pretty new to visual components and python. My first idea was to make a script that would first check if the robot is holding the box and is the sledge empty and is the robot in correct position (or maybe use some variable instead of position) but I have no idea what the syntax for something like that would look like.

I think it’s easier to answer if you attach your project to your post.

You could make a reference to the ComponentContainer and use the method “grab” to put the Component into the ComponentContainer. The output port of ComponentContainer can attached to the input port of Path, if there is a Path.

From the other view, a Component has the method “transfer” which accepts (vcBehaviour, port) or (vcConnector). I think the use of a ComponentContainer is better.

I pretty much want do something like in this tutorial video: https://academy.visualcomponents.com/lessons/place-parts-on-moving-objects/
The difference between that and my project is that the object where the part is placed is stopped by sensor on conveyor belt until robot places the part. I also have already made a robot program in program tab so I would like to trigger that python script containing “robot.releaseComponent()” at specific moment (when robot is above empty sledge). I have used grap already in this project to get the sledges moving on the conveyor but I still had to attach them to it manually.

This is the old approach.

In this tutorial you learn the old techniques.
Since 4.2 VC has the Process Flow, which can also used together with a Robot.

The Process Modeling is also described.

You should get it to work without any scripts. This image describes how the releasing part works.
In image 1 you also see the grasp detection around TCP that is used for grasping the item. When releasing it is shifting the released part 25mm (by default) downwards and checking which item it is colliding with (image2). If the sledge is less than 25mm or the gravity direction value is increades (image 3) it might collide with the conveyor attaching the part to the conveyor not to the sledge. If it’s not close enough to the sledge it may not collide with anything and will remain in the “air”. In image 4 you can see where to edit the grasp and release defaults per signal action.

2 Likes

I messed around with those values and got it working, thank you! I didn’t really know how visual components works when you drop objects to other objects but now it makes sense.

1 Like