Evaluate MinValue/MaxValue of a joint

Hi everyone

 

I know that for properties on a component there’s the “CalculatedValue” property to get the actual value.

Is there a way to do the same for the MinValue/MaxValue of a joint?

I can only get the string from there.

Thanks in advance for any help!

 

Regards

Johnny

Hi Johnny,

I am also wondering, why the property returns a string.

What’s wrong with casting the string to float?

minValue = float(myJointNode.Dof.MinValue)

 

Hi,

Max and min limits are string expressions to allow dependencies to properties such as other joint values. And the properties in python API are MinLimit and MaxLimit and not MinValue and MaxValue. If the expression is simple numeric literal such as “360” you can cast it to float. With complex expression there is a way to solve those by creating a temporary expression property and solving the expression with it.

Below there is an example which solves and prints link max limits for ABB IRB1200_5-90 robot, which has both simple and complex limit expressions:

from vcScript import *

app = getApplication()
comp = app.findComponent('IRB1200_5-90')

links =[comp]
prop = None

while links:
  link = links.pop(0)
  print link.Name
  if link.Dof:
    max_limit = 0
    try:
      max_limit = float(link.Dof.MaxLimit)
      print ' MaxLimit:%.3f' % max_limit
    except:
      if not prop:
        prop = comp.createProperty(VC_EXPRESSION, 'TempExpression')
      prop.Value = link.Dof.MaxLimit
      max_limit = prop.CalculatedValue
      print ' MaxLimit:%.3f' % max_limit
  else:
    print ' No Dof.'
  links.extend(link.Children)
if prop:
  comp.deleteProperty(prop)

-k

To correct myself, the properties for vcDof are MinLimit and MaxLimit but for vcJoint they are MinValue and MaxValue.

-k

Hi

 

@JuergenB

Thanks for your reply but since I reference a property in this expression I cannot simply cast it to float.

 

@Keke

Thanks for the fast help!

This seems to be the best way currently, didn’t think about that solution.

Maybe it would be a cool feature if you had some kind of method called “evalExpression” on the vcComponent instance to evaluate an expression.

Anyways thanks for the solution I appreciate that! :slight_smile:

 

Regards

Johnny