Jogging Two Axis Groups Using Threads

Brief: in this example, we add two axes, each one in its own independent axis group, and jog them simultaneously using URScript threads in simulation.

URScript API functions used in this example:

  • axis_group_add

  • axis_group_add_axis

  • axis_group_movej

  • reset_world_model

  • axis_group_speedj

The example program adds two new axis groups named “positioner1” and “positioner2”. The “axis1” external axis is added to the “positioner1” group, while “axis2” is added to the “positioner2” group. The axes are then jogged independently of each other.

NOTE: This example does not drive any EtherCAT hardware and the external axes move only in the world model.

img

Let’s go through some highlights of this example in greater detail:

Resetting the World Model

img

This removes all axis groups and axes that have been added to the controller’s world. At the end of the program, the axis and groups that have been added remain in the controller’s world model for subsequent programs. Calling reset_world_model() at the start of a program ensures there is a clean slate if that’s desired. More info: reset_world_model

Adding Two Axis Groups

  • img

    • This adds two axis groups named “positioner1” and “positioner2”. The axis group “positioner1” is placed 0.4m in the x direction and -0.2m in the y direction of the robot’s base frame.

    • The axis group “positioner2” is placed 0.4m in the x direction and 0.2m in the y direction of the robot’s base frame. More info: axis_group_add

Adding Two Axes

  • img

    • This adds an axis to each axis group. The “axis1” axis is configured to be rotational and is placed 0.3m in the z direction of the “positioner1” frame and rotated 90deg around the y axis of the “positioner1” frame. The “axis2” axis is configured to be prismatic and is placed 0.3m in the z direction of the “positioner2” frame and rotated 90deg around the y axis of the “positioner2” frame. The direction of motion for both axes is always in their z directions by construction. More info: axis_group_add_axis

Starting the Threads

  • img

    • This creates and starts two threads for moving both axes in parallel. The function moveAxis1() drives the first axis and moveAxis2() drives the second axis. Their implementations are described below in more detail. The call to “join” blocks the program from moving forward until each thread completes and returns. See the URScript manual for more info on URScript threads.

Moving Axis 1

  • img

    • This first rotates “axis1” with a velocity of 2rad/s using axis_group_speedj. The acceleration factor is 1 so it accelerates at the maximum rate set in the call to axis_group_add_axis(). It runs for a duration of 3 seconds, which is the last argument. The axis then rotates back to the 0 position using axis_group_movej. The acceleration and velocity factors are both 1 so it uses the maximum values set in the call to axis_group_add_axis(). More info: axis_group_movej, and axis_group_speedj

Moving Axis 2

img

This translates “axis2” with a velocity of .1m/s using axis_group_speedj. The acceleration factor is .1 so it accelerates at 10% of the maximum rate set in the call to axis_group_add_axis(). It runs for a duration of 3 seconds, which is the last argument. The axis then translates back to the 0 position using ``axis_group_movej. The acceleration factor is .1 and velocity factor is 1 it uses 10% of the maximum acceleration and 100% of the maximum velocity set in the call to axis_group_add_axis(). More info: axis_group_movej, and axis_group_speedj