Using Device in Template
Using Device in Template
Abstract
In PolyScope versions 3.11.0/5.5.1, gripper drivers were introduced. This was the first
concept of a device driver/contribution in PolyScope. With the introduction of PolyScope
version 3.12.0/5.6.0, it is now possible to use such devices in templates. This document
will describe how to do so using a gripper-based template as a running example.
Contents
1 Introduction 3
1 Introduction
Creating template URCaps is a powerful way of helping the end user to easily configure the
robot to perform a specific complex task. Prior to the introduction of the concept of devices in
PolyScope, a template URCap developer would have to rely on inserting a Set program node,
Comment program node or similar to have the user do the final configuration of a device oper-
ation.
By using a device-based program node this is no longer necessary. The template program node
can automatically insert the desired device node and configure it to perform its operation.
The following sections will describe the pick functionality of a URCap template program node
for executing a Pick and Place operation. The template node will use a Gripper program node
for performing the grip and release actions. Even though a gripper is used in the example, the
steps taken can be generalized to working with other Polyscope devices as well.
The retrieved list can be presented to the end user in a combo box, so he can select which gripper
to use in the template. If only one gripper device is installed, this could be used directly. If no
gripper devices are installed, the end user should be informed of this and appropriate guiding
actions of how to resolve this should also be presented.
A root tree node is required to insert a child program node. To obtain the root tree node
of the template, use the getRootTreeNode() method in the ProgramModel interface available in the
ProgramAPI interface used in the previous section. An example of this is shown in the code snippet
in Listing 2.
The newly built configuration instance can now be set on the Gripper program node itself. An
example of this can be seen in Listing 3.
All the specific capabilities, that a gripper device can optionally support, are represented by in-
terfaces extending the CapabilitySupport base interface. Each interface provides the information
required for configuring the supported capability for a specific gripper device (the information
is not applicable for other gripper devices). This can used to configure a Gripper program node
which uses that specific gripper device.
An interface representing the support for a specific capability can be obtained using the method
getCapabilitySupport(Class<T>) in the GripperDevice interface. The method should be called with
the class of the specific capability support. Listing 4 shows an example of how to access the
support for the multi-gripper capability using MultiGripperSupport.class as parameter to the
getCapabilitySupport(Class<T>) method.
Listing 4: Getting the support for the multi-gripper capability for a gripper device
1 Optional < MultiGripperSupport > m u l t i G r i p p e r S u p p o r t = gripperDevice .
g e t C a p a b i l i t y S u p p o r t ( M u l t i G r i p p e r S u p p o r t . class ) ;
The getCapabilitySupport(Class<T>) method can also be used just to check if the device supports
a specific capability (or set of capabilities). The result can be used to determine how to con-
figure the gripper device or to help decide which gripper device to select based on its capabilities.
Since the various grippers available in PolyScope can support different sets of capabilities, the
isPresent() method should always be used to check, if a specific capability is available before
calling the get() method. Failing to do so will result in a NoSuchElementException being thrown, if
the capability is not supported.
The example in Listing 5 shows how to select a specific individual gripper in a Gripper node
configuration for a gripper device supporting multiple grippers (i.e. the multi-gripper capabil-
ity). This is achieved using the list af individual grippers available in the multi-gripper provided
by the MultiGripperSupport interface.
For simplicity, the first available gripper is always selected in the example in Listing 5.