In this example, we connect to two robots and then ask them to do a slight movement. The first robot will do the asked movement, turn to learning mode, then the second robot will do the asked movement and turn to learning mode too.
This is due to the use of move_joints() function. The program waits for the robot to end its movement to run the next line.
To make a movement on the two robots in a simultaneous way, we will use the threading library provided by default with Python.
Multithreading allows you to run several parts of the same program in parallel. It is often used to spread the load of calculations betweens several processors and to run several actions simultaneously. Thus, it will allow us to execute several commands of the Python API TPC/IP at the same time. To do so, we will create a thread for each robot.
If you don’t know multithreading yet, we invite you to read and follow the links down below:
We can now modify the program in order to run the actions of each robot in a different thread.