I’m working with the UR10e. I’m writing a URCap. I would like to get the list of digital inputs that are configured under “Installation/General/IO Setup” to automatically trigger freedrive mode. Is there a way to get this from the API or anywhere else?
Thanks,
Steven
I developed a solution to this, but keep in mind it can be broken by changes to Polyscope. I was hoping for a solution that isn’t so fragile, so I welcome any replies with better solutions. That said, here’s how you can get the list of digital inputs that will trigger freedrive:
public Vector<DigitalInputPinEnum> getFreedrivePins()
{
Vector<DigitalInputPinEnum> freedrivePins = new Vector<DigitalInputPinEnum>();
Iterator<IO> iterator = myAPI.getInstallationAPI().getIOModel().getIOs().iterator();
while (iterator.hasNext())
{
IO io = iterator.next();
if (io.isInput())
{
Object pin = executeMethod(io, "getIOPin");
if (pin == null) continue;
Object action = executeMethod(pin, "getIOPinAction");
if (action == null) continue;
Object inputPinAction = executeMethod(action, "getInputPinAction");
if (inputPinAction == null) continue;
if ("FREEDRIVE".equalsIgnoreCase(inputPinAction.toString()))
{
System.out.println("Found a freedrive pin at " + io.getDefaultName());
freedrivePins.add(DigitalInputPinEnum.getInputPin(io));
}
}
}
return freedrivePins;
}
private static Object executeMethod(Object object, String methodName)
{
Class<? extends Object> c = object.getClass();
Method[] methods = c.getMethods();
for (Method method : methods)
{
if (method.getName().contains(methodName))
{
try {
Object value = method.invoke(object, null);
return value;
} catch(IllegalAccessException ex)
{
System.out.println("IllegalAccessException: " + ex.getMessage());
} catch (InvocationTargetException ex)
{
System.out.println("InvocationTargetException: " + ex.getMessage());
}
}
}
return null;
}