How to simulate a production line in multi-robot (threading)?
In this article, you will learn how to use two or more Ned2 in order to create a production line.
Which devices are needed to operate this feature?
You’ll need two Ned2, the vision set and its workspace, the large gripper, the vacuum pump, some pawns and the conveyor belt and a slope.
1. How to set-up/prepare my hardware?
2. How to set-up/prepare my software?
3. How does the process work?
4. Does each robot have his own thread?
5. Can I change the settings of the product line?
How to set-up/prepare my hardware?
First, you need to attach the front of the Conveyor Belt to the first Ned2 and plug the large gripper.
Then, plug the Vacuum Pump to the other Ned2, which is at the back of the Conveyor Belt. Set the slope midway between the two Ned2 and attach the four landmarks of the workspace at the front of the Conveyor Belt, in front of the first Ned/Ned2.
Finally, calibrate the workspace.
How to set-up/prepare my software?
For the first launch, you need to give six positions to the program with the Learning Mode activated (press Enter to confirm a position). Here are the positions (please use the same order):
- Front Ned2:
- The observation pose in which Ned2 can see the 4 landmarks of the workspace.
- A position of a few centimeters above the slope (at the top of the slope).
- The position from which the robot can drop the pawn on the slope.
- Back Ned2:
- The position from which the robot can grab the pawn at the bottom of the slope.
- A position a few centimeters above the previous position.
- A position at the back of the Conveyor Belt where the robot can drop the pawn (in front of the second Ned2).
Those 6 positions will be stored in a file named data.txt.
How does the process work?
Once you’ve done the set-up, the Conveyor Belt will start moving, the front Ned2 will wait for a pawn to appear in its workspace. Once a pawn is seen, the Conveyor Belt will stop, the front Ned2 will pick it and place it in the slope, while the Conveyor Belt starts again. Then, the back Ned2 will pick this pawn at the bottom of the slope, and put it back on the Conveyor Belt.
Multithreading allows us to perform several parts of the same program in parallel. You can then perform multiple instructions simultaneously within the same process. The exchange of information between threads is fast and easy, which makes multithreading very practical to control several Ned/Ned2 at the same time.
Does each robot have his own thread?
Yes, the program’s main thread launches a thread for each robot to control. Threads communicate with each other through shared variables and with the class threading.Event().
This way, the interactions between the two robots are possible as well as for the control of the Conveyor Belt and the sharing of the slope. Each thread is connected to a robot and controls it. Threads communicate together through variables located in the mother-class RobotsMains.
Can I change the settings of the product line?
Sure, you can change the Conveyor Belt speed with the conveyor_speed variable in the robot.py file.
You can also change the distance between the pawns with the conveyor_place_interval variable.
Finally, you can change the width of pawns’ distribution on the Conveyor Belt with the rand_drop variable.