Double values get truncated when sent by signal
Posted: 28 May 2019, 09:52
When trying to store a double value (with ~14 relevant digits) with a Lua signal, the corresponding function seems to be sim.setFloatSignal. However, the values seem to be truncated to 32-bit float values when using this.
A test code looks like this:
local testvar=simROS.getTime()
-- or something like: local testvar=123456789.123456
print(testvar)
sim.setFloatSignal("TestVar",testvar)
testvar=sim.getFloatSignal("TestVar")
print(testvar)
and returns:
1559031075,2268
1559031040
There does not seem to be a setDoubleSignal function. So there is currently no possibility to use signals with double-precision values !
Possible solutions: Implement a setDoubleSignal function (and corresponding functions), or let setFloatSignal work with double-precision values by default.
I suspect that the same problem occurs for sim.getFloatParamter (but have not tested it).
Meanwhile, does anybody know a workaround for this ?
A test code looks like this:
local testvar=simROS.getTime()
-- or something like: local testvar=123456789.123456
print(testvar)
sim.setFloatSignal("TestVar",testvar)
testvar=sim.getFloatSignal("TestVar")
print(testvar)
and returns:
1559031075,2268
1559031040
There does not seem to be a setDoubleSignal function. So there is currently no possibility to use signals with double-precision values !
Possible solutions: Implement a setDoubleSignal function (and corresponding functions), or let setFloatSignal work with double-precision values by default.
I suspect that the same problem occurs for sim.getFloatParamter (but have not tested it).
Meanwhile, does anybody know a workaround for this ?