UnderAutomation.UniversalRobots


NameUnderAutomation.UniversalRobots JSON
Version 7.8.0.5 PyPI version JSON
download
home_pagehttps://underautomation.com/universal-robots
SummaryQuickly create applications that communicate with your Universal Robots cobot
upload_time2024-09-03 20:31:04
maintainerNone
docs_urlNone
authorUnderAutomation
requires_python>=3.7
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![Python](https://img.shields.io/badge/Python-3.5_|_3.6_|_3.7_|_3.8|_3.9_|_3.10_|_3.11_|_3.12_-blue)](#)

# Universal Robots communication SDK

Quickly create applications that communicate with an [Universal Robots](https://www.universal-robots.com) industrial robot.

SDK : Software Development Kit

More information : [https://underautomation.com](https://underautomation.com)


[![UnderAutomation Universal Robots communication SDK](https://user-images.githubusercontent.com/47540360/136141853-1ec87530-d88e-467f-adb4-ec3c46d26010.png)](https://underautomation.com)


https://user-images.githubusercontent.com/47540360/143318635-6d6aaaf4-5642-457a-8ff1-4322f2defe82.mp4

## Try it
From Pypi :
```
pip install UnderAutomation.UniversalRobots
```

From this repo :
```
git clone https://github.com/underautomation/UniversalRobots.py.git
```

Import features :
```py
from underautomation.universal_robots.ur import UR
from underautomation.universal_robots.connect_parameters import ConnectParameters
from underautomation.universal_robots.common.pose import Pose
from underautomation.universal_robots.rtde.rtde_input_data import RtdeInputData
from underautomation.universal_robots.rtde.rtde_output_data import RtdeOutputData
from underautomation.universal_robots.rtde.rtde_input_values import RtdeInputValues
# from underautomation.universal_robots... import ...
# etc.
```

## Features

### RTDE and Primary Interface
Full support for :
- RTDE (Real-Time Data Exchange) : read and write registers up to 500Hz
- Primary Interface : 
  - Receive robot state data at 10Hz : Cartesian and angular position, robot status, inputs and outputs value, and 100+ more measurements ...
  - Send URScript
  - Get variables

``` py
# Create a robot instance
robot = UR()

# Setup connection to th robot
param = ConnectParameters()
param.ip = "192.168.0.1"

# Enable primary interface to get variable values
param.primary_interface.enable = True

# Enable rtde at 5Hz (500Hz possible)
param.rtde.enable = True
param.rtde.frequency = 5

# Ask the robot for permission to write these registers
param.rtde.input_setup.add(RtdeInputData.StandardAnalogOutput0)
param.rtde.input_setup.add(RtdeInputData.InputBitRegisters, 64)

# Ask the robot to send me this data
param.rtde.output_setup.add(RtdeOutputData.ActualTcpPose)
param.rtde.output_setup.add(RtdeOutputData.ActualTcpForce)

# Connect to the robot
robot.connect(param)

# Function called when new RTDE data is received
def on_output_data_received(o, e):
    ##
    # Display robot TCP pose
    pose = robot.rtde.output_data_values.actual_tcp_pose
    # pose.X, pose.Y, pose.Z, pose.Rx, ...

    # Display robot TCP force
    force = robot.rtde.output_data_values.actual_tcp_force

    # Write data in robot controler
    inputs = RtdeInputValues()
    inputs.standard_analog_output0 = 0.2
    inputs.input_bit_registers.x64 = True
    robot.rtde.write_inputs(inputs)
    ##

# Event raised when data is received
robot.rtde.output_data_received(on_output_data_received)

# Function called when any program or installation variable changes in the robot
def on_value_updated(p, e):
    ##
    # Display all program and installation variables
    variables = robot.primary_interface.global_variables.get_all()
    name = variables[0].name
    value = variables[0].to_pose()
    type = variables[0].type
    ##    

# Event raised when a program or installation variable change
robot.primary_interface.global_variables.values_updated(on_value_updated)


# Function called when masterboard data is received
def on_masterboard_data_received(p, e):
    ai0 = robot.primary_interface.masterboard_data.analog_input0
    di2 = robot.primary_interface.masterboard_data.digital_inputs.digital2

# Several other events are raised by primary interface
robot.primary_interface.masterboard_data_received(on_masterboard_data_received)

# Function called when cartesian data is received
def on_cartesian_info_received(p, e):
    x = e.X
    tcpOffsetX = e.TCPOffsetX

robot.primary_interface.cartesian_info_received(on_cartesian_info_received)

# Function called when joint data is received
def on_joint_data_received(o,e):
    shoulderAngle = e.Shoulder.Position
    elbowMode = e.Elbow.JointMode
    wrist3Speed = e.Wrist3.ActualSpeed

robot.primary_interface.joint_data_received(on_joint_data_received)
```

### Read variables
Read program and installation variables :
``` py
myVar = robot.primary_interface.global_variables.get_by_name("myVar")
variables =  robot.primary_interface.global_variables.get_all()
```

### Dashboard Server
Remote control the robot : load, play, pause, and stop a robot program, power on and off, release brake, shutdown, ...
``` py
# Create a new robot instance
robot = UR()

# Setup connection to th robot
param = ConnectParameters("192.168.0.56")
param.dashboard.enable=True

# Connect to the robot
robot.connect(param)

# Display a popup on the pendant
robot.dashboard.show_popup("I just remote-controlled my robot!")

# Power on the robot arm and release brakes
robot.dashboard.power_on()
robot.dashboard.release_brake()

# Load program file to polyscope
robot.dashboard.load_program("fast_bin_picking.urp")

# Start the program
robot.dashboard.play()

# Get program name and state
state = robot.dashboard.get_program_state()
```

### XML-RPC
From your robot program, remote call a function implemented in your .NET program. For example, this allows you to request a position resulting from image processing.

Robot code (URScript) :
``` ruby
# Connect to the SDK and specifie the IP and port of the PC
rpc:=rpc_factory("xmlrpc","http://192.168.0.10:50000")

# Call method GetPose and wait for the reply. The replied pose will be assigned in variable "answer"
answer:=rpc.GetPose(100)
```

Python code :
``` py
# XML-RPC server on port 50000
parameters.xml_rpc.enable = True
parameters.xml_rpc.port = 50000

# Event callback :
# robot.xml_rpc.xml_rpc_server_request
```

### Socket communication
The library can start a communication. The robot can connect to your server and exchange custom data. 

Robot code (URScript) :
``` ruby
# Connect to robot socket server in URScript
socket_open("192.168.0.10", 50001)

# Raise event SocketRequest is your app
socket_send_string("Hello from robot")

# Raise event SocketGetVar is your app
var1 := socket_get_var("MY_VAR")
```

Python code :
 ``` py
robot = UR()

# Setup connection to th robot
param = ConnectParameters("192.168.0.1")

# Enable spcket server on port 50001
param.socket_communication.enable = True
param.socket_communication.port = 50001

# Connect to the robot
robot.connect(param)

##
# Function called when robot connects with URScipt function socket_open()
def on_socket_client_connection(o, e : SocketClientConnectionEventArgs):
    e.client.socket_write("Hello cobot <3")

robot.socket_communication.socket_client_connection(on_socket_client_connection)

# Function called when the robot sends a message with socket_write()
def on_socket_request(o,e:SocketRequestEventArgs):
    # Get robot message
    robotMessage = e.Message

robot.socket_communication.socket_request(on_socket_request)

# Send a message to all connected clients
robot.socket_communication.socket_write("123456")
##

# List of all connected clients
connectedClients = robot.socket_communication.connected_clients

# IP address and remote port of a client
clientEndpoint = connectedClients[0].end_point

# Send a message to a specific connected robot
connectedClients[0].socket_write("Hello robot [0]")

  # Handle client disconnection
def on_socket_client_disconnection(o,e):
    pass

connectedClients[0].socket_client_disconnection(on_socket_client_disconnection)
```

### SFTP
Manipulate files and folders of the robot via SFTP (Secure File Transfer Protocol) : download to the robot, import from the robot, rename, delete, move, list files in a folder...
``` py
robot = UR()

# Setup connection to th robot
param = ConnectParameters("192.168.0.1")

# Enable SFTP file access
param.ssh.enable_sftp = True

# Connect to the robot
robot.connect(param)

# Enumerates files and folder
items = robot.sftp.list_directory("/home/ur/ursim-current/programs/")

# Download program file prg.urp to your local disk
robot.sftp.download_file("/home/ur/ursim-current/programs/prg.urp", "C:\\temp\\prg.urp")

# Send a local file to the robot
robot.sftp.upload_file("C:\\temp\\prg.urp", "/home/ur/ursim-current/programs/prg.urp")

# Manipulate files and directories
robot.sftp.rename_file("/home/ur/prg.urp", "/home/ur/prg2.urp")
robot.sftp.delete("/home/ur/prg.urp")
exists = robot.sftp.exists("/home/ur/prg.urp")
robot.sftp.write_all_text("/home/ur/file.txt", "Hello robot !")
```

### SSH
Open a SSH (Secure Shell) connection with the robot to execute Linux command lines, as in the terminal.
``` py
robot.ssh.run_command("echo Hello > /home/ur/Desktop/NewFile.txt");
```

### Convert position types
Convert Rotation Vector to and from RPY.
``` py
# Create X, Y, Z, RX, RY, RZ pose
pose = Pose(0.1, 0.2, -0.1, 0, 0.05, 0.1)

# Convert cartesian pose type to RPY or rotation vector
rpy = pose.from_rotation_vector_to_rpy()
vectorPose = pose.from_rpy_to_rotation_vector()
```

### Edit program and installation files
Open and edit program (.urp) and installation (.installation) files :
``` py
# Decompile program and installation files and access inner XML
installation = URInstallation.load("C:\\temp\\default.installation")
prg = URProgram.load("C:\\temp\\prg.urp")
internalXml = prg.xml
```

## License
This SDK is a commercial library and a license *must* be purshased. Once acquired, any application you develop can be delivered to an unlimited number of customers without royalties and without recurring subscription.

More information : [https://underautomation.com](https://underautomation.com)


            

Raw data

            {
    "_id": null,
    "home_page": "https://underautomation.com/universal-robots",
    "name": "UnderAutomation.UniversalRobots",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": null,
    "author": "UnderAutomation",
    "author_email": "support@underautomation.com",
    "download_url": "https://files.pythonhosted.org/packages/1f/8a/cd41212b42abb9df491c81aa5eae14e85ed0cb97a739782cce56e4f071bb/underautomation_universalrobots-7.8.0.5.tar.gz",
    "platform": null,
    "description": "[![Python](https://img.shields.io/badge/Python-3.5_|_3.6_|_3.7_|_3.8|_3.9_|_3.10_|_3.11_|_3.12_-blue)](#)\n\n# Universal Robots communication SDK\n\nQuickly create applications that communicate with an [Universal Robots](https://www.universal-robots.com) industrial robot.\n\nSDK : Software Development Kit\n\nMore information : [https://underautomation.com](https://underautomation.com)\n\n\n[![UnderAutomation Universal Robots communication SDK](https://user-images.githubusercontent.com/47540360/136141853-1ec87530-d88e-467f-adb4-ec3c46d26010.png)](https://underautomation.com)\n\n\nhttps://user-images.githubusercontent.com/47540360/143318635-6d6aaaf4-5642-457a-8ff1-4322f2defe82.mp4\n\n## Try it\nFrom Pypi :\n```\npip install UnderAutomation.UniversalRobots\n```\n\nFrom this repo :\n```\ngit clone https://github.com/underautomation/UniversalRobots.py.git\n```\n\nImport features :\n```py\nfrom underautomation.universal_robots.ur import UR\nfrom underautomation.universal_robots.connect_parameters import ConnectParameters\nfrom underautomation.universal_robots.common.pose import Pose\nfrom underautomation.universal_robots.rtde.rtde_input_data import RtdeInputData\nfrom underautomation.universal_robots.rtde.rtde_output_data import RtdeOutputData\nfrom underautomation.universal_robots.rtde.rtde_input_values import RtdeInputValues\n# from underautomation.universal_robots... import ...\n# etc.\n```\n\n## Features\n\n### RTDE and Primary Interface\nFull support for :\n- RTDE (Real-Time Data Exchange) : read and write registers up to 500Hz\n- Primary Interface : \n  - Receive robot state data at 10Hz : Cartesian and angular position, robot status, inputs and outputs value, and 100+ more measurements ...\n  - Send URScript\n  - Get variables\n\n``` py\n# Create a robot instance\nrobot = UR()\n\n# Setup connection to th robot\nparam = ConnectParameters()\nparam.ip = \"192.168.0.1\"\n\n# Enable primary interface to get variable values\nparam.primary_interface.enable = True\n\n# Enable rtde at 5Hz (500Hz possible)\nparam.rtde.enable = True\nparam.rtde.frequency = 5\n\n# Ask the robot for permission to write these registers\nparam.rtde.input_setup.add(RtdeInputData.StandardAnalogOutput0)\nparam.rtde.input_setup.add(RtdeInputData.InputBitRegisters, 64)\n\n# Ask the robot to send me this data\nparam.rtde.output_setup.add(RtdeOutputData.ActualTcpPose)\nparam.rtde.output_setup.add(RtdeOutputData.ActualTcpForce)\n\n# Connect to the robot\nrobot.connect(param)\n\n# Function called when new RTDE data is received\ndef on_output_data_received(o, e):\n    ##\n    # Display robot TCP pose\n    pose = robot.rtde.output_data_values.actual_tcp_pose\n    # pose.X, pose.Y, pose.Z, pose.Rx, ...\n\n    # Display robot TCP force\n    force = robot.rtde.output_data_values.actual_tcp_force\n\n    # Write data in robot controler\n    inputs = RtdeInputValues()\n    inputs.standard_analog_output0 = 0.2\n    inputs.input_bit_registers.x64 = True\n    robot.rtde.write_inputs(inputs)\n    ##\n\n# Event raised when data is received\nrobot.rtde.output_data_received(on_output_data_received)\n\n# Function called when any program or installation variable changes in the robot\ndef on_value_updated(p, e):\n    ##\n    # Display all program and installation variables\n    variables = robot.primary_interface.global_variables.get_all()\n    name = variables[0].name\n    value = variables[0].to_pose()\n    type = variables[0].type\n    ##    \n\n# Event raised when a program or installation variable change\nrobot.primary_interface.global_variables.values_updated(on_value_updated)\n\n\n# Function called when masterboard data is received\ndef on_masterboard_data_received(p, e):\n    ai0 = robot.primary_interface.masterboard_data.analog_input0\n    di2 = robot.primary_interface.masterboard_data.digital_inputs.digital2\n\n# Several other events are raised by primary interface\nrobot.primary_interface.masterboard_data_received(on_masterboard_data_received)\n\n# Function called when cartesian data is received\ndef on_cartesian_info_received(p, e):\n    x = e.X\n    tcpOffsetX = e.TCPOffsetX\n\nrobot.primary_interface.cartesian_info_received(on_cartesian_info_received)\n\n# Function called when joint data is received\ndef on_joint_data_received(o,e):\n    shoulderAngle = e.Shoulder.Position\n    elbowMode = e.Elbow.JointMode\n    wrist3Speed = e.Wrist3.ActualSpeed\n\nrobot.primary_interface.joint_data_received(on_joint_data_received)\n```\n\n### Read variables\nRead program and installation variables :\n``` py\nmyVar = robot.primary_interface.global_variables.get_by_name(\"myVar\")\nvariables =  robot.primary_interface.global_variables.get_all()\n```\n\n### Dashboard Server\nRemote control the robot : load, play, pause, and stop a robot program, power on and off, release brake, shutdown, ...\n``` py\n# Create a new robot instance\nrobot = UR()\n\n# Setup connection to th robot\nparam = ConnectParameters(\"192.168.0.56\")\nparam.dashboard.enable=True\n\n# Connect to the robot\nrobot.connect(param)\n\n# Display a popup on the pendant\nrobot.dashboard.show_popup(\"I just remote-controlled my robot!\")\n\n# Power on the robot arm and release brakes\nrobot.dashboard.power_on()\nrobot.dashboard.release_brake()\n\n# Load program file to polyscope\nrobot.dashboard.load_program(\"fast_bin_picking.urp\")\n\n# Start the program\nrobot.dashboard.play()\n\n# Get program name and state\nstate = robot.dashboard.get_program_state()\n```\n\n### XML-RPC\nFrom your robot program, remote call a function implemented in your .NET program. For example, this allows you to request a position resulting from image processing.\n\nRobot code (URScript) :\n``` ruby\n# Connect to the SDK and specifie the IP and port of the PC\nrpc:=rpc_factory(\"xmlrpc\",\"http://192.168.0.10:50000\")\n\n# Call method GetPose and wait for the reply. The replied pose will be assigned in variable \"answer\"\nanswer:=rpc.GetPose(100)\n```\n\nPython code :\n``` py\n# XML-RPC server on port 50000\nparameters.xml_rpc.enable = True\nparameters.xml_rpc.port = 50000\n\n# Event callback :\n# robot.xml_rpc.xml_rpc_server_request\n```\n\n### Socket communication\nThe library can start a communication. The robot can connect to your server and exchange custom data. \n\nRobot code (URScript) :\n``` ruby\n# Connect to robot socket server in URScript\nsocket_open(\"192.168.0.10\", 50001)\n\n# Raise event SocketRequest is your app\nsocket_send_string(\"Hello from robot\")\n\n# Raise event SocketGetVar is your app\nvar1 := socket_get_var(\"MY_VAR\")\n```\n\nPython code :\n ``` py\nrobot = UR()\n\n# Setup connection to th robot\nparam = ConnectParameters(\"192.168.0.1\")\n\n# Enable spcket server on port 50001\nparam.socket_communication.enable = True\nparam.socket_communication.port = 50001\n\n# Connect to the robot\nrobot.connect(param)\n\n##\n# Function called when robot connects with URScipt function socket_open()\ndef on_socket_client_connection(o, e : SocketClientConnectionEventArgs):\n    e.client.socket_write(\"Hello cobot <3\")\n\nrobot.socket_communication.socket_client_connection(on_socket_client_connection)\n\n# Function called when the robot sends a message with socket_write()\ndef on_socket_request(o,e:SocketRequestEventArgs):\n    # Get robot message\n    robotMessage = e.Message\n\nrobot.socket_communication.socket_request(on_socket_request)\n\n# Send a message to all connected clients\nrobot.socket_communication.socket_write(\"123456\")\n##\n\n# List of all connected clients\nconnectedClients = robot.socket_communication.connected_clients\n\n# IP address and remote port of a client\nclientEndpoint = connectedClients[0].end_point\n\n# Send a message to a specific connected robot\nconnectedClients[0].socket_write(\"Hello robot [0]\")\n\n  # Handle client disconnection\ndef on_socket_client_disconnection(o,e):\n    pass\n\nconnectedClients[0].socket_client_disconnection(on_socket_client_disconnection)\n```\n\n### SFTP\nManipulate files and folders of the robot via SFTP (Secure File Transfer Protocol) : download to the robot, import from the robot, rename, delete, move, list files in a folder...\n``` py\nrobot = UR()\n\n# Setup connection to th robot\nparam = ConnectParameters(\"192.168.0.1\")\n\n# Enable SFTP file access\nparam.ssh.enable_sftp = True\n\n# Connect to the robot\nrobot.connect(param)\n\n# Enumerates files and folder\nitems = robot.sftp.list_directory(\"/home/ur/ursim-current/programs/\")\n\n# Download program file prg.urp to your local disk\nrobot.sftp.download_file(\"/home/ur/ursim-current/programs/prg.urp\", \"C:\\\\temp\\\\prg.urp\")\n\n# Send a local file to the robot\nrobot.sftp.upload_file(\"C:\\\\temp\\\\prg.urp\", \"/home/ur/ursim-current/programs/prg.urp\")\n\n# Manipulate files and directories\nrobot.sftp.rename_file(\"/home/ur/prg.urp\", \"/home/ur/prg2.urp\")\nrobot.sftp.delete(\"/home/ur/prg.urp\")\nexists = robot.sftp.exists(\"/home/ur/prg.urp\")\nrobot.sftp.write_all_text(\"/home/ur/file.txt\", \"Hello robot !\")\n```\n\n### SSH\nOpen a SSH (Secure Shell) connection with the robot to execute Linux command lines, as in the terminal.\n``` py\nrobot.ssh.run_command(\"echo Hello > /home/ur/Desktop/NewFile.txt\");\n```\n\n### Convert position types\nConvert Rotation Vector to and from RPY.\n``` py\n# Create X, Y, Z, RX, RY, RZ pose\npose = Pose(0.1, 0.2, -0.1, 0, 0.05, 0.1)\n\n# Convert cartesian pose type to RPY or rotation vector\nrpy = pose.from_rotation_vector_to_rpy()\nvectorPose = pose.from_rpy_to_rotation_vector()\n```\n\n### Edit program and installation files\nOpen and edit program (.urp) and installation (.installation) files :\n``` py\n# Decompile program and installation files and access inner XML\ninstallation = URInstallation.load(\"C:\\\\temp\\\\default.installation\")\nprg = URProgram.load(\"C:\\\\temp\\\\prg.urp\")\ninternalXml = prg.xml\n```\n\n## License\nThis SDK is a commercial library and a license *must* be purshased. Once acquired, any application you develop can be delivered to an unlimited number of customers without royalties and without recurring subscription.\n\nMore information : [https://underautomation.com](https://underautomation.com)\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Quickly create applications that communicate with your Universal Robots cobot",
    "version": "7.8.0.5",
    "project_urls": {
        "Documentation": "https://underautomation.com/universal-robots/documentation/get-started-python",
        "Homepage": "https://underautomation.com/universal-robots",
        "Source": "https://github.com/underautomation/UniversalRobots"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6542caac0f63dec09de6e24a66f901763e64403ebc6a4e900f8faf737589f74b",
                "md5": "de42b71f8efeba0111e6be011cf25f15",
                "sha256": "99f20cc2d2d6b5fd0359707249902a9491f87bb7ebab332c6cdf0b3930b25e71"
            },
            "downloads": -1,
            "filename": "UnderAutomation.UniversalRobots-7.8.0.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "de42b71f8efeba0111e6be011cf25f15",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 587301,
            "upload_time": "2024-09-03T20:31:02",
            "upload_time_iso_8601": "2024-09-03T20:31:02.269663Z",
            "url": "https://files.pythonhosted.org/packages/65/42/caac0f63dec09de6e24a66f901763e64403ebc6a4e900f8faf737589f74b/UnderAutomation.UniversalRobots-7.8.0.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1f8acd41212b42abb9df491c81aa5eae14e85ed0cb97a739782cce56e4f071bb",
                "md5": "d77f9b755b759c1ce081fa6cf73b61b7",
                "sha256": "50df0730b1ea4a8ca76e087f4b841672b24ab54c345f9e069e5359c4a7acd750"
            },
            "downloads": -1,
            "filename": "underautomation_universalrobots-7.8.0.5.tar.gz",
            "has_sig": false,
            "md5_digest": "d77f9b755b759c1ce081fa6cf73b61b7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 495820,
            "upload_time": "2024-09-03T20:31:04",
            "upload_time_iso_8601": "2024-09-03T20:31:04.134501Z",
            "url": "https://files.pythonhosted.org/packages/1f/8a/cd41212b42abb9df491c81aa5eae14e85ed0cb97a739782cce56e4f071bb/underautomation_universalrobots-7.8.0.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-03 20:31:04",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "underautomation",
    "github_project": "UniversalRobots",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "underautomation.universalrobots"
}
        
Elapsed time: 0.32899s