Closed nunoguedelha closed 2 years ago
After further analysis, we see that:
- The issue is already present in https://github.com/ami-iit/yarp-openmct/pull/129, so before the changes introduced by this issue.
- The parser
ICubTelemetry.prototype.parseFromId
is called with the same Yarp port sample for both telemetry idssens.rightArmJointState
andsens.leftArmJointState
in the case of the arms, and similar thing happens for the legs.It could be a problem with the definition of the function pointer
icubtelemetry.forwardYarpDataToNotifier
...
Originally posted by @nunoguedelha in https://github.com/ami-iit/yarp-openmct/issues/123#issuecomment-1229600017
After checking again, actually the parser ICubTelemetry.prototype.parseFromId is called with the proper samples, different between the two ids
sens.leftLegJointState
andsens.rightLegJointState
.The problem was with the initialisation of the variable
ICubTelemetry.state
storing the parsed samples.https://github.com/ami-iit/yarp-openmct/blob/ff74f1e351fe1ddb7c1139002a57acc9dbcc5eb9/iCubTelemVizServer/icubtelemetry.js#L22 https://github.com/ami-iit/yarp-openmct/blob/ff74f1e351fe1ddb7c1139002a57acc9dbcc5eb9/iCubTelemVizServer/icubtelemetry.js#L29-L35 https://github.com/ami-iit/yarp-openmct/blob/ff74f1e351fe1ddb7c1139002a57acc9dbcc5eb9/iCubTelemVizServer/icubtelemetry.js#L70
When initialising the
sens.rightLegJointState
nested structure, we had used the=
operator to copysens.leftLegJointState
, which just sets a pointer to the later. For that reason we were always filling the same data for both legs.
This is easily fixed by using a deep copy through
JSON.parse(JSON.stringify(...))
.
Originally posted by @nunoguedelha in https://github.com/ami-iit/yarp-openmct/issues/123#issuecomment-1229658228
CC @S-Dafarra
Originally posted by @nunoguedelha in https://github.com/ami-iit/yarp-openmct/issues/123#issuecomment-1229587565