Writing a value in a RTDE INPUT_DOUBLE_REGISTER and reading it back with another RTDE client leads to lost precision.
For exemple, the value 556.044 which is represent by the double precision value 556.043999999999982719600666314 is read back with the value 556.04400634765625, which is the most accurate representation with a float precision.
Is there a way to pass a double precision value from one RTDE client to another one without lost of precision ?
It is in the [24…47] region.
You can reproduce the lost of precision using the UR RTDE Python library to write in a double register and display the value in Polyscope.
Are you seeing this when you read with other clients too?
The URScript number variable type (and therefore the variable window in Polyscope?) only supports int or float so that would explain why you’re not seeing the full double precision there?
@ajp In my application, I write in INPUT_DOUBLE_REGISTER_24 with a first RTDE client and read INPUT_DOUBLE_REGISTER_24 with a second RTDE client.
My application is in C++ and I verify with Wireshark that the data package send by the first RTDE client is in double precision and that the value received by the second RTDE client from RTDE server is in float precision.
I also reproduce the double precision lost with a Python example using the UR RTDE library rtde-2.3.6.
The example use only one RTDE client writing in INPUT_DOUBLE_REGISTER_24 and reading it back.
To eleminates printing format issue or type casting of the possible explanations, I use Wireshark to look at the network RTDE raw data.
The raw data of my register value send to RTDE server is in double precision.
The 64 bits of raw data receive from RTDE server of the same register value should be exactly the same.
I found out that half the bits are actually clear to 0.
So the RTDE server clearly reduce the precision of my value
A good explanation to me is that the RTDE server casted the double precision value to a float.
@jbm Could you validate with your developper team that the problem described in this post about precision losted in RTDE float register is a real issue ?
Internally GP registers are stored as single precision values, so bug is confirmed Thank you for reporting.
Could you elaborate impact on robot operation? Internally UR controller operates mostly on single precision values so gp register will be truncated when used in calculations anyway. Is this a problem in practice?
We use the RTDE to exchange data between a deamon and an external device. Since other URCaps could write on RTDE registers, we validate data with a keep alive signal and CRC. At first, CRC failed du to this bug. We escaped this issue by casting our values to single precision.
We were also thinking to send 2 single precision value on 1 RTDE register to reduce nombre of used register.