airobot.utils.urscript_util

Tools for creating URScript messages, for communicating with the real UR robots over TCP/IP by creating URScript programs and sending them for execution on the robot’s system

built off of urscript.py, part of python-urx library (https://github.com/SintefManufacturing/python-urx)

class airobot.utils.urscript_util.Robotiq2F140URScript(socket_host, socket_port, socket_name)[source]

Bases: airobot.utils.urscript_util.URScript

Class for creating Robotiq 2F140 specific URScript messages to send to the UR robot, for setting gripper related variables

Parameters:
  • socket_host (str) – gripper IP address used by the UR controller
  • socket_port (int) – gripper communication port used by the UR controller
  • socket_name (str) – name of the socket connection
set_activate()[source]

Activate the gripper, by setting some internal variables on the UR controller to 1

set_gripper_force(force)[source]

Set maximum gripper force

Parameters:force (int) – Desired maximum gripper force, ranges from 0-255
set_gripper_position(position)[source]

Control the gripper position by setting internal position variable to desired position value on UR controller

Parameters:position (int) – Position value, ranges from 0-255
set_gripper_speed(speed)[source]

Set what speed the gripper should move

Parameters:speed (int) – Desired gripper speed, ranges from 0-255
class airobot.utils.urscript_util.URScript[source]

Bases: object

Class for creating urscript programs to send to the UR5 controller

__init__()[source]

Constructor, each urscript has a header and a program that runs on the contoller

constrain_unsigned_char(value)[source]

Ensure that unsigned char values are constrained to between 0 and 255.

Parameters:value (int) – Value to ensure is between 0 and 255
reset()[source]

Reset the urscript to empty

sleep(value)[source]

Add a sleep command to urscript program, sleep for a specified amount of time

Parameters:value (float) – Amount of time in seconds for program to sleep
socket_close(socket_name)[source]

Add a close socket command to urscript program.

Parameters:socket_name (str) – Name of socket to close (must be same as name of socket that was opened previously)
socket_get_var(var, socket_name)[source]

Add a command to the program with communicates over a socket connection to get the value of a variable

Parameters:
  • var (str) – Name of the variable to obtain the value of
  • socket_name (str) – Which socket connection to use for getting the value (must be same as name of socket that was opened previously)
socket_open(socket_host, socket_port, socket_name)[source]

Add a open socket command to urscript program with specified host, port, and name

Parameters:
  • socket_host (str) – Host address
  • socket_port (int) – Port to open
  • socket_name (str) – Name of the socket to use when interacting with the socket after it is opened
socket_set_var(var, value, socket_name)[source]

Add a command to the program with communicates over a socket connection to set the value of a variable

Parameters:
  • var (str) – Name of the variable to obtain the value of
  • value (int) – Value to set the variable to
  • socket_name (str) – Which socket connection to use for getting the value (must be same as name of socket that was opened previously)
sync()[source]

Add a sync command to the myProg() urscript program