Python scripting - Event rule callbacks

CheckJointsDynamicLimits

 

The CheckJointsDynamicLimits callback is called automatically when the joint limits neeed to be checked, either during joint interaction and teaching, or also during simulation and APO computation.

 

The callback template is defined in cenpyDefResource.py file. The CheckJointsDynamicLimits callback receives as input a list of main and external joint values, ordered in the same way as in the machine resource. Thus, the main joints go first and then the external ones. For example, if the resource has 5 main and 2 external joints, the CheckJointsDynamicLimits will receive a list of 7 joint values.

 

The script itself can be placed in the internal E2Plugin folder or in any local repository. The script will only be executed if the attribute name is found, the attribute value is not empty and the specified path exists. A single script can be used for multiple resources, or each resource can have a separate script.

 

The script path should be defined in the User defined attributes of the main resource. The attribute name has a predefined name: DynamicLimitsScriptPath. An attribute can have either an absolute or a relative path.

If the relative path should be used, place the script with dynamic limits definition into internal E2Plugin. The recommended folder structure is: ..\E2InstallationFolder\E2Plugin\DynamicLimits\RobotManufacturer\ScriptName.py

Thus the relative path should start from the DynamicLimits folder: DynamicLimits\RobotManufacturer\ScriptName.py. The first part of the path will be automatically completed with the internal E2Plugin location.

 

DynamicLimitsScriptPath

 

 


 

CheckJointsDynamicLimits(list: jointValues): DynamicLimitsReachabilityStatus

 

o

jointValues

Coupled main and external joint values to check

 

o

return

Reachability status: REACHABLE or UNREACHABLE

 

Check if the coupled joint values are not out of dynamic limits.

 

 


 

[Example 1]

# Import libraries

from centypes import *

 

def CheckJointsDynamicLimits(joints):

  # condition 1: J2+J3<;-76 && J4<;-90

  if joints[1] + joints[2] < -76 and joints[3] < -90:

     return UNREACHABLE

  # condition 2: J2+J3<;-73 && J4-5*(J2+J3) > 435

  elif joints[1] + joints[2] < -73 and joints[3] - 5 * (joints[1] + joints[2]) > 435:

     return UNREACHABLE

  # condition 3: J5 < -100 && J6 < 30 && J6 > -60

  elif joints[4] < -100 and joints[5] < 30 and joints[5] > -60:

     return UNREACHABLE

  # condition 4: ((J5 > 100 && (J6 < 120 || J6 < -160)) || (J5 > 110 && (J6 < 100 || J6 < -130) ) )

  elif (joints[4] > 100 and (joints[5] < 120 or joints[5] < -160)) or (joints[4] > 110 and (joints[5] < 100 or joints[5] < -130)):

     return UNREACHABLE

  else:

     return REACHABLE

 


 

An internal library cenpylib has a few utility functions used to simplify the dynamic limits check. For example, the Ramp function:

 

[Example 2]

# Import libraries

from centypes import *

from cenpylib import DynamicLimits as DL

 

def CheckJointsDynamicLimits(joints):

  # Min Limit: =ramp(dof(2)*DEG,0,-86,155,-15)*RAD

  # Max Limit: =ramp(dof(2)*DEG,-105,115,-90,160)*RAD

 

  j2 = joints[1]

  j3 = joints[2]

  j3min = DL.Ramp(j2, 0, -86, 155, -15)

  j3max = DL.Ramp(j2, -105, 115, -90, 160)

 

  if j3 >;= j3min and j3 <;= j3max:

     return REACHABLE

  else:

     return UNREACHABLE

 


 

 

 


Previous
Previous page
Chapter
Chapter page
Next
Next page