Universal Robots Library

LEonard's Universal Robot Library

Lecky Engineering provides a full featured interface to Universal Robots that allows you to control motion and I/O through any of the LEonard scripting languages.

Our system also provides geometry-independent control to allow easy operation on flat, cylindrical, or spherical surfaces

The system provides for saving and moving to locations, incremental and relative moves along the part surface, and general computation and control of speeds and accelerations while moving along curved surfaces.


Adding UR Dashboard and Command Devices to LEonard

Yup, it's that easy... add the supplied LEonard01.urp PolyScope program onto the robot and you're ready to go

Real-Time Monitoring

LEonard provides real-time monitoring, error reset, and file management capabilities for your Universal Robot!

Jogging in Base, Tool, or Part Coordinates

Really nice to have full Freedrive control here, too.

LElib.UR Library for Universal Robots

These functions work with Universal Robots robotic systems. The commands fall into three categories

1. Dashboard

2. Command Interface to Lecky Engineering’s LEonard01.urp PolyScope program

3. Grinding Package for force-controlled surface following

LElib.UR.dashboard: Commands to control the UR dashboard

The UR robot provides a dashboard interface that allows controlling the robot operation.

string ur_dashboard(string message, int timeout_ms)

Sends the command message to the currently selected Universal Robot dashboard connection and waits for up to timeout_ms milliseconds for a response.

Response:

LEScript: Any response received is placed in the variable ur_dashboard_response

Java, Python: Function returns any string received or and empty string.

The UR dashboard system provides many commands that are useful in loading, starting, and stopping the robot. The Run tab in LEonard uses robotmode to determine whether the robot has booted, and regularly sends robotmode, safetystatus, and programstate to keep an eye on the robot.

When you press the Robot Mode button, LEonard cycles through the robot modes as appropriate- RUNNING initiates sending power off. IDLE initiates sending brake release. And POWER_OFF initiates sending power on. This allows you to cycle through UR operating modes.

The Safety Status button sends unlock protective stop and close safety popup when the robot is in safety stop but not in E-Stop.

The Program State button toggles between sending play and stop to start and stop the loaded PolyScope program. The UR Dashboard device sends a load JobFile command when the UR connects with the dashboard to get your default PolyScope program loaded.

A comprehensive discussion of the dashboard interface is available on the UR website:

https://www.universal-robots.com/articles/ur/dashboard-server-e-series-port-29999/

Here are the handiest ones that are used internally by LEonard!

Useful UR Dashboard Commands

get robot model Returns robot model number, as in “UR5”

get serial number Returns robot serial number, for example “20195501xxxx”

PolyscopeVersion Returns PolyScope version installed on robot

power on Power system up

brake release Release from IDLE to READY

load LEonard/LEonard01.urp Load a PolyScope program (default shown)

play Start it

close popup Close a popup prompt on the pendant

close safety popup Close a safety popup prompt on the pendant

unlock protective stop Recover from E-stop or safety stop

stop Stop execution of the program

robotmode Get mode POWER_OFF POWER_ON BOOTING IDLE RUNNING

programstate Return program state STOPPED file PLAYING file

power off Power servos down (and put brakes on)


LElib.UR.robot: The UR Robot PolyScope Interface

Lecky Engineering supplies an extensive PolyScope program that supports robot control and grinding functions. This code is supplied with the LEonard installation and must be installed on the UR robot.

Getting robot communications working is discussed in Basic Ethernet Connection and The LEonard Interface.

Installation of the code on the robot is discussed in Installing Programs on the UR

select_tool(string tool_name)

Setup all the necessary environment to be able to use tool_name. No motion is performed. Future tool moves, position moves, and grinds will assume this tool is attached.

set_part_geometry(string FLAT|CYLINDER|SPHERE, double part_diam_mm)

Future tool moves and grinds will assume the specified geometry.

save_position(position_name)

The current robot position is stored in the Positions Table as position_name.

move_linear(position_name)

The robot moves along a linear path to Position position_name.

move_joint(position_name)

The robot performs a joint move to Position position_name.

move_relative(dx_mm, dy_mm)

Move (dx_mm, dy_mm) relative to current tool position. If the part geometry selected is CYLINDER or SPHERE, robot moves along the part.

move_tool_home()

Perform a joint move to the home position associated with the current tool.

move_tool_mount()

Perform a joint move to the mounting position associated with the current tool.

free_drive(0=OFF|1=ON)

Turn robot free drive mode on or off.

The commands below provide a programmatic way to set the default motion parameters.

set_linear_speed(speed_mm/s)

Sets default linear speed used for robot linear moves.

set_linear_accel(accel_mm/s^2)

Sets default linear acceleration used for robot linear moves.

set_joint_speed(speed_deg/s)

Sets default joint speed used for robot joint moves.

set_joint_accel(double accel_deg/s^2)

Sets default joint acceleration used for robot joint moves.

set_blend_radius(double blend_radius_mm)

Sets default blend radius used in all robot moves.

get_actual_tcp_pose()

Ask the current robot to perform get_actual_tcp_pose() and return the value in the LEonard variable actual_tcp_pose.

get_target_tcp_pose()

Ask the current robot to perform get_target_tcp_pose() and return the value in the LEonard variable target_tcp_pose.

get_actual_joint_positions()

Ask the current robot to perform get_actual_joint_positions() and return the value in the LEonard variable actual_joint_positions.

get_target_joint_positions()

Ask the current robot to perform get_target_joint_positions() and return the value in the LEonard variable target_joint_positions.

get_actual_both()

Performs both get_actual_joint_positions() and get_actual_tcp_pose() on the current robot and return the values to the LEonard variables actual_joint_positions and actual_tcp_pose.

get_target_both()

Performs both get_target_joint_positions() and get_target_tcp_pose() on the current robot and return the values to the LEonard variables target_joint_positions and target_tcp_pose.

movej(double j1, j2, j3, j4, j5, j6)

Performs a movej to joint positions on the current robot as follows:

q = [j1, j2, j3, j4, j5, j6]

movej(q, a=robot_joint_accel_rpss, v=robot_joint_speed_rps)

movel(double x, y, z, rx, ry, rz)

Performs a movel to a pose on the current robot as follows:

p = p[x, y, z, rx, ry, rz]

movej(q, a=robot_joint_accel, v=robot_joint_speed)

get_tcp_offset()

Ask the current robot to perform get_tcp_offset() and return the value in the LEonard variable tcp_offset.

movel_incr_base(double x,y,z,rx,ry,rz)

Ask the current robot to move incrementally from the current position in base coordinates as in URScript:

local p0 = get_target_tcp_pose()

local p1 = p[x,y,z,dx,dy,dz]

local p2 = pose_add(p0, p1)

if p1[0] == 0 and p1[1] == 0 and p1[2] == 0: # Rotational move

movel(p2, robot_joint_accel_rpss, robot_joint_speed_rps)

else:

movel(p2, robot_linear_accel_mpss, robot_linear_speed_mps)

end

movel_incr_tool(double x,y,z,rx,ry,rz)

Ask the current robot to move incrementally from the current position in TCP coordinates as in URScript:

local p1 = p[x,y,z,rx,ry,rz]

local p2 = pose_trans(get_target_tcp_pose(), p1)

if p1[0] == 0 and p1[1] == 0 and p1[2] == 0: # Rotational move

movel(p2, robot_joint_accel_rpss, robot_joint_speed_rps)

else:

movel(p2, robot_linear_accel_mpss, robot_linear_speed_mps)

end

movel_incr_part(x,y,z,rx,ry,rz)

Ask the current robot to move incrementally from the current position in PART coordinates. X and Y are interpreted based on set_part_geometry(…). For cylinders, X is along the axis of the cylinder and Y is interpreted as a fixed-distance rotation about the cylinder.

movel_single_axis(axis,value)

Ask the current robot to move to its current pose with the coordinate axis changed to value.

movel_rot_only(rx,ry,rz)

Ask the current robot to move to its current pose with the new rotations rx, ry, and rz.

movel_rel_set_tool_origin(double x,y,z,rx,ry,rz)

movel_rel_set_tool_origin_here()

Sets a tool-coordinate origin for the current robot either to a specified pose or to the current robot position. Subsequent calls to movel_rel_tool() will move in tool coordinates relative to this origin.

movel_rel_tool(x,y,z,rx,ry,rz)

Move to a tool coordinate position that is relative to the movel_rel_set_tool_origin.

movel_rel_set_part_origin(x,y,z,rx,ry,rz)

movel_rel_set_part_origin_here()

Sets a part-coordinate (FLAT, CYLINDER, or SPHERE) origin for the current robot either to a specified pose or to the current robot position. Subsequent calls to movel_rel_part() will move in part coordinates relative to this origin.

movel_rel_part(x,y,z,rx,ry,rz)

Move to a part coordinate position that is relative to the movel_rel_set_part_origin.

send_robot(string message)

Sends any command to the Lecky Engineering PolyScope program. All communications with the Lecky Engineering PolyScope program is handled by this command.

1. Commands are sent with a message ID and a checksum as follows:

a. (ID, checksum, message)

2. ID can be any integer. LEonard sends an incrementing number between 100 and 999.

3. Checksum is expected to be 1000 – ID.

4. message is typically 1 or more comma-separated numeric values.

5. The command is non-blocking.

6. The PolyScope program is expected to send a start message:

robot_starting = ID

robot_ready = False

7. After the command is complete, the PolyScope program is expected to send back the following:

robot_response = response_message

robot_ready=True

robot_completed = ID (as it was received)

In addition, the UR Command device runs the general CallBack, so the UR robot can return LeonardMessages to set variables or trigger other actions in LEonard at any time.

set_output(int port, bool value)

Set UR digital output port to value.

robot_socket_reset()

Commands the Lecky Engineering UR PolyScope program to reset (bounce) its socket connection to LEonard. Program must be running on the UR!

robot_program_exit()

Commands the Lecky Engineering UR PolyScope program to terminate. Program must be running on the UR!

Low-level Setup Calls

These are all called automatically by select_tool(), set_part_geometry(),and the grind_xxx() functions. They should be used through that high level interface except during testing or for special purposes!

set_tcp(x,y,x,rx,ry,rz)

Executes set_tcp(p[x,y,z,rx,ry,rz]) on the current robot only if x > 10. Always returns the current get_tcp_offset() in the LEonard variable robot_tcp.

set_payload(mass_kg,cog_x_m, cog_y_m, cog_z_m)

Executes set_paylod(mass_kg, [cog_x_m, cog_y_m, cog_z_m]) on the current robot only if mass_kg > 0. Always returns the current robot_payload_mass_kg and robot_paylod_cog_m in corresponding LEonard variables.

set_door_closed_input(int dig_in, int state)

Specifies what digital input and state is expected to signify that the door is closed to the current robot.

set_footswitch_pressed_input(int dig_in, int state)

Specifies what digital input and state is expected to signify that the footswitch is pressed on the current robot.

set_tool_on_outputs(int dig_out, int state, …)

Sets a set of digital output,state pairs (1 – 4) to specify what outputs should be controlled when tool_on() is executed on the current robot.

set_tool_off_outputs(int dig_out, int state, …)

Sets a set of digital output,state pairs (1 – 4) to specify what outputs should be controlled when tool_off() is executed on the current robot.

set_coolant_on_outputs(int dig_out, int state, …)

Sets a set of digital output,state pairs (1 – 4) to specify what outputs should be controlled when coolant_on() is executed on the current robot.

set_coolant_off_outputs(int dig_out, int state, …)

Sets a set of digital output,state pairs (1 – 4) to specify what outputs should be controlled when coolant_off() is executed on the current robot.

tool_on()

Performs the tool_on output list set in set_tool_on_outputs() on the current robot.

tool_off()

Performs the tool_off output list set in set_tool_off_outputs() on the current robot.

coolant_on()

Performs the coolant_on output list set in set_coolant_on_outputs() on the current robot.

coolant_off()

Performs the coolant_off output list set in set_coolant_off_outputs() on the current robot.