TCPIP
Controlling the robot arm using TCP/IP
The user can connect the robot arm through the IP address of the robot arm, so as to achieve the effect of remote operation of the robot arm without connecting the USB port
Note: Currently only Python3 uses the robot arm in this way, provided there is a server and it has been enabled.
Action before connecting
Get Robot IP and Port
1 Get the latest Basic and Atom firmware,Burn method
2 Get Robot IP and Port
M5 version:
The display at the bottom of the robot arm selects the third Transponder--and then selects the second WLAN Server
As shown in the picture, the IP and port number of the robotic arm have been displayed
PI version:
wireless network
Click the WIFI icon, connect to WIFI, and enter the WIFI password, click the Connection Information option
wired network Network cable to connect to the network port of the robotic arm
Click Connection Information to view the current IP
Note: The robotic arm needs to be under the same network segment as the control terminal, that is, under the same WIFI
3 Download the server file Server.py through GitHub and run it on the robotic arm system
4 Open a command terminal
5 Enter the following code to run the script:
python Server.py
The operation is successful as shown in the figure:
socket control
connect(serialport, baudrate, timeout)
- function: Connect the robotic arm via serial port and baud rate(For PI version)
- parameter
serialport
: (str
) default/dev/ttyAMA0
。baudrate
: Baud rate default1000000
timeout
: default0.1
。
Example:
from pymycobot import MyCobotSocket
# Use port 9000 by default
# Where "192.168.10.22" is the IP of the robot arm
mc = MyCobotSocket("192.168.10.22","9000")
#The Raspberry Pi version needs to enter the connect function, the default value is ("/dev/ttyAMA0", "1000000"):
#Not required when the machine model is M5 version
#mc.connect()
#After the connections is normal, the robot arm can be controlled.
res = mc.get_angles()
print(res)
mc.send_angles([0,0,0,0,0,0],20)
...