tu-darmstadt-ros-pkg / hector_gazebo

hector_gazebo provides packages related to the simulation of robots using gazebo (gazebo plugins, world files etc.).
http://www.ros.org/wiki/hector_gazebo
184 stars 157 forks source link

fixed NaN return values of the attitude in the imu message #12

Closed burrimi closed 10 years ago

burrimi commented 10 years ago

(1 - cos_alpha) can be a negative value and leads to NaN in the attitude because of the square root

meyerj commented 10 years ago

Normally (1 - cos(alpha)) cannot be negative in a mathematical sense. Have you observed NaN values with a debugger and are you sure that this line causes the problem? Which OS/compiler are you using?

burrimi commented 10 years ago

In a mathematical sense yes, but doubles are not exact numbers. I was also surprised at the beginning, but it actually makes sense in my opinion. I'm using gcc (Ubuntu/Linaro 4.7.3-1ubuntu1) 4.7.3.

A simple example can be found here: http://stackoverflow.com/questions/4453372/sqrt1-0-pow1-0-2-returns-nan

markusachtelik commented 10 years ago

Same on OSX 10.9, Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn).