UniversalRobots / Universal_Robots_ROS_as_a_Service_URCap

This URCap makes a universal robot part of a ROS system by making ROS calls available inside Polyscope through the rosbridge.
Apache License 2.0
12 stars 3 forks source link

Add datatype validation #1

Closed fmauch closed 3 years ago

fmauch commented 3 years ago

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:

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 it to_num for numeric values.

fmauch commented 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.

urrsk commented 3 years ago

@fmauch can yo provide a json example?

fmauch commented 3 years ago

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