ur_cb2.send package

Submodules

ur_cb2.send.cb2_send module

A module to send commands to a UR robot

class ur_cb2.send.cb2_send.URSender(open_socket, verbose=False)[source]

Bases: object

A class to send commands to a UR CB2 Robot.

Acceleration, velocity, and the blend radius are all stored and reused for each command. There is a separate values of acceleration and velocity for joint motions and cartesian motions. The user should adjust the values for acceleration and velocity as needed.

__socket

The Socket used to connect to the robot

a_tool

Float, tool acceleration [m/s^2]

v_tool

Float, tool speed [m/s]

radius

Float, blend radius [m]. This allows the robots to miss points, so long as they are within the radius and continue moving. If you would like the robot to stop at every point, set this to zero. Because of the real time nature of this system, the value of the blend radius is low.

a_joint

Float, joint acceleration of leading axis [rad/s^2]

v_joint

Float, joint speed of leading axis [rad/s]

tool_voltage_set

Boolean, whether the tool voltage has been set

force_settings

Tuple of values to set force following settings on robot

verbose

Boolean of whether to print info to the console

sent

Integer of the number of commands sent

__init__(open_socket, verbose=False)[source]

Construct a UR Robot connection to send commands

Parameters:
  • open_socket (socket.socket) – An already open and connected socket
  • a (to) – UR robot
  • verbose (bool) – Whether to print information to the terminal
force_mode_off()[source]

Deactivates force mode

force_mode_on()[source]

Activates force mode.

Requires that force mode settings have been passed in by set_force_mode()

Raises:StandardError – Force settings have not been called.
move_circular(pose_via, pose_to, cartesian=True)[source]

Move to position, circular in tool-space.

TCP moves on the circular arc segment from current pose, through pose via to pose to. Accelerates to and moves with constant tool speed self.v_tool.

Parameters:
  • pose_via (tuple or list of 6 floats) – Path point through which to draw arc, only x,y,z are used
  • pose_to (tuple or list of 6 floats) – Destination point
  • cartesian (bool) – Whether supplied poses are cartesian or joint coordinates
Raises:

TypeError – cartesian was not a boolean

move_joint(goal, time=None, cartesian=False)[source]

Move to position (linear in joint-space).

When using this command, the robot must be at standstill or come from a movej or movel with a blend. The speed and acceleration parameters controls the trapezoid speed profile of the move. The time parameter can be used in stead to set the time for this move. Time setting has priority over speed and acceleration settings. The blend radius can be set with the radius parameters, to avoid the robot stopping at the point. However, if the blend region of this mover overlaps with previous or following regions, this move will be skipped, and an ‘Overlapping Blends’ warning message will be generated.

Parameters:
  • goal (tuple or list of 6 floats) – Destination pose
  • time (float) – The time in which to complete the move, ignored if value is zero. Overrides speed and acceleration otherwise.
  • cartesian (bool) – Whether the goal point is in cartesian coordinates.
Raises:
  • TypeError – cartesian was not a boolean or time was not a float
  • ValueError – time was not a positive value
move_line(goal, time=None, cartesian=True)[source]

Move to position (linear in tool-space).

When using this command, the robot must be at standstill or come from a movej or movel with a blend. The speed and acceleration parameters controls the trapezoid speed profile of the move. The time parameter can be used in stead to set the time for this move. Time setting has priority over speed and acceleration settings. The blend radius can be set with the radius parameters, to avoid the robot stopping at the point. However, if the blend region of this mover overlaps with previous or following regions, this move will be skipped, and an ‘Overlapping Blends’ warning message will be generated.

Parameters:
  • goal (tuple or list of 6 floats) – Destination pose
  • time (float) – The time in which to complete the move. Overrides speed and acceleration if set. Must be a positive value.
  • cartesian (bool) – Whether the goal point is in cartesian coordinates.
Raises:
  • TypeError – cartesian was not a boolean or time was not a float
  • ValueError – time was not a positive value
move_process(goal, cartesian=True)[source]

Move Process, guarantees that speed will be maintained.

Blend circular (in tool-space) and move linear (in tool-space) to position. Accelerates to and moves with constant tool speed v. Failure to maintain tool speed leads to an error. Ideal for applications such as gluing

Parameters:
  • goal (tuple or list of 6 floats) – Destination pose
  • cartesian (bool) – Whether the goal point is in cartesian coordinates.
Raises:

TypeError – cartesian was not a boolean

send(message)[source]

Sends the message over the IP pipe.

Parameters:message (str) – The message to be sent.
servo_circular(goal, cartesian=True)[source]

Servo to position (circular in tool-space).

Accelerates to and moves with constant tool speed v.

Parameters:
  • goal (tuple or list of 6 floats) – Destination pose
  • cartesian (bool) – Whether the goal point is in cartesian coordinates.
Raises:

TypeError – cartesian was not a boolean

servo_joint(goal, time)[source]

Servo to position (linear in joint-space).

Parameters:
  • goal (tuple or list of 6 floats) – Destination pose
  • time (float) – The time in which to complete the move in seconds
Raises:
  • TypeError – time was not a float
  • ValueError – time was non positive
set_analog_input_range(port, input_range)[source]

Set input_range of analog inputs

Port 0 and 1 are in the control box, 2 and three are on the tool flange.

Parameters:
  • port (int) – Port ID (0,1,2,3)
  • input_range (int) – On the controller: [0: 0-5V, 1: -5-5V, 2: 0-10V 3: -10-10V] On the tool flange: [0: 0-5V, 1: 0-10V 2: 0-20mA]
Raises:
  • TypeError – Either port or input_range was not an integer
  • IndexError – input_range was not a valid value for the selected port
set_analog_out(ao_id, level)[source]

Set analog output level

Parameters:
  • ao_id (int) – The output ID#. AO 0 and 1 are in the control box. There is not analog output on the tool.
  • level (float) – The output signal level 0-1, corresponding to 4-20mA or 0-10V based on set_analog_output_domain.
Raises:
  • TypeError – Either ao_id was not an integer or level was not a float
  • IndexError – ao_id was not a valid value (0,1)
set_analog_output_domain(ao_id, domain)[source]

Sets the signal domain of the analog outputs.

The analog outputs can be flexibly set to operate on a 4-20mA or 0-10V scale. There are two analog outputs on the controller and none on the tool.

Parameters:
  • ao_id (int) – The port number (0 or 1).
  • domain (int) – 0 for 4-20mA and 1 for 0-10V
Raises:
  • TypeError – Either ao_id or domain was not an integer
  • IndexError – ao_id or domain was not a valid value (0,1)
set_digital_out(do_id, level)[source]

Set the value for DO[do_id]

Parameters:
  • do_id (int) – The digital output #. Values 0-7 are on the control box. Values 8 and 9 are on the tool flange. You must set the tool voltage prior to attempting to modify the tool flange outputs.
  • level (bool) – High or low setting for output
Raises:
  • TypeError – do_id was not an integer or level was not a boolean
  • StandardError – The tool voltage was not set prior to attempting this call
  • IndexError – do_id was out of range (0-9)
set_force_mode(task_frame, selection_vector, wrench, frame_type, limits)[source]

Set robot to be controlled in force mode

Parameters:
  • task_frame (tuple or list of 6 floats) – A pose vector that defines the force frame relative to the base frame.
  • selection_vector (tuple or list of 6 binaries) – A 6d vector that may only contain 0 or 1. 1 means that the robot will be compliant in the corresponding axis of the task frame, 0 means the robot is not compliant along/about that axis.
  • wrench (tuple or list of 6 floats) – The forces/torques the robot is to apply to its environment. These values have different meanings whether they correspond to a compliant axis or not. Compliant axis: The robot will adjust its position along/about the axis in order to achieve the specified force/torque. Non-compliant axis: The robot follows the trajectory of the program but will account for an external force/torque of the specified value.
  • frame_type (int) – Specifies how the robot interprets the force frame. 1: The force frame is transformed in a way such that its y-axis is aligned with a vector pointing from the robot tcp towards the origin of the force frame. 2: The force frame is not transformed. 3: The force frame is transformed in a way such that its x-axis is the projection of the robot tcp velocity vector onto the x-y plane of the force frame. All other values of frame_type are invalid.
  • limits (tuple or list of 6 floats) – A 6d vector with float values that are interpreted differently for compliant/non-compliant axes: Compliant axes: The limit values for compliant axes are the maximum allowed tcp speed along/about the axis. Non-compliant axes: The limit values for non-compliant axes are the maximum allowed deviation along/about an axis between the actual tcp position and the one set by the program
Raises:
  • TypeError – The selection_vector was not a tuple, it did not have 6 members, or it was not filled with booleans; or frame_type was not an integer
  • IndexError – frame_type was not in the set (1,2,3)
set_normal_gravity()[source]

Sets a normal gravity for an upright mounted robot

set_payload(mass, cog=None)[source]

Set payload mass and center of gravity

This function must be called, when the payload weight or weight distribution changes significantly - I.e when the robot picks up or puts down a heavy workpiece. The CoG argument is optional - If not provided, the Tool Center Point (TCP) will be used as the Center of Gravity (CoG). If the CoG argument is omitted, later calls to set tcp(pose) will change CoG to the new TCP. The CoG is specified as a Vector, [CoGx, CoGy, CoGz], displacement, from the tool mount.

Parameters:
  • mass (float) – mass in kilograms
  • cog (tuple or list of 3 floats) – Center of Gravity: [CoGx, CoGy, CoGz] in meters.
Raises:
  • TypeError – mass was not a float
  • ValueError – mass was negative
set_tcp(pose)[source]

Set the TCP transformation.

Set the transformation from the output flange coordinate system to the TCP as a pose.

Parameters:
  • pose (tuple or list of 6 floats) – A pose describing the
  • transformation.
set_tool_voltage(voltage)[source]

Sets the voltage level for the power supply that delivers power to the connector plug in the tool flange of the robot. The voltage can be 0, 12 or 24 volts.

Parameters:

voltage (int) – The voltage to set at the tool connector

Raises:
  • TypeError – voltage was not an integer
  • ValueError – voltage was not valued 0, 12, or 24
stop_joint()[source]

Stop (linear in joint space)

stop_linear()[source]

Stop (linear in tool space)

ur_cb2.send.cb2_send.check_pose(pose)[source]

Checks to make sure that a pose is valid.

Checks that the pose is a 6 member tuple or list of floats. Does not return anything, simply raises exceptions if the pose is not valid.

Parameters:pose – The pose to check
Raises:TypeError – The pose was not valid.
ur_cb2.send.cb2_send.check_xyz(pose)[source]

Checks to make sure that a 3 tuple or list x,y,z is valid.

Checks that the pose is a 3 member tuple or list of floats. Does not return anything, simply raises exceptions if the pose is not valid.

Parameters:pose – The pose to check
Raises:TypeError – The pose was not valid.
ur_cb2.send.cb2_send.clean_list_tuple(input_data)[source]

Return a string of the input without brackets or parentheses.

Parameters:input_data (tuple or list) – The tuple or list to convert to a string and strip of brackets or parentheses
Raises:TypeError – input_data was not a tuple or list
ur_cb2.send.cb2_send.deg_2_rad(x)[source]

Converts from degrees to radians

Parameters:x (float) – The input in degrees

Returns: A float of the value input converted to radians

ur_cb2.send.cb2_send.double_range(start, stop, step)[source]

Create a list from start to stop with interval step

Parameters:
  • start (float) – The initial value
  • stop (float) – The ending value
  • step (float) – The step size

Returns: A list from start to stop with interval step

ur_cb2.send.cb2_send.rad_2_deg(x)[source]

Converts from radians to degrees

Parameters:x (float) – the input value in radians

Returns: A float of the value input converted to degrees.

ur_cb2.send.cb2_send.scale_path(origin, goal, multiplier=2)[source]

Creates a new goal pose along a path.

Takes the linear path from the origin to the goal and finds a pose on the path which is the length of the original path times multiplier from the origin.

Parameters:
  • origin (tuple or list of 6 floats) – The origin pose
  • goal (tuple or list of 6 floats) – The goal pose
  • multiplier (float) – The multiplier which defines the new path’s length
Returns:

the new pose along the path.

Return type:

tuple of 6 floats

ur_cb2.send.cb2_send_example module

This basic script demonstrates usage of the cb2_send module.

ur_cb2.send.cb2_send_example.main()[source]

Module contents