Skip to main content

Staubli Robot Communication SDK for Python

PyPI PyPI downloads Python Platforms License

UnderAutomation.Staubli is a Python package that communicates with Staubli CS8 and CS9 robot controllers through the SOAP server of the controller. Nothing is installed on the controller. No other Staubli software is needed on the PC.

Use it to read the robots and the controller parameters, read positions, compute the kinematics, move the robot, read and write I/O, manage VAL 3 applications and tasks, and transfer the files of the controller, from a Python script.

How it works

The package wraps the .NET library UnderAutomation.Staubli.dll with pythonnet. The DLL is inside the package: pip install installs everything, including pythonnet.

  • Windows: the DLL runs on the .NET Framework 4.x of Windows. Nothing else to install.

  • Linux and macOS: install the .NET runtime (for example .NET 8), then tell pythonnet to use it before you start Python:

    export PYTHONNET_RUNTIME=coreclr
    

    Without this variable, pythonnet uses Mono, its default runtime on Linux and macOS. You can also choose the runtime in your code, before the first import of the package:

    from pythonnet import load
    load("coreclr")
    

Installation

Python 3.7 to 3.13 is supported (the limit of pythonnet 3.0.5). Install the package in a virtual environment:

python -m venv .venv
# Windows
.venv\Scripts\activate
# Linux and macOS
source .venv/bin/activate

pip install UnderAutomation.Staubli

Or install it from the sources of this repository:

git clone https://github.com/underautomation/Staubli.py.git
cd Staubli.py
pip install -e .

Getting started

from underautomation.staubli.staubli_controller import StaubliController
from underautomation.staubli.connection_parameters import ConnectionParameters

# The SDK runs in trial mode for 30 days. Register your key to remove the trial limit.
# StaubliController.register_license("Your Company", "your-license-key")

parameters = ConnectionParameters("192.168.0.254")
parameters.soap.user = "default"      # user of the controller
parameters.soap.password = "default"
parameters.soap.port = 0              # 0 (default): automatic, 851 on a real controller

controller = StaubliController()
controller.connect(parameters)

joints = controller.soap.get_current_joint_position(0)
print(list(joints))

controller.disconnect()

parameters.ping_before_connect (True by default) pings the controller before the connection.

To connect to a controller emulated by Staubli Robotics Suite, give the path of its .controller file as address (for example C:\...\MyCell\Controller1\Controller1.controller, or a UNC path when the emulator runs on another PC). With the SOAP port 0, the SDK reads the SOAP port of the emulated controller in its configuration (usr\configs\network.cfx), and uses 851 when it is not found.

From .NET names to Python names

The Python API is the .NET API with Python names. The .NET documentation applies to Python.

.NET Python
Method GetCurrentJointPosition(0) get_current_joint_position(0)
Property Soap.User soap.user
Static method StaubliController.RegisterLicense(...) StaubliController.register_license(...)
Enum value LicenseState.Trial LicenseState.Trial (an IntEnum)
Array double[] list-like object, use list(...) to copy it
Nullable<int> int | None

Each type is in the module named after it, in snake case: UnderAutomation.Staubli.Soap.Data.MotionDesc is underautomation.staubli.soap.data.motion_desc.MotionDesc.

Features

Everything is reached through controller.soap, except the files: controller.file.

Controller and robots

robots = controller.soap.get_robots()
for parameter in controller.soap.get_controller_parameters():
    print(parameter.name, parameter.value)

dh = controller.soap.get_dh_parameters(0)
joint_range = controller.soap.get_joint_range(0)

Positions and kinematics

joints = controller.soap.get_current_joint_position(0)

position = controller.soap.get_current_cartesian_joint_position(0)
print(position.cartesian_position.x, position.cartesian_position.y, position.cartesian_position.z)

# Joints to frame, then frame to joints
fk = controller.soap.forward_kinematics(0, joints)
ik = controller.soap.reverse_kinematics(0, joints, fk.position, fk.config, joint_range)
print(list(ik.joint), ik.result)

Motion

from underautomation.staubli.soap.data.motion_desc import MotionDesc
from underautomation.staubli.soap.data.frame import Frame

mdesc = MotionDesc()
mdesc.velocity = 50               # % of the nominal joint speed
mdesc.acceleration = 100          # %
mdesc.deceleration = 100          # %
mdesc.translation_velocity = 250  # mm/s
mdesc.rotation_velocity = 100     # deg/s
mdesc.tool = Frame()
mdesc.frame = Frame()
mdesc.frequency = 100             # interpolation frequency in %, 0 is refused by the controller

controller.soap.set_power(True)

result = controller.soap.move_jj(0, [0, 0, 90, 0, 90, 0], mdesc)
print(result.return_code)

target = Frame()
target.px, target.py, target.pz = 300, 0, 450
controller.soap.move_l(0, target, mdesc)

controller.soap.stop_motion()
controller.soap.set_power(False)

Inputs / Outputs

for io in controller.soap.get_all_physical_ios():
    print(io.name, io.type_str, io.description)

states = controller.soap.read_ios(["BasicDO_1"])
print(states[0].value, states[0].state)

responses = controller.soap.write_ios(["BasicDO_1"], [1.0])

VAL 3 applications and tasks

controller.soap.load_project("Disk://myProject/myProject.pjx")
for application in controller.soap.get_val_applications():
    print(application.name, application.loaded, application.is_running)

for task in controller.soap.get_tasks():
    print(task.name, task.state, task.created_by)

controller.soap.stop_and_unload_all()

Files

The file client is disabled by default. On a real controller, it uses the FTP server of the controller (port 21, user and password of the FTP server). The emulator of Staubli Robotics Suite has no FTP server: give the path of the .controller file of the emulated controller as address (a UNC path when the emulator runs on another PC). The files are read and written in the folder of this file, which has the same tree as the FTP server of a real controller. The paths are the same in both cases. The VAL 3 applications are in /usr/usrapp, one sub-folder per application: /usr/usrapp/myApp/myApp.pjx is the project Disk://myApp/myApp.pjx.

from underautomation.staubli.staubli_controller import StaubliController
from underautomation.staubli.connection_parameters import ConnectionParameters

parameters = ConnectionParameters("192.168.0.254")  # or r"C:\SRS\MyCell\Controller1\Controller1.controller"
parameters.file.enable = True
parameters.file.user = "default"
parameters.file.password = "default"

controller = StaubliController()
controller.connect(parameters)

for item in controller.file.get_listing("/usr/usrapp"):
    print(item.full_name, item.type, item.size)

controller.file.upload_file_to_controller(r"C:\Data\points.dat", "/usr/usrapp/myApp/points.dat")
content = controller.file.download_bytes_from_controller("/usr/usrapp/myApp/myApp.pjx")

# Send a complete application: C:\MyApps\myApp is copied to /usr/usrapp/myApp
controller.soap.stop_and_unload_all()
controller.file.upload_application_to_controller(r"C:\MyApps\myApp")
controller.soap.load_project("Disk://myApp/myApp.pjx")

controller.disconnect()

Examples

The folder examples contains scripts ready to run. The first run asks the address of the controller, the SOAP user, the password and the port, and saves them in examples/robot_config.json. It also checks the license and asks a key when the trial has ended.

Script What it does
examples/controller/controller_info.py Controller parameters, robots, DH parameters and joint ranges.
examples/motion/motion_move_robot.py Positions, forward and inverse kinematics, then a joint move to the zero position.
examples/io/io_read.py Lists the physical I/O, then reads the I/O you choose.
examples/io/io_write.py Lists the physical I/O, then writes the I/O you choose.
examples/applications/applications_load_start.py Lists the VAL 3 applications, loads and starts a project, then suspends, resumes and kills its task.
examples/files/files_explorer.py Console explorer of the files of the controller: list, open folders, download, upload, create, rename, delete.
examples/files/files_upload_application.py Sends the folder of a VAL 3 application to /usr/usrapp, then loads and starts the project.
examples/files/files_backup_applications.py Downloads all the VAL 3 applications of /usr/usrapp to a folder of the PC.

The files examples also ask the user and the password of the FTP server of the controller. For the emulator of Staubli Robotics Suite, give the path of the .controller file of the emulated controller as address: the files are then read and written in the folder of this file.

Run a script from the root of the repository:

python examples/controller/controller_info.py

examples/motion/motion_move_robot.py moves the robot. Check the surroundings of the robot first.

Compatibility

  • Python: 3.7 to 3.13, with pythonnet 3.0.5.
  • Operating systems: Windows (.NET Framework), Linux and macOS (.NET runtime and export PYTHONNET_RUNTIME=coreclr).
  • Controllers: Staubli CS8 and CS9, and the emulator of Staubli Robotics Suite.

License

This SDK needs a commercial license. A 30-day trial starts at the first use, no key needed. After the trial, register your key in your code:

from underautomation.staubli.staubli_controller import StaubliController

license_info = StaubliController.register_license("Your Company", "your-license-key")
print(license_info.state)

Support

Metadata

Release files for UnderAutomation.Staubli 1.0.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for UnderAutomation.Staubli 1.0.0.0
File Size Uploaded
underautomation_staubli-1.0.0.0.tar.gz 168.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for UnderAutomation.Staubli 1.0.0.0
File Interpreter ABI Platform
underautomation_staubli-1.0.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 392.0 kB

Release files / underautomation_staubli-1.0.0.0.tar.gz

Download URL underautomation_staubli-1.0.0.0.tar.gz
Size 168.0 kB
Tags Source
SHA-256 checksum
How to use checksums
b3307798e6422917235d528ecd647846f4794fb077a2134e5ab35bc4a5f89048
BLAKE2b-256 checksum
How to use checksums
9266f198a88556188c31b185deff5166ee304f47f45efcc7ff077c8252cd35cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / underautomation_staubli-1.0.0.0-py3-none-any.whl

Download URL underautomation_staubli-1.0.0.0-py3-none-any.whl
Size 223.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
15943eee5e3b0dee36edfabdd7d68d5e08e567c45b8eb524060163dfad0222df
BLAKE2b-256 checksum
How to use checksums
2b9780a88df87b9007953283af18a5d1f90034f555d41f16a1ab78d44a0503d9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

1.0.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page