I’ve been trying to generate integer indices that roll over after a certain limit. In the absence of a URScript mod() function I was trying to construct my own. This involved assuming that the dividend resulting from the operation:
idividend = inum/idivisor
where idividend, inum and idivisor are all initialized to integers,
will also be an integer.
Unfortunately, when I tried to perform this operation in URScript, idividend was converted from an int to a float. Is this a bug or a feature?
Any suggestions as to a way to accomplish my objective, either an available URscript mod() function or a way to truncate/convert a float?
In the meantime the immediate problem has been solved by adding the necessary functionality to an existing xml-rpc server used by the vision system. Still it would seem that the functionality should be part of URScript.
use the operator
% to calculate modulo.
result := var_1 % 10
btw. I did not find it in the manual, but by interpreting the generated script code from polyscope.
maybe the script-functions
ceil() do what you want. You may use
floor() for positive values and
ceil() for negative to cut off all after the decimal point (the result is still a float).
This can be found in the scriptmanual.
The % operator is what I was looking for. In addition to searching the manual I had tried to create a POLYSCOPE assignment instruction but did not find the % operator listed in the graphical programming environment menu. So I assumed it did not exist.
It seems that both the menu and the manual.should be updated.
@rkm Were you able to find the % symbol in the GUI ?
I need to use it to perform the modulo function as well.
Numbers in PolyScope are generally not devided into either float or integers - they are just numbers.
% operator is not on the on-screen keyboard. You can use an external USB keyboard or import the
.script file from PC.
Is it a polyscope version thing? Because the % is on the 3.7.1 keyboard. It is both on the Danish and English keyboard at least.
Thanks for the prompt responses.
Yes, I updated the polyscope platform to version 3.7 and I was able to find the % symbol on the GUI keyboard.
Have not tried to use it through an external keyboard yet but I believe that should work too.