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 communication of information between the threads is fast and easy, which makes multithreading very practical to control several Niryo One.
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 helps in organizing interactions between the two robots as well as the control of the Conveyor Belt and the sharing of the slope.
Each thread has an instance of the “NiryoOneClient()” class that allows it to be connected to a robot and to control it.
Threads communicate together through variables located in the mother-class “RobotsMains”.