Universal Robots Forum

Compile changes on instalation

Hi there. thank for offer this community.

I’m facing an issue with my first URcap:
My ProgramNodes use some variables setted on the instalation, and when I change a value of them(on the instalationTab) and save the instalation it doesn’t apply the changes on the URScript until I change something on the program tree and pulse play to compile.

Is there a way to notify polyscope that something has changed on a URCap to make it compile again the URScript the next time the “play” button is pressed???(even when nothing has changed int he program tree)

Thanks in advance.

Hi,

changes applied to both installation and programnodes apply on the urscript layer when playing or saving a robot program. This mechanism takes action when the installation and programnodes have their generateScript methods called.

To apply changes to your programnode from your installationnode, you need to call the datamodel of your installation from the programnode, in this case, a get method and the getInstallation Interface should be implemented.

To assure that the changes apply when needed, the get method should be implemented both in your openView and the generate Script method. This way, your changes will either be viewed or executed.

On my generateScript method of my PorgramNodeContribution I call a public method of my Instalation contribution like this:

“apiProvider.getInstalationNode(My instalationContibution.class).getSetupValue()”

The “getSetupValue” method on my instalation contribution is which consult the dataModel… and it transfer the value correctly when compile, but I doesn’t apply changes until is another change in the program tree to compile.

I didn’t find the way to call the datamodel instance of my instalation contribution from my generateScript method of my programNodeContribution if that is what you are suggesting.

Hi,

i never noticed such strange behavior. can you upload a minimum example urcap?

Hi, @m.birkholz!..

My “generateScript” metod is like this:

public void generateScript(ScripWriter writer){
if(model.get(Activated_KEY, false) == true){
Float time = new Float(model.get(Time_KEY, 0.0));
writer.appendLine("TimeToExecute = " + time.toString());
writer.appendLine(“AllowExecution = True”);
}else{
writer.appendLine(“URCap not activated”);
}
}

And the slider I have to set the time has the same context than the one “MyFirstURCap” example,… trigering an Change listener, that calls a method of the instalation contribution, wich saves the new value on the datamodel. exactly the same programing than the example and it works… when it compiles, the problem is that I need to make a change in the program tree to see the changes I made in the instalation tab applied, even when are properly saved in the datamodel of the instalation contribution.

well… I only was able to solve it by creating a small pyton damon to store and get the value on every program start.

the pyton daemon is this:

from SimpleXMLRPCServer import SimpleXMLRPCServer
DefaultTime = 65
Time = DefaultTime

def getTime():
response = None
response = Time
return response

def setTime(value):
global Time
Time = value
return True

def testRPC():
return True

print “Opening XML-RPC Server”
server = SimpleXMLRPCServer(("", 23445), allow_none=True)
server.register_function(setTime, “setTime”)
server.register_function(getTime, “getTime”)
server.register_function(testRPC, “testRPC”)
server.serve_forever()

and on my URscript instalation contribution instead having:

TimeToExecute = 'FixedValueFromDatamodel ’

I have something like:

RPCserver = rpc_factory(“xmlrpc”,“http://127.0.0.1:23445”)
TimeString = RPCserver .getTime()
TimeToExecute = to_num(timeString)

I set the value from my Instalation contribution constructor after a delay from startup to initialize the daemon with a InvokeLater function.

All is based on the “Program Monitor” example:

I hope this helps someone.

When you say that changes on the URScript are not applied, are you looking at the .script file? To my knowledge, that file is changed only on program saving, but the actual URScript which runs when pressing the play button can be hidden.

You know what… that is true!

I guess I just spend a week debugging a bug that didn’t exist! :sweat_smile:

well… it was interesting learn how to set up a pyton daemon as RPC server, will be usefull for more complex projects in the future.

thanks.

I don’t know why this happens but it is confusing. Maybe UR staff (@jbm for example) can explain this: why the <program>.script file is updated only on program saving and not when the play button is pressed? Moreover, I think the <program>.script file is used only as a reference to understand the generated URScript code, but the actual code which is executed is hidden in another folder, can you confirm this?