I have an issue on my URCaps.
it’s purpose is to make the robot pickup a piece on a grid, place this piece in a production machine and then put it back at it’s place on the grid.
for that, in Polyscope I’m creating a loop node with 2 node from my URCaps to pickup the piece and place it on the grid.
The program does it perfectly for the first piece but it won’t come to the others. It gets stuck at the first one.
After several tes twith an index that I increment in the program to process each piece, I’ve realised that the loop node in Polyscope only execute the compiled program when the “start” button is pushed, but never re-compiled it. Is that normal ?
Or have I missed something?
How can I make the robot process each piece with the URCaps in that loop Node ?
thanks in advance.
Which index are you referring to ? The loop node in the PolyScope or an index in your URCap? and what is the purpose of the URCap? Is it necessary to run your node inside the loop node?
I’m referring to an index in the URCap. It is used to get a line in a csv file that contains several coordinate for the robot to reach during the program run.
I’ve tried to refer to an installation variable but I can’t get nor set it’s value in the URCap
The purpose of the URCap is to make the robot pick a raw piece on a grid, place it in a production machine, then pickup another piece and when the previous piece is processed, replace it with the new piece that the robot picked up, and finally, put the processed piece back at it’s place on the grid.
And yes, it is necessary to run the node in a loop node because the user have to choose if the robot has to pickup the piece from the grid or put it back on
and as the robot has to do that in precise order multiple times, I can’t create a loop in the URCap otherwise, it would remain stuck at the pickup or place part of the program.
So you need a variable telling you which iteration the loop is in?
no, I already have this variable in the URCap,
I need to know if there’s a way to make the program in polyscope read the URCap at each iteration to update the positions for the robot to reach.
Do you have a code example of your current implementation?
here’s the pickup part of the scriptWriter code
Ahh I see what you mean. The generateScript() method is only called once when the play button in polyscope is pressed. One way to do it is to:
- Read everything in the file at once.
- Assign a variable (my_countVariable=0 etc.) which does the counting using a installation node generateScript method.
3)Set the my_countVariable to increment in the loop.
- Ref to my_countVariable from the program node generateScript and use that as the index.
Another way would be to make a daemon to dynamically read the coordinates.
I’m going to try that,
thanks for your time !
so, I’ve tried to create an Installation variable with the installation node generateScript method in two ways :
- use the API to create a GlobalVariable
- create a variable in script command with "writer.appendLine(“global myVar = 0”)
In both ways, no Installation variable have been created, only a program variable has been created with the script command, but I can’t do anything with it.
Am I doing something wrong to create this variable ?
It is important to separate between the Java layer and the script layer. The generateScript() method should only contain the scope of script writing - for more information you can read the articles provided in getting started.. When creating a variable, it is not visible in the polyScope. Also you need to assign a value to the variable in polyscope and then refer to the variable in your generateScript() method in program node to use it.
Could be something like this Installation node::
assign a value in the polyScope (robot UI):
and it should be possible to refer to it in the program node:
this is just an example.
Thanks for your answers,
everything works now