Welcome to DOFBOT-Ultra repository
12. Two DOFBOT Synchronized Actions
12. Two DOFBOT Synchronized Actions
Note: This experiment requires two robotic arms.
12.1 Communication Principle
The principle of this experiment is to set one robotic arm as a server,开启ing a TCP network service to receive data and execute operations, while the other robotic arm acts as a client (controller), sequentially reading the angle values of all servos and immediately sending them to the server via TCP. The client continuously reads the servo angle values at high speed and sends them to the server. The server receives and immediately updates all servo angles, thus achieving remote synchronized action between the two robotic arms.
12.2 Preparation Before Experiment
- This experiment involves two hardware-identical robotic arms. Except for the programs running on them, everything else can be the same. If the robotic arms use the factory system image, please terminate the auto-starting web control program backend process before proceeding with this experiment.
- Ensure both robotic arms are connected to the same local network (connected to the same router, either wired or wireless) and can communicate within the LAN.
- Since this involves two robotic arms, for easy distinction, we call the server arm Arm A (the controlled party) and the controller arm Arm B (the freely movable party). Since Arm A's movements depend on Arm B's movements, to avoid excessive range of motion for Arm A when the program starts, it is best to adjust both Arm A and Arm B to a vertical upward state before starting the program.

12.3 Program Code
[Server Code: Arm A]
Please refer to the following path for the specific code:
~/dofbot_ctrl/scripts/12.sync_movement/A_arm_follow.py
[Client Code: Arm B]
Please refer to the following path for the specific code:
xxxxxxxxxx~/dofbot_ctrl/scripts/12.sync_movement/B_arm_ctrl.py
12.4 Experiment Operation and Objective
Experiment Objective: Use Arm B to remotely control Arm A.
- Open the terminal of Arm A and run the A_arm_follow.py program. Note down the printed IP address.
xxxxxxxxxxcd ~/dofbot_ctrl/scripts/12.sync_movement/python3 A_arm_follow.py

- Open the terminal of Arm B and replace the IP address in B_arm_ctrl.py with the one noted down in the previous step.

- After modification, save and exit, then run the B_arm_ctrl.py program.
xxxxxxxxxxcd ~/dofbot_ctrl/scripts/12.sync_movement/python3 B_arm_ctrl.py

Note: Always run Arm A's A_arm_follow.py program first, then run Arm B's B_arm_ctrl.py program. Arm B's terminal will print connection information and display the sent data, and the communication between the two arms officially begins.
At this point, you can see that Arm A's state is the same as Arm B's state. By moving Arm B's posture, you can modify Arm A's posture accordingly. Through this TCP command transmission, the two robotic arms achieve synchronized motion. Arm A has angle restrictions when being controlled, while Arm B moves freely without angle limits. If Arm B's servo 1 is moved beyond 180 degrees, Arm A will stay at 180 degrees until Arm B's angle is adjusted back to a reasonable range before it can continue moving.