Welcome to DOFBOT-Pi repository
12.Synchronous action
Two Robotic Arms Synchronous Action
I. Communication Principle
The principle of this experiment is to use one robotic arm as a server, starting TCP network service to receive data and execute operations; while the other robotic arm acts as a client, which is the controller, reading all servo angle values sequentially, then immediately sending all servo angles to the server through TCP service. At this time, the client continuously and quickly reads servo angle values and sends them to the server. The server receives and sets to immediately update all servo angles, thereby achieving the function of remote synchronous action between two robotic arms.
II. Pre-Experiment Preparation
- This experiment involves two robotic arms with identical hardware. Except for the different running programs, everything else can be the same. If the robotic arm uses the factory default system image, please first stop the auto-starting factory main program before conducting this experiment.
- Ensure that both robotic arms are connected to the same local area network, i.e., connected to the same router (wired or wireless connection is acceptable), and can communicate within the local area network.
- Since this experiment involves two robotic arms, to easily distinguish them, we call the robotic arm acting as the server as Arm A (the controlled side), and the robotic arm acting as the controller as Arm B (the freely movable side). Since the movement of Arm A depends on the movement of Arm B, to avoid excessive movement range of Arm A when the program just starts, it is best to adjust both Arm A and Arm B to the vertical upward state before starting the program.

III. Program Code
- Start Docker
After entering the main board desktop, open a terminal and run the following command to start the corresponding Dofbot container:
./Docker_Ros.sh
【Server Code: Arm A】
For specific code, please see the content in the following path:
xxxxxxxxxx/root/Dofbot/3.ctrl_Arm/12.sync_movement/A_arm_follow.py
【Client Code: Arm B】
For specific code, please see the content in the following path:
xxxxxxxxxx/root/Dofbot/3.ctrl_Arm/12.sync_movement/B_arm_ctrl.py
IV. Operation Experiment and Experiment Purpose
Experiment Purpose: Use Arm B to remotely control Arm A.
- Enter the container terminal of Arm A and run the A_arm_follow.py program. Then note down the printed IP address.
xxxxxxxxxxcd /root/Dofbot/3.ctrl_Arm/12.sync_movement/python3 A_arm_follow.py

- Enter the container terminal of Arm A, replace the IP address noted in the previous step to the IP address position in B_arm_ctrl.py.

- After modification is complete, save and exit, then enter the container terminal of Arm A and run the B_arm_ctrl.py program.
xxxxxxxxxxpython3 B_arm_ctrl.py

Note that you must first run the A_arm_follow.py program of Arm A, then run the B_arm_ctrl.py program of Arm B. The Arm B terminal will print connection information and print sent data, and the communication between the two robotic arms officially begins.
At this time, you can see that the state of Arm A is the same as the state of Arm B, and you can modify the posture of Arm A by moving the posture of Arm B. Through this TCP transmission command, the effect of synchronous action between two robotic arms can be achieved. The control of Arm A has angle limitations, while Arm B's automatic movement has no angle limitations. If servo 1 of Arm B is moved beyond 180 degrees, Arm A will stay at 180 degrees until the angle of Arm B is adjusted back to a reasonable range before it can continue moving.