facontidavide / ros_type_introspection

Deserialize ROS messages that are unknown at compilation time
MIT License
61 stars 30 forks source link

When converting type, checkTruncation throws when input is nan #22

Closed kartikmohta closed 7 years ago

kartikmohta commented 7 years ago

The equality check for nan always returns false which caused checkTruncation to throw "Floating point truncated" exception. Happened when loading a ROS bag in PlotJuggler containing nans in some messages.

facontidavide commented 7 years ago

Honestly, I don't know what the desired behavior should be in this case. Convert aims by definition at mathematical correctness. It is still possible to extract the number I guess. I will think about it

kartikmohta commented 7 years ago

In my opinion, it should return a nan if the input is nan but I don't know how that can work if the destination is not a floating point type.

facontidavide commented 7 years ago

I found an even better solution. Check the last commit. Actually it will make convert even faster

kartikmohta commented 7 years ago

Seems odd to have a special case for float64, but that works for me so it's ok I guess. 🙂

facontidavide commented 7 years ago

for the records, the template specialization for convert was already there to correctly handle the ros::Time and ros::Duration conversion.

Cheers and thanks for reporting