Welcome to myCobot 320 Arm repository
6.Use Cases
Use Cases
1 Controlling RGB Light Panel
xfrom pymycobot.mycobot320 import MyCobot320import time
# The above needs to be written at the beginning of the code, which means importing the project package
# MyCobot320 class initialization requires two parameters:# The first is the serial port string, such as:# linux: "/dev/ttyUSB0"# or "/dev/ttyACM0"# windows: "COM3"# The second is the baud rate:# M5 version is: 115200## Example:# mycobot-M5:# linux:# mc = MyCobot320("/dev/ttyUSB0", 115200)# or mc = MyCobot320("/dev/ttyACM0", 115200)# windows:# mc = MyCobot320("COM3", 115200)
# Initialize a MyCobot320 object# Create object code here for windows versionmc = MyCobot320("COM13", 115200)
i = 7# loop 7 timeswhile i > 0: mc.set_color(0, 0, 255) # blue light on time.sleep(2) # wait for 2 seconds mc.set_color(255, 0, 0) # red light on time.sleep(2) # wait for 2 seconds mc.set_color(0, 255, 0) # green light on time.sleep(2) # wait for 2 seconds i -= 12 Controlling Arms to Move Them to Starting Point
xxxxxxxxxxfrom pymycobot.mycobot320 import MyCobot320
mc = MyCobot320("COM3", 115200)
# Check whether the program can be burned into the robot armif mc.is_controller_connected() != 1: print("Please connect the robot arm correctly for program writing") exit(0)
# Fine-tune the robotic arm to ensure that all the bayonets are aligned in the adjusted position# Subject to the alignment of the mechanical arm bayonet, this is only a casemc.send_angles([0, 0, 0, 0, 0, 0], 30)3 Single-Joint Motion
xxxxxxxxxxfrom pymycobot.mycobot320 import MyCobot320import time
mc = MyCobot320('COM3', 115200)
# Robotic arm recoverymc.send_angles([0, 0, 0, 0, 0, 0], 40)time.sleep(3)
# Control joint 3 to move 70°mc.send_angle(3, 70, 40)time.sleep(3)
# Control joint 4 movement -70°mc.send_angle(4, -70, 40)time.sleep(3)
# Control joint 1 to move 90°mc.send_angle(1, 90, 40)time.sleep(3)
# Control joint 5 movement -90°mc.send_angle(5, -90, 40)time.sleep(3)
# Control joint 5 to move 90°mc.send_angle(5, 90, 40)time.sleep(3)4 Multi-Joint Motion
xxxxxxxxxximport timefrom pymycobot import MyCobot320
# MyCobot320 class initialization requires two parameters:# The first is the serial port string, such as:# linux: "/dev/ttyUSB0"# or "/dev/ttyACM0"# windows: "COM3"# The second is the baud rate:115200