Closed fmauch closed 3 years ago
As I am not aware of any method of getting the type of a variable either on the java side nor in URScript, I don't know how to solve this currently.
@fmauch can yo provide a json example?
When writing my previous answer I had something different in mind. The issue described in the OP should actually be resolved by #37.
I'll open a separate issue describing the problems I had in mind when writing https://github.com/UniversalRobots/Universal_Robots_ROS_as_a_Service_URCap/issues/1#issuecomment-843915090
Currently, it is possible to use variables of any datatype to map them to message fields. This will eventually result in an error message on the rosbridge:
Reproduce the error:
geometry_msgs/Pose
0
frame_id(string)
[ERROR] [1618848091.913749]: [Client 7] publish: geometry_msgs/PoseStamped message requires a string for field header.frame_id, but got a <type 'int'>
We should add a validation step on URCap side.
As far as I know, polyscope variables are not typed.
We should try to convert the variables to string / numbers in URScript to get a type check at runtime. Currently, we convert everything to a string, e.g.
to_str(int_var)
. As this integer ends up in the jsonstring without quotes it will be treated as number on the rosbridge side. We'll have to make sure that the jsonstring actually contains surrounding quotes for a string variable and tries to convert itto_num
for numeric values.