Reply to topic

NaN matrix from AngleAxisd, but not with -ggdb

ronalde
Registered Member
Posts
3
Karma
0
I needed to add some rotation math to some existing code. Surprisingly a rotation matrix got NaN coefficients and only the first rotation matrix in that function, the rest were fine. What helped was that I added a dummy rotation matrix before the one I needed and then my code worked, but I really need to understand what goes wrong there.

For debugging, I compiled the code with -ggdb and then the problem disappeared.
When compiled with -O2 -g, I can see that the matrix coefs are set to zero in

Old value = -1.8093557357788086
New value = -nan(0x8000000000000)
run (src=..., dst=...) at /usr/include/mrpt/base/include/Eigen/src/Core/Assign.h:181
181 assign_LinearTraversal_CompleteUnrolling<Derived1, Derived2, Index+1, Stop>::run(dst, src);


Any ideas why is that?!

An example snippet what does not work in the program as a first rotation matrix. In a separate test cpp file it works as it should.
Code: Select all
   
Eigen::Matrix3d zRotMat;
zRotMat = Eigen::AngleAxisd(0.09, Eigen::Vector3d(0,0,1));
cout<<zRotMat<<endl;
User avatar ggael
Moderator
Posts
2206
Karma
15
OS
HArd to help without seeing the code. I recommend you to run your program under valgrind to check your are not reading uninitialized memory, are writing out of bounds, etc.
ronalde
Registered Member
Posts
3
Karma
0
This was a weird issue. Thanks for the advice. Valgrind did not show any mistakes either.

Finally we found out, that the FPU stack was full after a certain OpenCV call and when Eigen pushed more data to FPU, it got corrupted, hence the NaNs. Probably the binary package of OpenCV we used was faulty, after changing the library files, the problem disappeared.
User avatar ggael
Moderator
Posts
2206
Karma
15
OS
Indeed, that was a strange one.

 
Reply to topic

Bookmarks



Who is online

Registered users: AElfwine, alake, anditosan, Artmessiah, Baidu [Spider], Bing [Bot], edmael, Exabot [Bot], garthecho, geaplanet, Google [Bot], google01103, Horus, inksi, Joif, ken300, La Ninje, lazyit, mtvee, pedrorodriguez, pvonz, thalesgava, tienhung, VP1986, Yahoo [Bot]