eigen2 support disabled

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
yorik
Founder
Posts: 13664
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

eigen2 support disabled

Post by yorik »

Apparently EIGEN2_SUPPORT is now completely disabled in Eigen > 3.2 (I have 3.3 now on debian). I guess we have one more porting to do :(

Compiling now stops with this kind of message:

Code: Select all

In file included from /home/yorik/Sources/FreeCAD/src/Mod/Mesh/App/Core/Approximation.cpp:59:0:
/usr/include/eigen3/Eigen/Core:275:2: error: #error Eigen2-support is only available up to version 3.2. Please go to "http://eigen.tuxfamily.org/index.php?title=Eigen2" for further information
There are several changes listed there: http://eigen.tuxfamily.org/dox/Eigen2ToEigen3.html

Not sure I understand much of what's written there, but I'll try... Soon I'll become the official porting person... :)
User avatar
PrzemoF
Veteran
Posts: 3520
Joined: Fri Jul 25, 2014 4:52 pm
Contact:

Re: eigen2 support disabled

Post by PrzemoF »

fedora 22 with eigen-3.2.5, compilation doesn't fail, so it might be distro specific or some version after 3.2.5
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: eigen2 support disabled

Post by looo »

I have found this here:
http://eigen.tuxfamily.org/dox/classEig ... olver.html
replace "# include <Eigen/LeastSquares>" with "#include <Eigen/Eigenvalues>" in Approximation.cpp line 59
User avatar
sgrogan
Veteran
Posts: 6499
Joined: Wed Oct 22, 2014 5:02 pm

Re: eigen2 support disabled

Post by sgrogan »

On Windows and Ubuntu PPA 3.2.5 compiles, there is a deprecation message.
From Yorik's link I think deprecated in 3.2.x and totally removed in 3.3
"fight the good fight"
wmayer
Founder
Posts: 20309
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: eigen2 support disabled

Post by wmayer »

According to http://eigen.tuxfamily.org/dox/classEig ... derQR.html the needed changes are:
1. Remove EIGEN2_SUPPORT
2.

Code: Select all

-# include <Eigen/LeastSquares>
+# include <Eigen/QR>
 
 using namespace MeshCore;
 
@@ -700,7 +700,9 @@ double SurfaceFit::PolynomFit()
     //std::clog << b << std::endl;
 #else
     // A.llt().solve(b,&x); // not sure if always positive definite
-    A.qr().solve(b,&x);
+    //A.qr().solve(b,&x);
+    Eigen::HouseholderQR< Eigen::Matrix<double,6,6> > qr(A);
+    x = qr.solve(b);
 #endif
 
     _fCoeff[0] = (float)(-x(5));
However, I have to first write a unit test and check if everything still works the same way.

But EIGEN2_SUPPORT is also used for kdl in the Robot and Path modules and I haven't tested if the work without. If not then we have to update the kdl lib in the hope it uses the Eigen3 API.
User avatar
yorik
Founder
Posts: 13664
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: eigen2 support disabled

Post by yorik »

The above change seems to work okay. There are apparently other changes in eigen3.3 too, which seem unrelated to the EIGEN2_SUPPORT removal, for ex:

Code: Select all

[ 59%] Building CXX object src/Mod/Sketcher/App/CMakeFiles/Sketcher.dir/planegcs/GCS.cpp.o
In file included from /usr/include/eigen3/Eigen/Core:295:0,
                 from /home/yorik/Sources/FreeCAD/src/Mod/Sketcher/App/planegcs/SubSystem.h:29,
                 from /home/yorik/Sources/FreeCAD/src/Mod/Sketcher/App/planegcs/GCS.h:26,
                 from /home/yorik/Sources/FreeCAD/src/Mod/Sketcher/App/planegcs/GCS.cpp:27:
/usr/include/eigen3/Eigen/src/Core/util/Meta.h: In member function ‘Eigen::SparseSolverBase<Eigen::SparseQR<Eigen::SparseMatrix<double>, Eigen::COLAMDOrdering<int> > >& Eigen::SparseSolverBase<Eigen::SparseQR<Eigen::SparseMatrix<double>, Eigen::COLAMDOrdering<int> > >::operator=(const Eigen::SparseSolverBase<Eigen::SparseQR<Eigen::SparseMatrix<double>, Eigen::COLAMDOrdering<int> > >&)’:
/usr/include/eigen3/Eigen/src/Core/util/Meta.h:190:40: error: ‘const Eigen::internal::noncopyable& Eigen::internal::noncopyable::operator=(const Eigen::internal::noncopyable&)’ is private
   EIGEN_DEVICE_FUNC const noncopyable& operator=(const noncopyable&);
I think I'll comment out all the kdl stuff in Path for now, it has never been used so far, it is there mostly because Jürgen was thinking on using it in Robot...
User avatar
yorik
Founder
Posts: 13664
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: eigen2 support disabled

Post by yorik »

Ok I could pass this point. It was a workaround introduced to solve a big in eigen3.2...

Code: Select all

diff --git a/src/Mod/Sketcher/App/planegcs/GCS.cpp b/src/Mod/Sketcher/App/planegcs/GCS.cpp
index 5df8e74..799c1d5 100644
--- a/src/Mod/Sketcher/App/planegcs/GCS.cpp
+++ b/src/Mod/Sketcher/App/planegcs/GCS.cpp
@@ -30,14 +30,17 @@
 // NOTE: In CMakeList.txt -DEIGEN_NO_DEBUG is set (it does not work with a define here), to solve this:
 // this is needed to fix this SparseQR crash http://forum.freecadweb.org/viewtopic.php?f=10&t=11341&p=92146#p92146, 
 // until Eigen library fixes its own problem with the assertion (definitely not solved in 3.2.0 branch)
+// NOTE2: solved in eigen3.3
 
 #define EIGEN_VERSION (EIGEN_WORLD_VERSION * 10000 \
                                + EIGEN_MAJOR_VERSION * 100 \
                                + EIGEN_MINOR_VERSION)
 
-#if EIGEN_VERSION >= 30202                              
+#if EIGEN_VERSION >= 30202  
+#if EIGEN_VERSION < 30290 // this is eigen3.3 apparently. Bad numbering? This should be safe anyway.                       
 #define EIGEN_SPARSEQR_COMPATIBLE
 #endif
+#endif
 
 //#undef EIGEN_SPARSEQR_COMPATIBLE
User avatar
yorik
Founder
Posts: 13664
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: eigen2 support disabled

Post by yorik »

wmayer wrote:But EIGEN2_SUPPORT is also used for kdl in the Robot and Path modules and I haven't tested if the work without. If not then we have to update the kdl lib in the hope it uses the Eigen3 API.
Ok Kdl is now commented out everywhere in Path, and it compiles OK.

For Robot, apparently KDL+eigen3 works: http://www.orocos.org/forum/orocos/oroc ... roblem-kdl
But indeed the current version we have doesn't work when removing EIGEN2_SUPPORT. I'll update to the latest version (hope it won't break anything...)

Changes so far: https://github.com/yorikvanhavre/FreeCAD/tree/eigen33
User avatar
yorik
Founder
Posts: 13664
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: eigen2 support disabled

Post by yorik »

KDL is updated, FreeCAD now builds succesfully with eigen3.3
Unfortunately the Robot WB is broken now :(

Code: Select all

>>> import Robot
Traceback (most recent call last):
  File "<input>", line 1, in <module>
ImportError: /home/yorik/Apps/FreeCAD/lib/Robot.so: undefined symbol: _ZN3KDL19ChainJntToJacSolver8JntToJacERKNS_8JntArrayERNS_8JacobianEi
wmayer
Founder
Posts: 20309
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: eigen2 support disabled

Post by wmayer »

KDL is updated, FreeCAD now builds succesfully with eigen3.3
Sounds like you have to do a full rebuild at least of the Robot module.
Post Reply