7.3 TCP Socket Remote Control
TCP Socket mode runs the Python client on a PC. The UNO Q service receives client commands and communicates with the robot through Bridge RPC. Install Python 3 and a pymycobot version containing MyCobot280Socket on the PC before use.
1. PC Python Environment
Windows
- Install Python 3 from python.org and select Add Python to PATH.
- Confirm the environment:
python --version
python -m pip --version
- Create a virtual environment and install pymycobot:
python -m venv .venv
.venv\Scripts\activate
python -m pip install --upgrade pip
python -m pip install --upgrade pymycobot
macOS / Linux
python3 --version
python3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install --upgrade pymycobot
Verify the Client Class
python -c "from pymycobot import MyCobot280Socket; print('MyCobot280Socket ready')"
Do not use the board-side unoq_bridge=True initialization on the PC.
2. Check the UNO Q Service
Run these commands in the UNO Q terminal:
hostname -I
systemctl is-active mycobot-server.service
ss -lntp | grep ':9000'
The service must show active and port 9000 must listen. Select a UNO Q address on the same subnet as the PC; do not use 0.0.0.0 as a client destination.
For a service failure, view logs:
systemctl status mycobot-server.service --no-pager
journalctl -u mycobot-server.service -n 100 --no-pager
3. Check the Network
Keep the PC and UNO Q on the same trusted LAN. On Windows, test the port:
Test-NetConnection UNO_Q_IP -Port 9000
For macOS or Linux, use an available network utility to check UNO_Q_IP:9000. If it is unreachable, resolve the IP address, network isolation, firewall, or UNO Q service state first.
4. Connect from the PC Client
Replace UNO_Q_IP with the actual UNO Q address. Save this as uno_q_socket_test.py and start with a read-only test:
from pymycobot import MyCobot280Socket
mc = MyCobot280Socket("UNO_Q_IP", 9000, debug=True)
print("version:", mc.get_system_version())
print("angles:", mc.get_angles())
Run it in the PC virtual environment:
python uno_q_socket_test.py
After successful reads, run only a confirmed-safe motion command:
mc.send_angles([0, 0, 0, 0, 0, 0], 30)
5. Usage Limits
- The service processes one client at a time; do not connect multiple control clients simultaneously.
- Exit the TCP client normally before switching to App Lab or a board-side script.
- Never expose port 9000 to the public internet.
- Use debug=True for troubleshooting and turn it off for performance measurements.
- Before restarting the service, confirm that no program is controlling the robot:
sudo systemctl restart mycobot-server.service
systemctl status mycobot-server.service --no-pager
Previous: Python Development | Chapter Home | Next: Gamepad Control