### Install Dependencies Source: https://github.com/elephantrobotics/pymycobot/blob/main/demo/handle_control/README.md Run this command in the terminal to install the required libraries for the project. ```bash pip3 install -r requirements.txt ``` -------------------------------- ### MyBuddySocket Connection and Get Angles Example Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/MyBuddy_en.md Example demonstrating how to connect to the MyBuddy robot via a socket and retrieve the current angles of its joints. ```APIDOC ## MyBuddySocket Example ### Description Connect to MyBuddy via socket and get joint angles. ### Code ```python from pymycobot import MyBuddySocket mst = MyBuddySocket("192.168.0.1", 9000) mst.connect("/dev/ttyACM0", "115200") print(mst.get_angles(1)) ``` ``` -------------------------------- ### Install Dependencies Source: https://github.com/elephantrobotics/pymycobot/blob/main/demo/myArm_M&C_demo/README.md Install the necessary Python packages using pip. ```shell pip install -r requirement.txt ``` -------------------------------- ### Initialize MyArmM and Control Joints Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/myArm_M&C_en.md Import the MyArmM library and initialize the robot connection. This example demonstrates how to get all joint angles and set a specific joint's angle and speed. Ensure the correct serial port is specified. ```python # Example from pymycobot import MyArmM mam = MyArmM('/dev/ttyAMA1') # Gets the current angle of all joints angles = mam.get_joints_angle() print(angles) # Set 1 joint to move to 40 and speed to 20 mam.set_joint_angle(1, 40, 20) ``` -------------------------------- ### start() Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/mybuddy_emoticon_en.md Initiates the playback of the configured video emoticons. ```APIDOC ## start() ### Description start playing video ``` -------------------------------- ### Initialize MechArm270 and Get Angles Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/MechArm_270_en.md Import the MechArm270 class and initialize the robot arm connection. This example demonstrates how to get the current angles of all joints. ```python from pymycobot import MechArm270 mc = MechArm270('COM3') # Gets the current angle of all joints angles = mc.get_angles() print(angles) ``` -------------------------------- ### Initialize and Start MyBuddyEmoticon Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/mybuddy_emoticon_en.md Initializes MyBuddyEmoticon with a list of videos and their playback durations, then starts playback. Ensure the video paths are absolute. ```python from pymycobot import MyBuddyEmoticon import time # [video_path, Playback_duration(s)] video1 = ["/home/er/pymycobot/emo/face_video_3_2.mp4", 10] datas = [video1] me = MyBuddyEmoticon(datas) me.start() ``` -------------------------------- ### PyMyCobot Server Output Example Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/pro630_esp32_en.md Example output when running the `Server_Pro630.py` script, showing the IP address, port, and connection status. ```shell pi@raspberrypi:~/pymycobot/demo $ python3 Server_Pro630.py ip: 192.168.1.169 port: 9000 Binding succeeded! This is asynchronous mode waiting connect!------------------ ``` -------------------------------- ### Install PyMyCobot from Source Source: https://github.com/elephantrobotics/pymycobot/blob/main/README.md Clone the repository and install pymycobot from the source code. This is useful for development or if you need the latest unreleased features. ```bash # The latest code branch is the develop branch. You can choose to install it if necessary. git clone https://github.com/elephantrobotics/pymycobot.git cd /pymycobot # Install [sudo] python2 setup.py install # Will not support starting from v4.0.1 # or [sudo] python3 setup.py install ``` ```bash # Install pip install . # Uninstall pip uninstall . ``` -------------------------------- ### Mercury X1 Chassis API Usage Example Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/Mercury_X1_Chassis_en.md Import the API library and control the chassis. Ensure the API library is imported before using any functions. This example demonstrates getting battery voltage and setting the RGB light strip color. ```python # demo from pymycobot import mercurychassis_api mc = ChassisControl('/dev/wheeltec_controller') # Get battery voltage voltage = mc.get_power_voltage() print(voltage) # Set the chassis RGB light strip to green mc.set_color(255, 0, 0) ``` -------------------------------- ### Initialize MyCobot 320 and Get Joint Angles Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/MyCobot_320_en.md Import the MyCobot320 class and initialize the robot by specifying the COM port. This example demonstrates how to retrieve the current angles of all joints and print them. ```python from pymycobot import MyCobot320 mc = MyCobot320('COM3') # Gets the current angle of all joints angles = mc.get_angles() print(angles) ``` -------------------------------- ### Start Chassis Communication Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/Mercury_X1_Chassis_en.md Run this command in the console to initiate communication with the chassis. ```bash roslaunch turn_on_mercury_robot mapping.launch ``` -------------------------------- ### Install PyMyCobot Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/pro630_esp32_en.md Update or install the PyMyCobot library to version 3.5.0a2 or later to use the Pro630 client. ```shell pip uninstall pymycobot pip install pymycobot==3.5.0a2 ``` -------------------------------- ### Initialize MyPalletizer 260 and Get Joint Angles Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/MyPalletizer_260_en.md Import the MyPalletizer260 class and initialize it with the serial port. This example demonstrates how to retrieve the current angles of all joints. ```python from pymycobot import MyPalletizer260 mc = MyPalletizer260('COM3') # Gets the current angle of all joints angles = mc.get_angles() print(angles) ``` -------------------------------- ### Initialize MyCobot and Get Joint Angles Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/MyCobot_280_RDKX5_en.md Import the MyCobot API and establish a connection to the robot. This snippet demonstrates how to get the current angles of all joints. ```python from pymycobot import MyCobot280RDKX5 mc = MyCobot280RDKX5('/dev/ttyS1') # Gets the current angle of all joints angles = mc.get_angles() print(angles) ``` -------------------------------- ### Install PyMyCobot via Pip Source: https://github.com/elephantrobotics/pymycobot/blob/main/README.md Install the latest version of the pymycobot library using pip. This is the recommended method for most users. ```bash pip install pymycobot --upgrade ``` -------------------------------- ### tool_serial_ready() Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/Mercury_API.md Initializes the 485 serial communication. Returns 0 if not set, and 1 if setup is completed. ```APIDOC ## tool_serial_ready() ### Description Set up 485 communication. ### Return value - 0 : not set - 1 : Setup completed ``` -------------------------------- ### drag_start_record Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/MyCobot_280_en.md Starts the trajectory recording process. ```APIDOC ## drag_start_record() ### Description Starts trajectory recording. ### Return Value - An integer representing the current recording queue length. ``` -------------------------------- ### Basic Robot Control Examples Source: https://context7.com/elephantrobotics/pymycobot/llms.txt Demonstrates fundamental robot control operations including sending angles, setting colors, and releasing servos. ```APIDOC ## Basic Robot Control ### Description Examples for controlling the robot's arm, setting LED colors, and releasing servos. ### Methods - `send_angles(id, angles, speed)`: Sends a list of joint angles to the robot. - `set_color(id, r, g, b)`: Sets the color of the robot's LED. - `release_all_servos(id)`: Releases all servos for the specified robot arm. ### Example Usage ```python from pymycobot import MyCobot import time buddy = MyCobot("/dev/ttyUSB0", 115200) # Move left arm to home position buddy.send_angles(1, [0, 0, 0, 0, 0, 0], 30) time.sleep(3) # Set color on left arm Atom buddy.set_color(1, 255, 0, 0) buddy.release_all_servos(1) # release left arm ``` ``` -------------------------------- ### drag_teach_save Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/pro630_esp32_en.md Starts recording and saving points for drag teaching. The recording time should not exceed 90 seconds for optimal performance. ```APIDOC ## drag_teach_save() ### Description Starts recording and dragging teaching points. ### Note In order to display the best sports effect, the recording time should not exceed 90 seconds. ``` -------------------------------- ### Run Handle Control Program Source: https://github.com/elephantrobotics/pymycobot/blob/main/demo/handle_control/README.md Execute the Python script to start the MyCobot handle control application. ```bash python3 myCobot280_handle_control.py ``` -------------------------------- ### Run Bluetooth Server Source: https://github.com/elephantrobotics/pymycobot/blob/main/demo/mycobot_pi_bluetooth/README.md Execute this Python script to start the Bluetooth server on the myCobot Pi. This is necessary for establishing a connection. ```python python uart_peripheral_serial.py ``` -------------------------------- ### Drag Teaching Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/Mercury_API.md Functions to start, pause, and execute drag teaching for the robotic arm. ```APIDOC ## drag_teach_save ### Description Starts recording and dragging teaching points. The recording time should not exceed 90 seconds for optimal performance. ### Method ``` drag_teach_save() ``` ## drag_teach_pause ### Description Pauses the sampling process during drag teaching. ### Method ``` drag_teach_pause() ``` ## drag_teach_execute ### Description Starts the execution of the taught points from drag teaching. This function executes the sequence only once. ### Method ``` drag_teach_execute() ``` ``` -------------------------------- ### MyCobot 320 Socket Client Example Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/MyCobot_320_en.md Demonstrates how to connect to and control the MyCobot 320 robotic arm using the `MyCobot320Socket` class over TCP/IP. ```APIDOC ## MyCobot 320 Socket Client ### Description This section provides an example of how to use the `MyCobot320Socket` class to establish a connection with the robotic arm's server and send commands. ### Usage ```python from pymycobot import MyCobot320Socket # Initialize the connection to the robot arm # Port 9000 is used by default mc = MyCobot320Socket("192.168.10.10", 9000) # Example: Get current angles res = mc.get_angles() print(res) # Example: Send angles command mc.send_angles([0, 0, 0, 0, 0, 0], 20) ... ``` ### Note - The `MyCobot320Socket` class requires the robotic arm to have a server running and enabled. - This class is intended for use with the Raspberry Pi version and supports Python 3. ``` -------------------------------- ### Run the Main Program Source: https://github.com/elephantrobotics/pymycobot/blob/main/demo/myArm_M&C_demo/README.md Execute the main Python script to start the myArm M&C control application. ```shell python main.py ``` -------------------------------- ### ultraArm P340 Initialization and Pick-and-Place Example Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/ultraArm_P340_en.md Demonstrates connecting to the ultraArm P340, moving it to predefined positions, and using the suction pump for a pick-and-place operation. It includes system-specific port selection and timed pauses for movement and suction. ```python import time import platform from pymycobot.ultraArmP340 import ultraArmP340 # Automatically select the system and connect the mechanical arm if platform.system() == "Windows": ua = ultraArmP340('COM6', 115200) ua.go_zero() elif platform.system() == "Linux": ua = ultraArmP340('/dev/ttyUSB0', 115200) ua.go_zero() # Position of mechanical arm movement angles = [ [-81.71, 0.0, 0.0], [-90.53, 21.77, 47.56], [-90.53, 0.0, 0.0], [-59.01, 21.77, 45.84], [-59.01, 0.0, 0.0] ] # Suck small pieces ua.set_angles(angles[0], 50) time.sleep(3) ua.set_angles(angles[1], 50) time.sleep(3) # Start suction pump ua.set_gpio_state(0) ua.set_angles(angles[2], 50) time.sleep(3) ua.set_angles(angles[3], 50) # Close the suction pump ua.set_gpio_state(1) time.sleep(3) ua.set_angles(angles[4], 50) ``` -------------------------------- ### Get Robot Type Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/Mercury_API.md Obtain the robot's model identifier. For example, the Mercury A1 model is represented by 4500. ```python mc.get_robot_type() ``` -------------------------------- ### Navigate to the directory Source: https://github.com/elephantrobotics/pymycobot/blob/main/demo/myAGVPro_Composite_Kit/README.md Enter the specific directory for the myAGVPro composite kit demo. ```shell cd pymycobot/demo/myAGVPro_Composite_Kit ``` -------------------------------- ### Basic Arm Control Example Source: https://context7.com/elephantrobotics/pymycobot/llms.txt Demonstrates basic arm control operations including moving to a home position, setting LED color, and releasing servos. ```python # Move left arm to home position buddy.send_angles(1, [0, 0, 0, 0, 0, 0], 30) time.sleep(3) # Set color on left arm Atom buddy.set_color(1, 255, 0, 0) buddy.release_all_servos(1) # release left arm ``` -------------------------------- ### gpio_init Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/MechArm_270_en.md Initializes the GPIO module and sets the mode to BCM. ```APIDOC ## gpio_init() ### Description Initializes the GPIO module and sets the BCM mode. ``` -------------------------------- ### Install Older PyMyCobot Version Source: https://github.com/elephantrobotics/pymycobot/blob/main/README.md If you are using an older version of the Atom firmware (prior to 2.4), install version 1.0.7 of pymycobot. ```bash pip install pymycobot==1.0.7 --user ``` -------------------------------- ### Initialize GPIO Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/MyCobot_320_en.md Initializes the GPIO module and sets the mode to BCM. ```python mycobot.gpio_init() ``` -------------------------------- ### Robot Class Instantiation Source: https://context7.com/elephantrobotics/pymycobot/llms.txt Demonstrates how to instantiate various MyCobot robot models for serial or TCP socket connections, including options for debug logging. ```APIDOC ## Robot Class Instantiation Every interaction starts by instantiating a robot class with a serial port or network address. The `debug=True` flag enables verbose hex logging of all protocol frames. ```python from pymycobot import ( MyCobot280, MyCobot280Socket, MyCobot320, MyCobot320Socket, MechArm270, MechArmSocket, MyPalletizer260, MyPalletizerSocket, Mercury, MercurySocket, MyArm, MyArmSocket, MyBuddy, MyAgv, Pro450Client, PI_PORT, PI_BAUD, ) # Serial connection (USB or UART) mc = MyCobot280("/dev/ttyUSB0", baudrate=115200, timeout=0.1, debug=False) # TCP socket connection (robot runs demo/Server_280.py first) mc = MyCobot280Socket("192.168.1.10", netport=9000, debug=False) # Raspberry Pi onboard serial mc = MyCobot280(PI_PORT, PI_BAUD) # MyCobot 320 via serial mc320 = MyCobot320("/dev/ttyUSB0", 115200) # MechArm 270 via serial marm = MechArm270("/dev/ttyUSB0", 115200) # Mercury via serial mercury = Mercury("/dev/ttyAMA1", 115200) # MyBuddy dual-arm buddy = MyBuddy("/dev/ttyUSB0", 115200) # MyAGV agv = MyAgv("/dev/ttyUSB0", 115200) # Pro 450 client (Ethernet) pro = Pro450Client("192.168.1.10", 9000) mc.close() # close serial/socket when done ``` ``` -------------------------------- ### Initialize MyBuddyEmoticon with Video Data Source: https://github.com/elephantrobotics/pymycobot/blob/main/demo/mybuddy_demo/emoticon.md This snippet shows how to initialize the MyBuddyEmoticon class with a list of video configurations. Each configuration includes the video file path and its playback duration in seconds. Ensure the video path points to a valid, decompressed video file. ```python from pymycobot import MyBuddyEmoticon import time # [video_path, Playback_duration(s)] video1 = ["/home/er/pymycobot/emo/face_video_3_2.mp4", 10] datas = [video1] me = MyBuddyEmoticon(datas) ... ``` -------------------------------- ### Get System Version Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/Mercury_API.md Retrieve the system version of the robot arm. ```python mc.get_system_version() ``` -------------------------------- ### set_pro_gripper_init Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/MyCobot_Pro450_en.md Initializes the gripper, restoring it to Modbus mode at 115200 baud rate. ```APIDOC ## set_pro_gripper_init ### Description Initializes the gripper, restoring it to Modbus mode at 115200 baud rate. ### Parameters #### Path Parameters - **gripper_id** (int) - Optional - Gripper ID, default 14, value range 1 ~ 254. ### Return Value - **bool**: True - Success, False - Failure ``` -------------------------------- ### get_hand_gripper_min_pressure Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/MyCobot_320_en.md Retrieves the minimum starting force (pressure) for a specified gripper joint. ```APIDOC ## get_hand_gripper_min_pressure(joint_id, gripper_id=14) ### Description Get the minimum starting force of a joint. ### Parameters #### Path Parameters - **joint_id** (int) - Required - Specifies the joint (1-6). - **gripper_id** (int) - Optional - Specifies the gripper ID (1-254, default 14). ### Return value - **value** (int) - The minimum force value (0-254). ``` -------------------------------- ### set_hand_gripper_min_pressure Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/MyCobot_320_en.md Sets the minimum starting force (pressure) for a specified gripper joint. ```APIDOC ## set_hand_gripper_min_pressure(joint_id, value, gripper_id=14) ### Description Set the minimum starting force of a joint. ### Parameters #### Path Parameters - **joint_id** (int) - Required - Specifies the joint (1-6). - **value** (int) - Required - The minimum force value (0-254). - **gripper_id** (int) - Optional - Specifies the gripper ID (1-254, default 14). ### Return value - **status** (int) - 0 for Failed, 1 for Success. ``` -------------------------------- ### Initialize and Control MyCobot 280 Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/MyCobot_280_en.md Import the MyCobot280 class and establish a connection to the robot via a specified COM port. This example demonstrates how to retrieve current joint angles and set a specific joint to a target angle with a given speed. ```python from pymycobot import MyCobot280 mc = MyCobot280('COM3') # Gets the current angle of all joints angles = mc.get_angles() print(angles) # Set 1 joint to move to 40 and speed to 20 mc.send_angle(1, 40, 20) ``` -------------------------------- ### Get Movement Type Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/pro630_esp32_en.md Retrieves the current movement type setting of the robot. ```APIDOC ## get_movement_type() ### Description Gets the current movement type setting of the robot. ### Method `get_movement_type()` ### Parameters None ### Return Value - `1`: Indicates `movel` (linear movement) is set. - `0`: Indicates `moveJ` (joint movement) is set. ### Example ```python from pymycobot import Pro630 p = Pro630("/dev/ttyAMA0") move_type = p.get_movement_type() print(f"Current movement type: {move_type}") ``` ``` -------------------------------- ### Get Reference Frame Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/pro630_esp32_en.md Retrieves the currently set base coordinate system. ```APIDOC ## get_reference_frame() ### Description Gets the currently set base coordinate system. ### Method `get_reference_frame()` ### Parameters None ### Return Value - `0`: Indicates the base coordinate system is set. - `1`: Indicates the tool coordinate system is set. ### Example ```python from pymycobot import Pro630 p = Pro630("/dev/ttyAMA0") frame_type = p.get_reference_frame() print(f"Current reference frame: {frame_type}") ``` ``` -------------------------------- ### System & Product Information Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/MyAGVPro_en.md Methods for retrieving system version and controlling power state. ```APIDOC ## get_system_version() ### Description Obtain the major firmware version number. ### Return value - **float: version** ``` ```APIDOC ## get_modify_version() ### Description Obtain the minor firmware version number. ### Return value - **int: version** ``` ```APIDOC ## power_on() ### Description Turn on the robot. ### Return value - **int: Power-on result, 1: Success, 0: Failed** ``` ```APIDOC ## power_on_only() ### Description Turn on the robot, but not start the control program. ### Return value - **int: Power-on result only, 1: Success, 0: Failed** ``` ```APIDOC ## power_off() ### Description Turn off the robot. ### Return value - **int: Power-off result only, 1: Success, 0: Failed** ``` ```APIDOC ## is_power_on() ### Description Check if the robot is powered on. ### Return value - **int: power state, 1: Power-on, 0: Power-off** ``` -------------------------------- ### Get Digital Input Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/pro630_esp32_en.md Reads the current state of a digital input pin. ```APIDOC ## get_digital_input(pin_no) ### Description Reads the signal status of a specified digital input pin. ### Method `get_digital_input(pin_no)` ### Parameters - `pin_no` (int): The number of the pin to read. ### Return Value - `signal` (int): The current signal state of the pin (`0` or `1`). ### Example ```python from pymycobot import Pro630 p = Pro630("/dev/ttyAMA0") status = p.get_digital_input(1) # Read pin 1 print(f"Pin 1 status: {status}") ``` ``` -------------------------------- ### init_gripper Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/MechArm_270_en.md Initializes the gripper, setting it to a default state. ```APIDOC ## init_gripper() ### Description Initialize gripper. ``` -------------------------------- ### Gripper Protection Current Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/MechArm_270_en.md Functions to get and set the protection current for the gripper. ```APIDOC ## get_gripper_protect_current() ### Description Get the gripper protection current. ### Return value (int) 1 ~ 500 ``` ```APIDOC ## set_gripper_protect_current(current) ### Description Set the gripper protection current. ### Parameters - **current** (int): 1 ~ 500 ``` -------------------------------- ### Power On Robot Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/pro630_esp32_en.md This snippet demonstrates how to power on the robot using the `power_on` command. It's essential to power on the robot before controlling it, especially on its first use. ```APIDOC ## Power On Robot ### Description Powers on the robot. This is a prerequisite for controlling the robot, particularly when it's powered on for the first time. ### Method `power_on()` ### Parameters None ### Request Example ```python from pymycobot import Pro630Client p = Pro630Client("192.168.1.169", 9000) res = p.power_on() if res == 1: print("power on succ") ``` ### Response - **res** (int) - Returns 1 on success, otherwise indicates failure. ``` -------------------------------- ### Speed Planning Functions Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/MyBuddy_en.md Functions for getting and setting planning acceleration and speed. ```APIDOC ## get_plan_acceleration(id=0) ### Description Get planning acceleration. ### Parameters - **id** (int) - 0/1/2/3 (ALL/L/R/W). ### Return Value - List[int]: [movel planning acceleration, movej planning acceleration]. ## get_plan_speed(id=0) ### Description Get planning speed. ### Parameters - **id** (int) - 0/1/2/3 (ALL/L/R/W). ### Return Value - List[int]: [movel planning speed, movej planning speed]. ## set_acceleration(id, acc) ### Description Set acceleration during all moves. ### Parameters - **id** (int) - 1/2/3 (L/R/W). - **acc** (int) - Acceleration value (1 - 100). ## get_acceleration(id) ### Description Read acceleration during all moves. ### Parameters - **id** (int) - 1/2/3 (L/R/W). ``` -------------------------------- ### Get End Coordinate System Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/pro630_esp32_en.md Retrieves the current setting for the end coordinate system. ```APIDOC ## get_end_type() ### Description Obtains the current setting for the end coordinate system. ### Method `get_end_type()` ### Parameters None ### Return Value - `0`: Indicates the end effector is set to the flange. - `1`: Indicates the end effector is set to the tool. ### Example ```python from pymycobot import Pro630 p = Pro630("/dev/ttyAMA0") end_type = p.get_end_type() print(f"End coordinate system: {end_type}") ``` ``` -------------------------------- ### Initialize MyCobot Pro 450 Client and Get Angles Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/MyCobot_Pro450_en.md This Python code initializes the Pro450Client, ensures the robot is powered on, and retrieves the current joint angles. Ensure the robot and PC are on the same network segment. ```python # Example from pymycobot import Pro450Client # The default IP address is "192.168.0.232" and the default port number is 4500 mc = Pro450Client('192.168.0.232', 4500) if mc.is_power_on() !=1: mc.power_on() print(mc.get_angles()) ``` -------------------------------- ### Get World Reference Frame Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/pro630_esp32_en.md Retrieves the current world coordinate system values. ```APIDOC ## get_world_reference() ### Description Gets the current world coordinate system values. ### Method `get_world_reference()` ### Parameters None ### Return Value - `list`: A list containing `[x, y, z, rx, ry, rz]` representing the world coordinates and rotations. ### Example ```python from pymycobot import Pro630 p = Pro630("/dev/ttyAMA0") world_ref = p.get_world_reference() print(f"World reference: {world_ref}") ``` ``` -------------------------------- ### get_gripper_protect_current Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/MyCobot_280_en.md Gets the protection current value for the gripper. The value ranges from 1 to 500. ```APIDOC ## get_gripper_protect_current() ### Description Retrieves the protection current setting for the gripper. ### Return value - (int): The protection current value, ranging from 1 to 500. ``` -------------------------------- ### MyBuddyEmoticon Class Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/mybuddy_emoticon_en.md Initializes the MyBuddyEmoticon with a list of video files and their playback durations, and optionally sets the window size and loop behavior. ```APIDOC ## MyBuddyEmoticon(file_path: list = [], window_size: tuple = (), loop=False) ### Description API for playing emoticons. ### Parameters * **file_path (list)**: `[[path, time]]` The absolute path of facial expression video and the length of time to play. Time in seconds. * **window_size (tuple)**: `(Length, width)` Size of the playback window (default is full screen). * **loop (bool)**: Loop playback or not (default False. only once by default). ``` -------------------------------- ### Velocity Fusion Parameters Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/MyCobot_Pro450_en.md Functions to get and set velocity fusion planning parameters. ```APIDOC ## get_fusion_parameters(rank_mode) ### Description Get velocity fusion planning parameters. ### Parameters #### Path Parameters - **rank_mode** (int) - Required - The parameter mode to retrieve. - `1`: Fusion joint velocity - `2`: Fusion joint acceleration - `3`: Fusion coordinate velocity - `4`: Fusion coordinate acceleration ### Return Value - **int** The parameter value (0 to 1000). ## set_fusion_parameters(rank_mode, value) ### Description Set velocity fusion planning parameters. ### Parameters #### Path Parameters - **rank_mode** (int) - Required - The parameter mode to set (1 to 4). - **value** (int) - Required - The parameter value (0 to 1000). ``` -------------------------------- ### Initialize Gripper Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/MyCobot_280_en.md Initializes the gripper module. Returns 1 upon successful completion. ```python init_gripper() ``` -------------------------------- ### Filter Parameters Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/MyCobot_Pro450_en.md Functions to get and set various filter parameters for motion control. ```APIDOC ## get_filter_len(rank) ### Description Get filter parameters based on the specified rank. ### Parameters #### Path Parameters - **rank** (int) - Required - The filter rank to query. - `1`: Drag teach sampling filter - `2`: Drag teach execution filter - `3`: Joint velocity fusion filter - `4`: Coordinate velocity fusion filter - `5`: Drag teach sampling period ### Return Value - **int** The filter value (1 to 255). ## set_filter_len(rank, value) ### Description Set filter parameters for the robot arm. ### Parameters #### Path Parameters - **rank** (int) - Required - The filter rank to set (1 to 5). - `1`: Drag teach sampling filter - `2`: Drag teach execution filter - `3`: Joint velocity fusion filter - `4`: Coordinate velocity fusion filter - `5`: Drag teach sampling period - **value** (int) - Required - The filter value (1 to 255). ``` -------------------------------- ### Joint Model Direction Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/MyCobot_Pro450_en.md Functions to get and set the direction of each joint's motor. ```APIDOC ## get_model_direction() ### Description Get the joint model direction for all joints. ### Return Value - **list** Model direction of joints 1-6. - `1`: Same direction as the motor - `0`: Opposite direction from the motor ## set_model_direction(joint_id, direction) ### Description Set the joint model direction for a specific joint. ### Parameters #### Path Parameters - **joint_id** (int) - Required - The ID of the joint (1 to 6). - **direction** (int) - Required - The direction setting. - `1`: Same direction as the motor - `0`: Opposite direction from the motor ``` -------------------------------- ### Import UltraArm P340 API Library Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/ultraArm_P340_en.md Import the necessary library for the Mira Series (UltraArm P340) before using any API functions. Ensure the library is installed. ```python #For Mira Series from pymycobot.ultraArmP340 import ultraArmP340 ``` -------------------------------- ### End Type Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/MyCobot_Pro450_en.md Functions to set and get the end coordinate system (Flange or Tool). ```APIDOC ## set_end_type(end) ### Description Set the end coordinate system. ### Parameters #### Path Parameters - **end** (int) - Required - Specifies the end coordinate system. - `0`: Flange (default) - `1`: Tool ## get_end_type() ### Description Get the end coordinate system. ### Return Value - `0`: Flange (default) - `1`: Tool ``` -------------------------------- ### Configure Port and Initialize MyCobot Source: https://github.com/elephantrobotics/pymycobot/blob/main/demo/handle_control/README.md Modify the script to use your computer's detected port number and baud rate. The MyCobot280 class is instantiated here. ```python import pygame import time from pymycobot import MyCobot280 import threading # Change /dev/ttyAMA0 to the port number and rate detected by your computer mc = MyCobot280("/dev/ttyANA0", 1000000) ``` -------------------------------- ### Reference Frame Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/MyCobot_Pro450_en.md Functions to set and get the base coordinate system reference frame. ```APIDOC ## set_reference_frame(rftype) ### Description Set the base coordinate system. ### Parameters #### Path Parameters - **rftype** (int) - Required - Specifies the coordinate system to use. - `0`: Base coordinates (default) - `1`: World coordinates ## get_reference_frame() ### Description Get the base coordinate system. ### Return Value - **list** [x, y, z, rx, ry, rz] ``` -------------------------------- ### Import and Initialize Mercury API Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/Mercury_API.md Import the Mercury API and initialize the robot arm connection. Ensure the correct serial port is specified. ```python from pymycobot import Mercury mc = Mercury('/dev/ttyAMA1') print(mc.get_angles()) ``` -------------------------------- ### Get All Joint Angles Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/Mercury_API.md Retrieve the current angular position of all joints in the robot arm. ```python mc.get_angles() ``` -------------------------------- ### Get Atom Version Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/Mercury_API.md Fetch the end version number of the robot's firmware. ```python mc.get_atom_version() ``` -------------------------------- ### Power On Robot Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/pro630_esp32_en.md Initializes the robot and powers it on. This command must be used before controlling the robot. ```APIDOC ## power_on() ### Description Powers on the robotic arm. This is a prerequisite for controlling the robot. ### Method `power_on()` ### Parameters None ### Return Value - `1` on success ### Example ```python from pymycobot import Pro630 p = Pro630("/dev/ttyAMA0") res = p.power_on() if res == 1: print("power on succ") ``` ``` -------------------------------- ### World Coordinate System Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/MyCobot_Pro450_en.md Functions to set and get the world coordinate system for the robot arm. ```APIDOC ## set_world_reference(coords) ### Description Set the world coordinate system. ### Parameters #### Path Parameters - **coords** (list) - Required - A list of floats representing [x, y, z, rx, ry, rz]. - x: -1000 ~ 1000 - y: -1000 ~ 1000 - z: -1000 ~ 1000 - rx: -180 ~ 180 - ry: -180 ~ 180 - rz: -180 ~ 180 ## get_world_reference() ### Description Get the world coordinate system. ### Return Value - **list** [x, y, z, rx, ry, rz] ``` -------------------------------- ### Initialize MyPalletizerSocket Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/MyPalletizer_260_en.md Instantiate the MyPalletizerSocket class to establish a connection with the robotic arm via TCP/IP. Ensure the server is running on the robotic arm and specify the IP address and port. ```python from pymycobot import MyPalletizerSocket # Port 9000 is used by default mc = MyPalletizerSocket("192.168.10.10",9000) ``` -------------------------------- ### Tool Coordinate System Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/MyCobot_Pro450_en.md Functions to set and get the tool coordinate system for the robot arm. ```APIDOC ## set_tool_reference(coords) ### Description Set the tool coordinate system. ### Parameters #### Path Parameters - **coords** (list) - Required - A list of floats representing [x, y, z, rx, ry, rz]. - x: -1000 ~ 1000 - y: -1000 ~ 1000 - z: -1000 ~ 1000 - rx: -180 ~ 180 - ry: -180 ~ 180 - rz: -180 ~ 180 ## get_tool_reference() ### Description Get the tool coordinate system. ### Return Value - **list** [x, y, z, rx, ry, rz] ``` -------------------------------- ### Speed and Acceleration Parameters Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/MyCobot_Pro450_en.md Functions to get and set the maximum speed and acceleration for the robot arm. ```APIDOC ## get_max_speed(mode) ### Description Retrieves the maximum speed setting for either angular or coordinate movement. ### Parameters - **mode** (int) - Required - 0 for angular speed, 1 for coordinate speed. ### Return Value - Angular speed range: 1-150°/s - Coordinate speed range: 1-200mm/s ``` ```APIDOC ## set_max_speed(mode, max_speed) ### Description Sets the maximum speed for either angular or coordinate movement. ### Parameters - **mode** (int) - Required - 0 for angular speed, 1 for coordinate speed. - **max_speed** (int) - Required - The desired maximum speed within the allowed range. ``` ```APIDOC ## get_max_acc(mode) ### Description Retrieves the maximum acceleration setting for either angular or coordinate movement. ### Parameters - **mode** (int) - Required - 0 for angular acceleration, 1 for coordinate acceleration. ### Return Value - Angular acceleration range: 1 to 150°/s - Coordinate acceleration range: 1 to 400 mm/s ``` -------------------------------- ### Record and Replay Arm Trajectories with Drag Teaching Source: https://context7.com/elephantrobotics/pymycobot/llms.txt Enable free mode, start recording with `drag_start_record`, move the arm manually, then stop recording with `drag_end_record`. Recorded data can be retrieved using `drag_get_record_data` and cleared with `drag_clear_record_data`. ```python from pymycobot import MyCobot280 import time mc = MyCobot280("/dev/ttyUSB0", 115200) mc.set_free_mode(1) queue_len = mc.drag_start_record() print("Recording started, queue length:", queue_len) # Move the arm by hand for 5 seconds time.sleep(5) queue_len = mc.drag_end_record() print("Recording ended, points captured:", mc.drag_get_record_len()) # Retrieve recorded data: [[encoders...], [speeds...]] data = mc.drag_get_record_data() if data != -1: encoders, speeds = data print("First point encoders:", encoders[:6]) print("First point speeds:", speeds[:6]) mc.drag_clear_record_data() # clear the recording buffer ``` -------------------------------- ### HTS Gripper Torque Control Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/MechArm_270_en.md Functions to set and get the torque for the HTS adaptive gripper. ```APIDOC ## set_HTS_gripper_torque(torque) ### Description Set new adaptive gripper torque. ### Parameters - **torque** (int): 150 ~ 980 ### Return value - 0: Set failed - 1: Set successful ``` ```APIDOC ## get_HTS_gripper_torque() ### Description Get gripper torque. ### Return value (int) 150 ~ 980 ``` -------------------------------- ### Command Execution Mode Source: https://context7.com/elephantrobotics/pymycobot/llms.txt Configure the command execution mode. 'Fresh mode' prioritizes the latest command, while 'Queue mode' executes commands sequentially. ```APIDOC ## set_fresh_mode / get_fresh_mode Control whether the command queue executes sequentially (queue mode) or always runs the latest command first (fresh/override mode). ```python from pymycobot import MyCobot280 mc = MyCobot280("/dev/ttyUSB0", 115200) # Fresh mode: always execute the latest command (useful for real-time tracking) mc.set_fresh_mode(1) print("Fresh mode:", mc.get_fresh_mode()) # -> 1 # Queue mode: execute commands in order (default for programmed sequences) mc.set_fresh_mode(0) print("Fresh mode:", mc.get_fresh_mode()) # -> 0 ``` ``` -------------------------------- ### Run PyMyCobot Server Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/pro630_esp32_en.md Execute the `Server_Pro630.py` script on the robot's system to establish a TCP/IP server for communication. The script will output the server's IP address and port. ```shell python3 Server_Pro630.py ``` -------------------------------- ### Control Command Execution Mode (Fresh vs. Queue) Source: https://context7.com/elephantrobotics/pymycobot/llms.txt Use `set_fresh_mode` to switch between fresh mode (latest command overrides) and queue mode (sequential execution). `get_fresh_mode` retrieves the current setting. ```python from pymycobot import MyCobot280 mc = MyCobot280("/dev/ttyUSB0", 115200) # Fresh mode: always execute the latest command (useful for real-time tracking) mc.set_fresh_mode(1) print("Fresh mode:", mc.get_fresh_mode()) # -> 1 # Queue mode: execute commands in order (default for programmed sequences) mc.set_fresh_mode(0) print("Fresh mode:", mc.get_fresh_mode()) # -> 0 ``` -------------------------------- ### Get Movement Type Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/MyCobot_320_en.md Retrieves the current movement type. Returns 1 for `movel` or 0 for `moveJ`. ```python mycobot.get_movement_type() ``` -------------------------------- ### Power On Pro630 Robot Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/pro630_esp32_en.md Initiates the robot's power-on sequence. This command must be executed before controlling the robot for the first time after it has been powered off. ```python from pymycobot import Pro630Client p = Pro630Client("192.168.1.169", 9000) res = 0 res = p.power_on() if res == 1: print("power on succ") ``` -------------------------------- ### Get Synchronous/Asynchronous Control Mode Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/pro630_esp32_en.md Retrieves the current control mode (synchronous or asynchronous) for position updates. ```APIDOC ## get_pos_switch() ### Description Gets the current control mode, indicating whether position updates are handled synchronously or asynchronously. ### Method `get_pos_switch()` ### Parameters None ### Return Value - `0`: Asynchronous mode. - `1`: Synchronous mode. ### Example ```python from pymycobot import Pro630 p = Pro630("/dev/ttyAMA0") mode = p.get_pos_switch() if mode == 0: print("Control mode is asynchronous") else: print("Control mode is synchronous") ``` ``` -------------------------------- ### run() Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/mybuddy_emoticon_en.md Resumes video playback after it has been paused. ```APIDOC ## run() ### Description Continue playing ``` -------------------------------- ### Get Gripper Torque Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/MyCobot_280_en.md Retrieves the current adaptive gripper torque setting. The value is between 150 and 980. ```python get_HTS_gripper_torque() ``` -------------------------------- ### Utility Methods Source: https://context7.com/elephantrobotics/pymycobot/llms.txt Provides access to system version, reboot count, and WiFi configuration for specific robot models. ```APIDOC ## get_system_version / get_reboot_count / set_ssid_pwd ### Description Utility methods for firmware version, reboot diagnostics, and WiFi configuration (M5 stack version). ### Methods - `get_system_version()`: Retrieves the robot's firmware version. - `get_reboot_count()`: Gets the number of times the robot has rebooted. - `set_ssid_pwd(ssid, password)`: Configures the WiFi network credentials. ### Parameters #### `set_ssid_pwd` - **ssid** (str) - The name of the WiFi network. - **password** (str) - The password for the WiFi network. ### Example Usage ```python from pymycobot import MyCobot280 mc = MyCobot280("/dev/ttyUSB0", 115200) version = mc.get_system_version() print("Firmware version:", version) # -> e.g. 1.0 reboot_count = mc.get_reboot_count() print("Reboot count:", reboot_count) # -> integer # Change connected WiFi (M5/Seeed version only) mc.set_ssid_pwd("MyNetwork", "MyPassword") ``` ``` -------------------------------- ### Movement Type Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/MyCobot_Pro450_en.md Functions to set and get the robot arm's movement type (linear or joint). ```APIDOC ## set_movement_type(move_type) ### Description Set the movement type. ### Parameters #### Path Parameters - **move_type** (int) - Required - Specifies the movement type. - `1`: moveL (Linear movement) - `0`: moveJ (Joint movement) ## get_movement_type() ### Description Get the movement type. ### Return Value - `1`: moveL - `0`: moveJ ``` -------------------------------- ### Joint Software Limit Operations Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/MyCobot_Pro450_en.md Functions to get and set the minimum and maximum angle limits for each joint. ```APIDOC ## get_joint_min_angle(joint_id) ### Description Reads the minimum angle limit for a specified joint. ### Parameters - **joint_id** (int): The ID of the joint (range 1-6). ### Return Value - `float`: The minimum angle value of the joint. ``` ```APIDOC ## get_joint_max_angle(joint_id) ### Description Reads the maximum angle limit for a specified joint. ### Parameters - **joint_id** (int): The ID of the joint (range 1-6). ### Return Value - `float`: The maximum angle value of the joint. ``` ```APIDOC ## set_joint_min_angle(id, angle) ### Description Sets the minimum angle limit for a specified joint. ### Parameters - **id** (int): The ID of the joint (range 1-6). - **angle** (float): The desired minimum angle limit. Must not be less than the joint's minimum value. ``` ```APIDOC ## set_joint_max_angle(id, angle) ### Description Sets the maximum angle limit for a specified joint. ### Parameters - **id** (int): The ID of the joint (range 1-6). - **angle** (float): The desired maximum angle limit. Must not be greater than the joint's maximum value. ``` -------------------------------- ### Raspberry Pi GPIO Control Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/MyCobot_320_en.md Initialize the GPIO module and control GPIO output pins. ```APIDOC ## gpio_init() ### Description Initialize the GPIO module and set it to BCM mode. ``` ```APIDOC ## gpio_output(pin, v) ### Description Set the output value for a specified GPIO pin. ### Parameters - **pin** (int): The GPIO pin number. - **v** (int): The output value: 0 or 1. ``` -------------------------------- ### Get Gripper Value Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/MyBuddy_en.md Retrieves the current value or position of the gripper. This indicates how open or closed the gripper is. ```APIDOC ## get_gripper_value ### Description Get the value of gripper. ### Parameters - **id** (int) - 1/2 (L/R). ### Return Value - gripper value (int). ``` -------------------------------- ### drag_teach_execute Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/pro630_esp32_en.md Executes the saved drag teaching points once. ```APIDOC ## drag_teach_execute() ### Description Starts dragging the teach-in point, executing it only once. ``` -------------------------------- ### Getting Gripper Value with get_gripper_value Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/MyBuddy_en.md Retrieve the current value or position of the gripper. Requires the arm ID. ```python get_gripper_value(id) ``` -------------------------------- ### Get System Version Source: https://github.com/elephantrobotics/pymycobot/blob/main/docs/MyBuddy_en.md Retrieves the system version of the robot. The 'id' parameter specifies the robot or arm. ```python get_system_version(id) ```