Skip to content

External Script

Jules van der Toorn edited this page Jan 2, 2021 · 5 revisions

The external script interface makes it possible to send motion related commands to the robot.

To setup a connection with the external script interface:

async with techmanpy.connect_sct(robot_ip, [client_id, conn_timeout, suppress_warns]) as conn:
   # connection established
   ...
  • robot_ip: str | mandatory kwarg
    The IP address of the robot
  • conn_timeout: int (s) | optional kwarg, default = 3
    The duration before a connection attempt times out
  • suppress_warns: bool | optional kwargs, default = False
    Suppress warnings, which normally get printed to the console

Given the connection object conn, various actions can be performed. These will now be discussed.

To send multiple commands as a whole, a transaction can be used:

trsct = conn.start_transaction()
trsct.do_some_command()
trsct.do_another_command()
await trsct.submit()

As can be seen, the commands themselve don't have to be awaited, as they are locally stored in the transaction buffer.

Calling submit on the transaction object will flush the buffer and send all commands as one packet. This ensures that either all commands are executed, or not at all.

The commands that can be called on a transaction object are exactly the same as the commands that can be called on the connection object directly. The only important difference is that transaction commands are not executed directly (so don't need the await keyword), whereas connection commands are directly executed (do need the await keyword).

Queue tags

To set a queue tag for the last-sent command:

await conn.set_queue_tag(tag_id, [wait_for_completion])
  • tag_id: int | mandatory arg
    The queue tag identifier
  • wait_for_completion: bool | optional kwarg, default = False
    Wait with returning until the queue tag completes


To wait for a previously set queue tag:

await conn.wait_for_queue_tag(tag_id, [timeout])
  • tag_id: int | mandatory arg
    The queue tag identifier
  • timeout: int (ms) | optional kwarg, default = -1
    The duration after which the waiting times out. Setting this value to -1 indicates no time out

Project execution

To pause an ongoing project:

await conn.pause_project()

To resume a paused project:

await conn.resume_project()

Motion parameters

To set the motion frame of reference (base) to an existing configuration:

await conn.set_base(base)
  • base: string | mandatory arg
    Identifier of a base in TMFlow


To set the motion frame of reference (base) to a custom configuration:

await conn.set_base(base)
  • base: [X (mm), Y (mm), Z (mm), RX (deg), RY (deg), RZ (deg)] | mandatory arg
    Frame of reference which will be set as the base


To set the tool center point (TCP) to an existing configuration:

await conn.set_tcp(tcp, weight, inertia)
  • tcp: string | mandatory arg
    Identifier of a tool center point in TMFlow
  • weight: float (kg) | optional kwarg, default = None
    The weight of the tool
  • inertia: [IX, IY, IZ, X (mm), Y (mm), Z (mm), RX (deg), RY (deg), RZ (deg)] | optional kwarg, default = None
    Tool's moment of inertia and its frame of reference


To set the tool center point (TCP) to a custom configuration:

await conn.set_tcp(tcp, weight, inertia)
  • tcp: [X (mm), Y (mm), Z (mm), RX (deg), RY (deg), RZ (deg)] | mandatory arg
    Tool center point expressed in point and rotation
  • weight: float (kg) | optional kwarg, default = None
    The weight of the tool
  • inertia: [IX, IY, IZ, X (mm), Y (mm), Z (mm), RX (deg), RY (deg), RZ (deg)] | optional kwarg, default = None
    Tool's moment of inertia and its frame of reference


To set the load weight:

await conn.set_load_weight(weight)
  • weight: float (kg) | mandatory arg
    The weight of the tool in kilograms

PVT motion

To execute a PVT path of points:

trsct = conn.start_transaction()
trsct.enter_point_pvt_mode()

# Add multiple PVT points
trsct.add_pvt_point(tcp_point_goal, tcp_point_velocities_goal, duration)
...

trsct.exit_pvt_mode()
await trsct.submit()
  • tcp_point_goal: [X (mm), Y (mm), Z (mm), RX (deg), RY (deg), RZ (deg)] | mandatory arg
    Motion goal expressed in point and rotation
  • tcp_point_velocities_goal: [VX (mm/s), VY (mm/s), VZ (mm/s), VRX (deg/s), VRY (deg/s), VRZ (deg/s)] | mandatory arg
    Motion velocity goal expressed in point and rotation
  • duration: float (s) | mandatory arg
    Intended duration of the motion


To execute a PVT path of joint angles:

trsct = conn.start_transaction()
trsct.enter_joint_pvt_mode()

# Add multiple PVT joint angles
trsct.add_pvt_joint_angles(joint_angles_goal, joint_angle_velocities_goal, duration)

trsct.exit_pvt_mode()
await trsct.submit()
  • joint_angles_goal: [J1 (deg), J2 (deg), J3 (deg), J4 (deg), J5 (deg), J6 (deg)] | mandatory arg
    Motion goal expressed in joint angles
  • joint_angle_velocities_goal: [VJ1 (deg/s), VJ2 (deg/s), VJ3 (deg/s), VJ4 (deg/s), VJ5 (deg/s), VJ6 (deg/s)] | mandatory arg
    Motion velocity goal expressed in joint angles
  • duration: float (s) | mandatory arg
    Intended duration of the motion

PTP motion

To move to an absolute point:

await conn.move_to_point_ptp(tcp_point_goal, speed_perc, acceleration_duration, [blending_perc, use_precise_positioning, pose_goal])
  • tcp_point_goal: [X (mm), Y (mm), Z (mm), RX (deg), RY (deg), RZ (deg)] | mandatory arg
    Motion goal expressed in point and rotation
  • speed_perc: float (%) | mandatory arg
    The speed percentage at which the motion should maximally occur
  • acceleration_duration: int (ms) | mandatory arg
    The duration for accelerating to the maximum speed
  • blending_perc: float (%) | optional kwarg, default = 0.0
    The blending percentage for the motion
  • use_precise_positioning: bool | optional kwarg, default = False
    Use precise positioning. This will result in a more accurate pose, but can cause more stress to the joints
  • pose_goal: [C1, C2, C3] optional kwarg, default = None
    The joint angles pose goal (otherwise decided by TMFlow)


To move to a relative point offset:

await conn.move_to_relative_point_ptp(relative_point_goal, speed_perc, acceleration_duration, [blending_perc, relative_to_tcp, use_precise_positioning])
  • relative_point_goal: [X (mm), Y (mm), Z (mm), RX (deg), RY (deg), RZ (deg)] | mandatory arg
    Relative motion goal expressed in point and rotation offset
  • speed_perc: float (%) | mandatory arg
    The speed percentage at which the motion should maximally occur
  • acceleration_duration: int (ms) | mandatory arg
    The duration for accelerating to the maximum speed
  • blending_perc: float (%) | optional kwarg, default = 0.0
    The blending percentage for the motion
  • relative_to_tcp: bool | optional kwarg, default = False
    Move relative to the TCP. If not enabled, the active base will be used
  • use_precise_positioning: bool | optional kwarg, default = False
    Use precise positioning. This will result in a more accurate pose, but can cause more stress to the joints


To move to absolute joint angles:

await conn.move_to_joint_angles_ptp(joint_angles_goal, speed_perc, acceleration_duration, [blending_perc, use_precise_positioning])
  • joint_angles_goal: [J1 (deg), J2 (deg), J3 (deg), J4 (deg), J5 (deg), J6 (deg)] | mandatory arg
    Motion goal expressed in joint angles
  • speed_perc: float (%) | mandatory arg
    The speed percentage at which the motion should maximally occur
  • acceleration_duration: int (ms) | mandatory arg
    The duration for accelerating to the maximum speed
  • blending_perc: float (%) | optional kwarg, default = 0.0
    The blending percentage for the motion
  • use_precise_positioning: bool | optional kwarg, default = False
    Use precise positioning. This will result in a more accurate pose, but can cause more stress to the joints


To move to relative joint angles offset:

await conn.move_to_relative_joint_angles_ptp(relative_joint_angles_goal, speed_perc, acceleration_duration, [blending_perc, use_precise_positioning])
  • relative_joint_angles_goal: [J1 (deg), J2 (deg), J3 (deg), J4 (deg), J5 (deg), J6 (deg)] | mandatory arg
    Relative motion goal expressed in joint angles offset
  • speed_perc: float (%) | mandatory arg
    The speed percentage at which the motion should maximally occur
  • acceleration_duration: int (ms) | mandatory arg
    The duration for accelerating to the maximum speed
  • blending_perc: float (%) | optional kwarg, default = 0.0
    The blending percentage for the motion
  • use_precise_positioning: bool | optional kwarg, default = False
    Use precise positioning. This will result in a more accurate pose, but can cause more stress to the joints

Path motion

To move to an absolute point:

await conn.move_to_point_path(tcp_point_goal, velocity, acceleration_duration, [blending_perc])
  • tcp_point_goal: [X (mm), Y (mm), Z (mm), RX (deg), RY (deg), RZ (deg)] | mandatory arg
    Motion goal expressed in point and rotation
  • velocity: int (mm/s) | mandatory arg
    The speed at which the motion should maximally occur
  • acceleration_duration: int (ms) | mandatory arg
    The duration for accelerating to the maximum speed
  • blending_perc: float (%) | optional kwarg, default = 0.0
    The blending percentage for the motion


To move to a relative point offset:

await conn.move_to_relative_point_path(relative_point_goal, velocity, acceleration_duration, [blending_perc, relative_to_tcp])
  • relative_point_goal: [X (mm), Y (mm), Z (mm), RX (deg), RY (deg), RZ (deg)] | mandatory arg
    Relative motion goal expressed in point and rotation offset
  • velocity: int (mm/s) | mandatory arg
    The speed at which the motion should maximally occur
  • acceleration_duration: int (ms) | mandatory arg
    The duration for accelerating to the maximum speed
  • blending_perc: float (%) | optional kwarg, default = 0.0
    The blending percentage for the motion
  • relative_to_tcp: bool | optional kwarg, default = False
    Move relative to the TCP. If not enabled, the active base will be used


To move to absolute joint angles:

await conn.move_to_joint_angles_path(joint_angles_goal, velocity, acceleration_duration, [blending_perc])
  • joint_angles_goal: [J1 (deg), J2 (deg), J3 (deg), J4 (deg), J5 (deg), J6 (deg)] | mandatory arg
    Motion goal expressed in joint angles
  • velocity: int (mm/s) | mandatory arg
    The speed at which the motion should maximally occur
  • acceleration_duration: int (ms) | mandatory arg
    The duration for accelerating to the maximum speed
  • blending_perc: float (%) | optional kwarg, default = 0.0
    The blending percentage for the motion


To move to relative joint angles offset:

await conn.move_to_relative_joint_angles_path(relative_joint_angles_goal, velocity, acceleration_duration, [blending_perc])
  • relative_joint_angles_goal: [J1 (deg), J2 (deg), J3 (deg), J4 (deg), J5 (deg), J6 (deg)] | mandatory arg
    Relative motion goal expressed in joint angles offset
  • velocity: int (mm/s) | mandatory arg
    The speed at which the motion should maximally occur
  • acceleration_duration: int (ms) | mandatory arg
    The duration for accelerating to the maximum speed
  • blending_perc: float (%) | optional kwarg, default = 0.0
    The blending percentage for the motion

Line motion

To move to an absolute point:

await conn.move_to_point_line(tcp_point_goal, speed, acceleration_duration, [blending, speed_is_velocity, blending_is_radius, use_precise_positioning])
  • tcp_point_goal: [X (mm), Y (mm), Z (mm), RX (deg), RY (deg), RZ (deg)] | mandatory arg
    Motion goal expressed in point and rotation
  • speed: float (%) | mandatory arg
    The speed at which the motion should maximally occur
  • acceleration_duration: int (ms) | mandatory arg
    The duration for accelerating to the maximum speed
  • blending: float (%) | optional kwarg, default = 0.0
    The blending for the motion
  • speed_is_velocity: bool | optional kwarg, default = False
    Describe the speed as a velocity. This changes the speed argument to int (mm/s)
  • blending_is_radius: bool | optional kwarg, default = False
    Describe the blending as a radius. This changes the blending argument to int (deg)
  • use_precise_positioning: bool | optional kwarg, default = False
    Use precise positioning. This will result in a more accurate pose, but can cause more stress to the joints


To move to a relative point offset:

await conn.move_to_relative_point_line(relative_point_goal, speed, acceleration_duration, [blending, relative_to_tcp, speed_is_velocity, blending_is_radius, use_precise_positioning])
  • relative_point_goal: [X (mm), Y (mm), Z (mm), RX (deg), RY (deg), RZ (deg)] | mandatory arg
    Relative motion goal expressed in point and rotation offset
  • speed: float (%) | mandatory arg
    The speed at which the motion should maximally occur
  • acceleration_duration: int (ms) | mandatory arg
    The duration for accelerating to the maximum speed
  • blending: float (%) | optional kwarg, default = 0.0
    The blending for the motion
  • relative_to_tcp: bool | optional kwarg, default = False
    Move relative to the TCP. If not enabled, the active base will be used
  • speed_is_velocity: bool | optional kwarg, default = False
    Describe the speed as a velocity. This changes the speed argument to int (mm/s)
  • blending_is_radius: bool | optional kwarg, default = False
    Describe the blending as a radius. This changes the blending argument to int (deg)
  • use_precise_positioning: bool | optional kwarg, default = False
    Use precise positioning. This will result in a more accurate pose, but can cause more stress to the joints

Circle motion

To move on a circular path:

await conn.move_on_circle(tcp_point_1, tcp_point_2, speed, acceleration_duration, [arc_angle, blending_perc, speed_is_velocity, use_precise_positioning])
  • tcp_point_1: [X (mm), Y (mm), Z (mm), RX (deg), RY (deg), RZ (deg)] | mandatory arg
    Motion keypoint expressed in point and rotation
  • tcp_point_2: [X (mm), Y (mm), Z (mm), RX (deg), RY (deg), RZ (deg)] | mandatory arg
    Motion keypoint expressed in point and rotation
  • speed: float (%) | mandatory arg
    The speed at which the motion should maximally occur
  • acceleration_duration: int (ms) | mandatory arg
    The duration for accelerating to the maximum speed
  • arc_angle: int (deg) | optional kwarg, default = 0
    The arc angle on which the TCP will keep the same pose and move from current point to the assigned arc angle via the given point and end point. If this value is 0, the TCP will move from current point and pose to end point and pose via the point on arc with linear interpolation on pose
  • blending_perc: float (%) | optional kwarg, default = 0.0
    The blending for the motion
  • speed_is_velocity: bool | optional kwarg, default = False
    Describe the speed as a velocity. This changes the speed argument to int (mm/s)
  • use_precise_positioning: bool | optional kwarg, default = False
    Use precise positioning. This will result in a more accurate pose, but can cause more stress to the joints