Robpod Studio Docs
  • Get Started
    • Introduction
    • Download
    • Installation
      • Install Platform
      • Install Plugin
    • First Steps
      • Choose Studio Flavor
      • Welcome Screen
      • Create a Project
      • Create a Script
      • User Interface
      • New UI
      • Robpod Studio Assistant
    • License
      • Buy a License
      • Install a License
    • Safety
  • ROBOT
    • Robot Toolbar
      • Connect the Robot
      • Control the Robot
      • Get Positions
      • Move To
      • Run a Script
    • Robot Tool Window
      • Status
      • Teach Pendant Viewer
      • Variables
      • Digital I/O
      • Analog I/O
      • Debug
    • Robot Variables
    • Robot Logs
  • Advanced Scripting
    • Live Auto Completion
    • Templete Completion
    • Param Info
    • Code Inspections
    • Quick Doc
    • Python Scripting
    • Editor Settings
  • Synchronization
    • Upload On Robot
    • Download From Robot
    • Synchronize Project
    • Clean Robot Files
    • Synchronization Settings
  • Simulation
    • Connect a Simulator
    • Simulate a Script
    • Off-Line Programming
    • Simulator Viewer
    • Simulation Commands
    • Simulation Settings
    • Simulation Examples
      • Palletizing
  • HMI Designer
    • Introduction
    • User Interface
    • Installation
    • Design Steps
      • Create new HMI Panel
      • Add HMI Components
      • Edit HMI Components
      • Preview HMI Panel
      • Synchronize HMI Panel
      • Run HMI Program
    • HMI Components
    • HMI Charts
    • Display Conditions
    • HMI Commands
    • HMI Icon Generator
    • Desktop HMI Viewer
    • HMI and UR Polyscope
    • HMI and Doosan Robotics
    • HMI Tutorials
      • Beginner Tutorial
      • UR Polyscope Tutorial
      • Doosan Robotics Task Editor Tutorial
      • Doosan Robotics DRL Tutorial
    • Working Examples
      • Universal Robots
        • Pick and Place Example
        • Polishing Example
        • Machine Tending Example
        • Simple Pallet Example
        • Welding Example
        • Skrewdriving Example
        • Chart Monitoring Example
        • Production Mix Example
        • Pallet App Example
        • Camera QA Example
        • Assembly Example
      • Doosan Robotics
        • Pick and Place Example DR
  • Other
    • Updates
    • License FAQ
    • Customer Portal
  • LEGAL
    • License Agreement
    • Privacy Policy
    • Third Party Licenses
  • Appendix
    • Supported Robots
    • Robot Specific Functions
      • Universal Robots
        • URSim
    • Supported Simulators
    • Network Configuration
    • Security Settings
Powered by GitBook
On this page
  1. Advanced Scripting

Python Scripting

PreviousQuick DocNextEditor Settings

Last updated 2 months ago

All the Python programming features provided by are included with Robpod Studio.

Python scripting can be useful to develop client applications that control the robot or exchange data externally. In this scenario Robpod Studio can be used as an integrated platform to develop both native robot programs and external Python scripts, and test them in the same environment.

To create a new Python file:

  1. Right click on project folder -> New -> Python File.

  2. Enter the name of your script file.

You can work now with both robot native program and external Python scripts. If you want you could also display the two scripts side by side and work on them at the same time. To display a script in side by side mode:

Right click on script name, then select Open in Right Split.

To test the scripts you can run both of them at the same time:

Example: UR external motion control with a Python Script

In this example TCP socket comunication is used to share motion data between the robot program and a client Python script. In this way is possible to control the robot form an external application.

Robot Program

# Universal Robots script for controlling the robot with external python script
while True:
    if socket_open("192.168.1.67", 8888):
        while True:
            values = socket_read_ascii_float(8)
            joints = [values[1], values[2], values[3], values[4], values[5], values[6]]
            if values[0] > 6:
                textmsg("Moving to: ", joints)
                movej(joints, v=values[7], a=values[8])
            else:
                socket_close()
                break
            end
            socket_send_string("target_reached")
        end

    else:
        textmsg("Connecting...")
        sleep(1)
    end
end

External Client Script

import socket
# connect to robot
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.bind(('0.0.0.0', 8888))
server.listen()
connection, address = server.accept()


# function to send move commands
def movej(pose, v=1, a=1):
    print("Moving to: {}".format(pose))
    connection.send("({}, {}, {}, {}, {}, {}, {}, {})\n".format(pose[0], pose[1], pose[2], pose[3], pose[4], pose[5], v, a).encode())
    buf = connection.recv(128)
    if len(buf) > 0:
        print(buf.decode())


# movements
movej([0.00, -1.57, -1.57, 0.00, 1.57, 0.00])
movej([0.00, -1.57, 0, 0.00, 1.57, 0.00])
movej([0.00, -1.57, -1.57, 0.00, 1.57, 0.00])

To , click on the robot program name and selectRun On Robot

To execute the Python script: click on the python script name and select Run.

PyCharm IDE
execute the robot script