Universal Robots Forum

Should I add a Feature to DataModel?

In createfeatureswing sample, in CreateFeatureInstallationNodeContribution a feature is created by:

featureContributionModel = apiProvider.getInstallationAPI().getFeatureContributionModel();
Feature feature = featureContributionModel.addFeature(FEATURE_KEY, SUGGESTED_FEATURE_NAME, positionParameters.getPose());
model.set(FEATURE_KEY, feature);

I have tested in my URCap that, even removing:

model.set(FEATURE_KEY, feature);

if I save the installation, the feature is still present the next time I load the installation. The only difference I can see is that there is no * after the installation to mark it as unsaved. This happens also when updating the feature with

featureContributionModel.updateFeature()

Is this the only difference in using model.set() for a Feature? Should I use it and why?

Hi Alessio,

storing the feature data additionally in the data-model is not required for adding it in the installation. After you call addFeature and save the installation it is stored in the feature list similar to a feature provided by the user directly.

The data-model is in this sample used later in the program node to assure the feature is defined and to retrieve the correspondent joint angles. If you use your provided feature differently, you do not need to store this info in data-model as well.

sko