UnderAutomation
    • 홈페이지
  • 제품
    • Universal Robots SDK
      • 개요
      • 다운로드
      • 문서
        • Overview
        • Get started with .NET
        • Get started with LabVIEW
        • Get started with Python
        • Get started with Matlab
        • Connect to the robot
        • Configure the UR simulator (URSIM)
        • Licensing
        • RTDE : Real-Time Data Exchange
        • Primary Interface : Data streaming
        • Remote send script
        • Dashboard Server : Remote Commands
        • SFTP file handling
        • SSH Linux commands
        • XML-RPC
        • Interpreter Mode
        • Socket communication
        • Forward and Inverse Kinematics
        • Convert position types
        • Open and edit program and installation files
        • Reading & Writing Global Variables
        • Reading & Writing Registers
    • Fanuc SDK
    • Yaskawa SDK
    • Staubli SDK
    • 견적 • 주문
    • 라이선스
질문이요?

[email protected]

문의하기
UnderAutomation
  • 홈페이지
  • 제품
      • 개요
      • 다운로드
      • 문서
      • 개요
      • 다운로드
      • 문서
      • 개요
      • 다운로드
      • 문서
      • 개요
      • 다운로드
      • 문서
  • 견적 • 주문
  • 문의하기
⌘Q
This page is only available in English.
Universal Robots SDK documentation
Documentation home
Connect to the robot

Get started with Python

Quickly develop a program in Python that communicates with your robot using this library. It is available on PyPI.

  • Overview
  • Installation
  • Example

Overview

The Python library is under development. The goal is to provide an industrial library with the same functionality as in .NET while adapting the API to Python concepts.

We invite you to use the library in beta on GitHub.

See on Github : https://github.com/underautomation/UniversalRobots/tree/master/Python

Installation

Please install the following Python package:

pip install pythonnet

You must have .NET installed on your computer (Go to the Windows "Turn Windows feature on and off" screen and check ".NET Framework 3.5)

Example

from underautomation.universal_robots.ur import UR
from underautomation.universal_robots.urprogram import URProgram
from underautomation.universal_robots.urinstallation import URInstallation
from underautomation.universal_robots.pose import Pose
from underautomation.universal_robots.connect_parameters import ConnectParameters
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
robot = UR()
parameters = ConnectParameters("192.168.0.1")
# Enable Primary Interface
parameters.primary_interface.enable = True
# Select exchanged data
parameters.rtde.enable = True
parameters.rtde.frequency = 500 # Hz
parameters.rtde.input_setup.add(RtdeInputData.InputDoubleRegisters, 42)
parameters.rtde.input_setup.add(RtdeInputData.StandardAnalogOutput0)
parameters.rtde.input_setup.add(RtdeOutputData.ActualTcpPose)
parameters.rtde.input_setup.add(RtdeOutputData.ActualTcpSpeed)
parameters.rtde.input_setup.add(RtdeOutputData.ActualTcpForce)
parameters.rtde.input_setup.add(RtdeOutputData.ActualCurrent)
parameters.rtde.input_setup.add(RtdeOutputData.InputIntRegisters, 0)
# Enable Dashboard commands
parameters.dashboard.enable = True
# XML-RPC server on port 50000
parameters.xml_rpc.enable = True
parameters.xml_rpc.port = 50000
# Socket server on port 50001
parameters.socket_communication.enable = True
parameters.socket_communication.port = 50001
# Enable SSH commands and files
parameters.ssh.enable_ssh = True
parameters.ssh.enable_sftp = True
parameters.ssh.username = "ur"
parameters.ssh.password = "easybot"
# Connect to the robot
robot.connect(parameters)
#######################
# PRIMARY INTERFACE
#######################
# Get all program and installation variables
variables = robot.primary_interface.global_variables.get_all()
# Send and execute script on the robot
robot.primary_interface.send("movej([-1.5,-1.5,-2,-0.5,1.8,0],a=1.4, v=1.05, t=0, r=0)")
# robot.primary_interface.program_threads...
# robot.primary_interface.popup_message...
# robot.primary_interface.joint_data.elbow...
# robot.primary_interface.singularity_info
########################
# RTDE
#######################
# Real frequency of received data
frequency = robot.rtde.measured_frequency
# Access received data
actualTcpPoseZ = robot.rtde.output_data_values.actual_tcp_pose.z
actualTcpPoseX = robot.rtde.output_data_values.input_int_registers.x0
# Prepare input values
inputs = RtdeInputValues()
inputs.input_double_registers.x42 = -42.1
inputs.standard_analog_output0 = 0.5
# Write values to robot
robot.rtde.write_inputs(inputs)
########################
# DASHBOARD
#######################
# 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()
# Display a popup on the pendant
robot.dashboard.show_popup("I just remote-controlled my robot!")
########################
# SOCKET COMMUNICATION
#######################
# Get all client connected with URScript socket_open()
clients = robot.socket_communication.connected_clients
# Send message to all clients and reply "ok" when a message is received
robot.socket_communication.socket_write("Hello :) !")
########################
# SSH
#######################
# Ask robot linux controller to execute a shell command
command = robot.ssh.run_command("ping 192.168.0.2")
result = command.result
exitStatus = command.exit_status
########################
# SFTP
#######################
# List all files and directories in "programs" directory
items = robot.sftp.list_directory("/home/ur/ursim-current/programs/")
# Manipulates files and directories
# robot.Sftp.DownloadFile()
# robot.Sftp.UploadFile()
# robot.Sftp.CreateDirectory()
########################
# EDIT NATIVE FILES
#######################
# Manipulate and edit program and installation files
program = URProgram.load(r"C:\path\to\program.urp")
installation = URInstallation.load(r"C:\path\to\default.installation")
########################
# CONVERT POSE
#######################
# Convert pose types
pose = Pose(0.1, 0.2, -0.1, 0.01, 0, 1.1)
rpy = pose.from_rotation_vector_to_rpy()
rotationVector = pose.from_rotation_vector_to_rpy()
Documentation home
Connect to the robot

Universal Robots, Fanuc, Yaskawa 또는 Staubli 로봇을 .NET, Python, LabVIEW 또는 Matlab 애플리케이션에 쉽게 통합

UnderAutomation
문의하기Legal
제품
Universal Robots SDKFanuc SDKYaskawa SDKStaubli SDK
enEnglish
frFrançais
deDeutsch
esEspañol
zh中文
ja日本語
ko한국어

© All rights reserved.