Environment Setup
ultraArm_P1_lib is a Python package for serial communication with myCobot, supporting Python3.5 and later versions.
Before using ultraArm_P1_lib to control the robot arm, you need to build a Python environment. The following is a detailed description of Python download and installation.
Linux System
Install the ultraArm_P1_lib library in the console terminal:
pip install ultraArm_P1_lib --upgrade --user
Windows System
Download And Install Python
Applicable devices:
- ultraArm P1
Currently, there are two versions of Python, one is 2.x version and the other is 3.x version. These two versions are incompatible. As 3.x version is becoming more and more popular, our tutorial will take the latest 3.10.7 version as an example.
Install Python
Note: Before installing, please confirm whether your computer is 64-bit or 32-bit. Right-click
My Computerand selectProperties. As shown in the figure below, it is a 64-bit operating system, so select the 64-bit Python installation package.
Python official download address: https://www.python.org/downloads/
Click the
Downloadsoption to start downloading Python, clickAdd Python 3.10 to PATH, clickInstall Nowto start installing Python
- The prompt "Setup was successful" appears, indicating that the installation is complete

Run Python
After successful installation, open the command prompt window (Win+R, enter cmd and press Enter), and type python. Two situations will occur.
Situation 1:

The prompt in the picture indicates that Python has been successfully installed.
The prompt >>> indicates that we are already in the Python interactive environment. We can enter any Python code and get the execution result immediately after pressing Enter.
Case 2:
If the input is wrong (for example, enter pythonn), an error message will appear:

Note: The error message is generally caused by not configuring the environment variables. You can refer to 1.3 Configure environment variables to modify the environment variables.
Configure Environment Variables
Since Windows will search for python.exe according to the path set by a Path environment variable, if it is not found, an error will be reported. Therefore, if you miss checking Add Python 3.10 to PATH during installation, you need to manually add the path where python.exe is located to Path, or reinstall Python and remember to check the Add Python 3.10 to PATH option.
The following are the steps to manually add the path where python.exe is located.
- Right-click My Computer –> Select Properties –> Select Advanced System Settings –> Select Environment Variables in the lower right corner:

- Environment variables mainly include user variables and system variables. The environment variables that need to be set are in these two variables. As shown in the figure below:

- User variables are used to download programs that can be used in cmd commands. Write the absolute path of the program to the user variable and you can use it, as shown in the figure below:

- After completing the above steps, open the command prompt window (Win+R, then enter cmd, press Enter), type Python, and the prompt in the figure below indicates success:

PyCharm Installation And Use
PyCharm is a powerful Python editor with cross-platform capabilities. First, let's introduce the installation steps of PyCharm in Windows system.
Download address: https://www.jetbrains.com/pycharm/download/#section=windows
Download And Install
- After entering the website, we will see the following interface:

Download the file according to the interface introduction. Professional means professional version, and Community means community version. It is recommended to install the community version because it is free to use.
- After downloading, start installing and click
Next:

- Select the corresponding options according to your personal preferences, and then click
Next:

- The following interface appears and continue to click
Next:

- Click
Finishto complete the installation:

Create A Project
After PyCharm is installed, enter the software and create the first program.
- Click the PyCharm icon on the desktop to enter PyCharm, as shown in the figure below, and click
New Project:

- After clicking, find
Interpreter, start setting the interpreter, and clickAdd Interpreter:

- Click
New, find the python.exe storage location, and check theInherit global site-packageoption:

- Set
Location. Location is where the PyCharm project is stored. You can choose it according to your needs.

- Create a new PyCharm file. Right-click the document icon pointed by the arrow, click
New, clickPython File, and the new file is created successfully.

- Name Python File:

- After the file is successfully created, you will enter the following interface and you can write your own program

Before Use
Firmware burning. Firmware refers to the device "driver" stored inside the device. Only through firmware can the operating system implement the operation of a specific machine according to the standard device driver. Different versions of the robot arm need to burn different firmware (refer to the MyStudio chapter).
ultraArm_P1_lib installation. Open a console terminal (shortcut Win+R, enter cmd to enter the terminal), and enter the following command:
pip install ultraArm_P1_lib --upgrade --user

The following words appear, indicating that the ultraArm_P1_lib package has been successfully installed

- Source code installation. Open a console terminal (shortcut Win+R, enter cmd to enter the terminal), enter the following command to install:
git clone -b develop https://github.com/elephantrobotics/ultraArm_P1_lib.git <your-path>
#Where <your-path> fills in your installation address, if not filled in, the current path is used by default
cd <your-path>/ultraArm_P1_lib
#Enter the ultraArm_P1_lib folder of the download package
#Run one of the following commands according to your python version
# Install
python2 setup.py install
# or
python3 setup.py install
Simple Use Of Python
After the above preparations are completed, start to control the robot arm through Python code. Here, the ultraArm P1 version is used as an example for demonstration.
First, open the PyCharm you installed, create a new Python file, enter the following code, and import our library:
from ultraArm_P1_lib import UltraArmP1
Note:
If you enter
from ultraArm_P1_lib import UltraArmP1, there is no red wavy line under the font, which proves that it has been successfully installed and can be used. If a red wavy line appears, you can refer to How to install the API library , How to call the API library.If you do not want to install the API library through the above command, you can download the project to your local computer through the following github.
First, go to the project address: https://github.com/elephantrobotics/ultraArm_P1_lib. Then click the Code button on the right side of the webpage, and then click Download ZIP to download it locally. Put the ultraArm_P1_lib folder in the compressed package ultraArm_P1_lib file project into your python dependency library directory, and you can directly import and use it.

Preparation Before Use
Before using Case Function I, please ensure the following hardware and environment are ready:
Hardware Equipment
ultraArm P1 robotic arm
USB-Type-C serial cable (for connecting the robotic arm to the computer)
Power adapter
Software and Environment
Python 3.6 or later is installed
The
ultraArm_P1_liblibrary is installed (installed via the terminal commandpip install ultraArm_P1_lib)Ensure the ultraArm P1 is properly powered on and in standby mode
Simple Demonstration
from ultraArm_P1_lib import UltraArmP1
# Modify the serial port number according to your actual situation; the baud rate is 1000000 by default
ua = UltraArmP1("COM3",1000000)
# Get the current joint angle
res = ua.get_angles_info()
print(res)
# Set the angles to zero, speed 50
ua.set_angles([0, 0, 90, 0],50)

