borglab / gtsam

GTSAM is a library of C++ classes that implement smoothing and mapping (SAM) in robotics and vision, using factor graphs and Bayes networks as the underlying computing paradigm rather than sparse matrices.
http://gtsam.org
Other
2.55k stars 754 forks source link

errors in build with matlab #894

Closed shaoxh closed 2 years ago

shaoxh commented 2 years ago

Description

build ../wrap/gtsam/gtsam_wrapper.cpp failed!

Steps to reproduce

  1. cmake -DGTSAM_INSTALL_MATLAB_TOOLBOX=ON \ -DEXAMPLES_BUILD_MATLAB_TOOLBOX:OPTION=ON \ -DGTSAM_TOOLBOX_INSTALL_PATH:PATH=$HOME/toolbox ..
  2. make install

Expected behavior

build successfully

Environment

Matlab 2021 python 3.6.5 c++ 14 ubuntu 18.04

Additional information

[100%] Built target ConcurrentFilteringAndSmoothingExample [100%] Generating ../wrap/gtsam/gtsam_wrapper.cpp [MatlabWrapper] Ignoring classes: ['gtsam::Point2', 'gtsam::Point3', 'gtsam::CustomFactor'] Traceback (most recent call last): File "/home/godu/gtsam/wrap/scripts/matlab_wrap.py", line 58, in cc_content = wrapper.wrap(sources, path=args.out) File "/home/godu/gtsam/wrap/gtwrap/matlab_wrapper/wrapper.py", line 1576, in wrap parsed_result = parser.Module.parseString(content) File "/home/godu/gtsam/wrap/gtwrap/interface_parser/module.py", line 56, in parseString return Module.rule.parseString(s)[0] File "/home/godu/anaconda3/lib/python3.6/site-packages/pyparsing.py", line 1622, in parseString loc, tokens = self._parse( instring, 0 ) File "/home/godu/anaconda3/lib/python3.6/site-packages/pyparsing.py", line 1529, in _parseCache value = self._parseNoCache(instring, loc, doActions, callPreParse) File "/home/godu/anaconda3/lib/python3.6/site-packages/pyparsing.py", line 1379, in _parseNoCache loc,tokens = self.parseImpl( instring, preloc, doActions ) File "/home/godu/anaconda3/lib/python3.6/site-packages/pyparsing.py", line 3378, in parseImpl loc, resultlist = self.exprs[0]._parse( instring, loc, doActions, callPreParse=False ) File "/home/godu/anaconda3/lib/python3.6/site-packages/pyparsing.py", line 1529, in _parseCache value = self._parseNoCache(instring, loc, doActions, callPreParse) File "/home/godu/anaconda3/lib/python3.6/site-packages/pyparsing.py", line 1379, in _parseNoCache loc,tokens = self.parseImpl( instring, preloc, doActions ) File "/home/godu/anaconda3/lib/python3.6/site-packages/pyparsing.py", line 3919, in parseImpl return super(ZeroOrMore, self).parseImpl(instring, loc, doActions) File "/home/godu/anaconda3/lib/python3.6/site-packages/pyparsing.py", line 3848, in parseImpl loc, tokens = self_expr_parse( instring, loc, doActions, callPreParse=False ) File "/home/godu/anaconda3/lib/python3.6/site-packages/pyparsing.py", line 1529, in _parseCache value = self._parseNoCache(instring, loc, doActions, callPreParse) File "/home/godu/anaconda3/lib/python3.6/site-packages/pyparsing.py", line 1379, in _parseNoCache loc,tokens = self.parseImpl( instring, preloc, doActions ) File "/home/godu/anaconda3/lib/python3.6/site-packages/pyparsing.py", line 3467, in parseImpl return e._parse( instring, loc, doActions ) File "/home/godu/anaconda3/lib/python3.6/site-packages/pyparsing.py", line 1529, in _parseCache value = self._parseNoCache(instring, loc, doActions, callPreParse) File "/home/godu/anaconda3/lib/python3.6/site-packages/pyparsing.py", line 1379, in _parseNoCache loc,tokens = self.parseImpl( instring, preloc, doActions ) File "/home/godu/anaconda3/lib/python3.6/site-packages/pyparsing.py", line 3717, in parseImpl return self.expr._parse( instring, loc, doActions, callPreParse=False ) File "/home/godu/anaconda3/lib/python3.6/site-packages/pyparsing.py", line 1529, in _parseCache value = self._parseNoCache(instring, loc, doActions, callPreParse) File "/home/godu/anaconda3/lib/python3.6/site-packages/pyparsing.py", line 1379, in _parseNoCache loc,tokens = self.parseImpl( instring, preloc, doActions ) File "/home/godu/anaconda3/lib/python3.6/site-packages/pyparsing.py", line 3395, in parseImpl loc, exprtokens = e._parse( instring, loc, doActions ) File "/home/godu/anaconda3/lib/python3.6/site-packages/pyparsing.py", line 1529, in _parseCache value = self._parseNoCache(instring, loc, doActions, callPreParse) File "/home/godu/anaconda3/lib/python3.6/site-packages/pyparsing.py", line 1379, in _parseNoCache loc,tokens = self.parseImpl( instring, preloc, doActions ) File "/home/godu/anaconda3/lib/python3.6/site-packages/pyparsing.py", line 3919, in parseImpl return super(ZeroOrMore, self).parseImpl(instring, loc, doActions) File "/home/godu/anaconda3/lib/python3.6/site-packages/pyparsing.py", line 3858, in parseImpl loc, tmptokens = self_expr_parse( instring, preloc, doActions ) File "/home/godu/anaconda3/lib/python3.6/site-packages/pyparsing.py", line 1529, in _parseCache value = self._parseNoCache(instring, loc, doActions, callPreParse) File "/home/godu/anaconda3/lib/python3.6/site-packages/pyparsing.py", line 1379, in _parseNoCache loc,tokens = self.parseImpl( instring, preloc, doActions ) File "/home/godu/anaconda3/lib/python3.6/site-packages/pyparsing.py", line 3467, in parseImpl return e._parse( instring, loc, doActions ) File "/home/godu/anaconda3/lib/python3.6/site-packages/pyparsing.py", line 1529, in _parseCache value = self._parseNoCache(instring, loc, doActions, callPreParse) File "/home/godu/anaconda3/lib/python3.6/site-packages/pyparsing.py", line 1405, in _parseNoCache tokens = fn( instring, tokensStart, retTokens ) File "/home/godu/anaconda3/lib/python3.6/site-packages/pyparsing.py", line 1049, in wrapper ret = func(*args[limit[0]:]) File "/home/godu/gtsam/wrap/gtwrap/interface_parser/variable.py", line 42, in t.default[0] if isinstance(t.default, ParseResults) else None)) File "/home/godu/gtsam/wrap/gtwrap/interface_parser/variable.py", line 49, in init self.ctype = ctype[0] # ParseResult is a list TypeError: 'Type' object does not support indexing matlab/CMakeFiles/gtsam_matlab_wrapper.dir/build.make:74: recipe for target 'wrap/gtsam/gtsam_wrapper.cpp' failed make[2]: [wrap/gtsam/gtsam_wrapper.cpp] Error 1 CMakeFiles/Makefile2:36764: recipe for target 'matlab/CMakeFiles/gtsam_matlab_wrapper.dir/all' failed make[1]: [matlab/CMakeFiles/gtsam_matlab_wrapper.dir/all] Error 2 Makefile:162: recipe for target 'all' failed make: *** [all] Error 2

shaoxh commented 2 years ago

And I notice there is a new file named "Matlab_wrapper.tpl" after run make in the directory /home/godu/gtsam/wrap/gtwrap/matlab_wrapper. The file content is something like:

include "wrap/matlab.h"

include "map"

Don't know if that information could help.

shaoxh commented 2 years ago

I was using develop branch. godu@godu-Precision-7820-Tower:~/gtsam/build$ git log commit 12f32187f1e259af541159edd6d6efab0277dc6b (HEAD -> develop, origin/develop, origin/HEAD, info) Merge: d314fda66 70b0e9522 Author: Fan Jiang ProfFan@users.noreply.github.com Date: Thu Oct 14 14:37:52 2021 -0400

Merge pull request #892 from borglab/add-axis-angle-stress-test

Add unit tests where angle of (axis,angle) repr. exceeds 180 degrees by <0.5 deg
ProfFan commented 2 years ago

@varunagrawal I think the wrap update has broken MATLAB?

@shaoxh Please use a version before d2bb299 and see if that works.

varunagrawal commented 2 years ago

Okay I'm looking into it.

shaoxh commented 2 years ago

@varunagrawal I think the wrap update has broken MATLAB?

@shaoxh Please use a version before d2bb299 and see if that works.

I used this commit but not work. Is there something wrong with the python version?

-- Building GTSAM - shared: ON -- Found Python: /home/godu/anaconda3/bin/python3.6 (found suitable exact version "3.6.5") found components: Interpreter Development -- gtwrap Package config : /usr/local/lib/cmake/gtwrap

godu@godu-Precision-7820-Tower:~/gtsam/build$ git log commit 108cd13ecd1cda7acbb62360628b526b8336ea80 (HEAD) Merge: b4b2f41f2 4307b842c Author: Varun Agrawal varagrawal@gmail.com Date: Tue Sep 28 10:09:10 2021 -0400

Merging 'master' into 'wrap'
varunagrawal commented 2 years ago

Unfortunatey, I cannot reproduce this bug. Let me try with Python 3.6.

varunagrawal commented 2 years ago

Even Python 3.6.5 works for me (latest develop). @shaoxh can you please share the output of your cmake?

shaoxh commented 2 years ago

Even Python 3.6.5 works for me (latest develop). @shaoxh can you please share the output of your cmake? Hi, @varunagrawal ! cmake could work successfully and message goes as follows.

godu@godu-Precision-7820-Tower:~/gtsam/build$ rm -rf ./* godu@godu-Precision-7820-Tower:~/gtsam/build$ ls godu@godu-Precision-7820-Tower:~/gtsam/build$ cmake -DGTSAM_INSTALL_MATLAB_TOOLBOX=ON \

-DGTSAM_TOOLBOX_INSTALL_PATH:PATH=$HOME/toolbox \ -DGTSAM_BUILD_UNSTABLE=OFF \ -DCMAKE_BUILD_TYPE=Release \ -DGTSAM_BUILD_UNSTABLE:OPTION=OFF .. -- The CXX compiler identification is GNU 7.5.0 -- The C compiler identification is GNU 7.5.0 -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Performing Test COMPILER_HAS_WSUGGEST_OVERRIDE -- Performing Test COMPILER_HAS_WSUGGEST_OVERRIDE - Success -- Performing Test COMPILER_HAS_WMISSING_OVERRIDE -- Performing Test COMPILER_HAS_WMISSING_OVERRIDE - Failed -- GTSAM_POSE3_EXPMAP=ON, enabling GTSAM_ROT3_EXPMAP as well -- Found Boost: /usr/local/lib/cmake/Boost-1.74.0/BoostConfig.cmake (found suitable version "1.74.0", minimum required is "1.65") found components: serialization system filesystem thread program_options date_time timer chrono regex -- Found Eigen version: 3.3.7 -- Looking for execinfo.h -- Looking for execinfo.h - found -- Looking for getline -- Looking for getline - found -- checking for thread-local storage - found -- Could NOT find MKL (missing: MKL_INCLUDE_DIR MKL_LIBRARIES) -- Found OpenMP_C: -fopenmp (found version "4.5") -- Found OpenMP_CXX: -fopenmp (found version "4.5") -- Found OpenMP: TRUE (found version "4.5")
-- Found Python3: /home/godu/anaconda3/bin/python3.6 (found version "3.6.5") found components: Interpreter Development -- Found TBB: /usr/include (found suitable version "2017.0", minimum required is "4.4") found components: tbb tbbmalloc -- Building 3rdparty -- Could NOT find GeographicLib (missing: GeographicLib_LIBRARY_DIRS GeographicLib_LIBRARIES GeographicLib_INCLUDE_DIRS) -- Building base -- Building basis -- Building geometry -- Building inference -- Building symbolic -- Building discrete -- Building linear -- Building nonlinear -- Building sam -- Building sfm -- Building slam -- Building navigation -- GTSAM Version: 4.1.0 -- Install prefix: /usr/local -- Building GTSAM - shared: ON -- Found Python: /home/godu/anaconda3/bin/python3.6 (found suitable exact version "3.6.5") found components: Interpreter Development -- gtwrap Package config : /usr/local/lib/cmake/gtwrap -- gtwrap version : 1.0 -- gtwrap CMake path : /usr/local/lib/cmake/gtwrap -- gtwrap library path : /usr/local/lib/gtwrap -- gtwrap binary path : /usr/local/bin/gtwrap -- gtwrap header path : /usr/local/include/gtwrap -- Found Matlab: /home/godu/Documents/MATLAB/R2021b/extern/include (found version "9.11") found components: MEX_COMPILER -- Building wrap module gtsam -- Found PythonInterp: /home/godu/anaconda3/bin/python3.6 (found suitable exact version "3.6.5") -- Found PythonLibs: /home/godu/anaconda3/lib/libpython3.6m.so (found suitable exact version "3.6.5") -- Installing Matlab Toolbox to /home/godu/toolbox -- GTSAM_SOURCE_ROOT_DIR: [/home/godu/gtsam] -- Wrote /home/godu/gtsam/build/GTSAMConfig.cmake -- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE) -- =============================================================== -- ================ Configuration Options ====================== -- CMAKE_CXX_COMPILER_ID type : GNU -- CMAKE_CXX_COMPILER_VERSION : 7.5.0 -- CMake version : 3.14.3 -- CMake generator : Unix Makefiles -- CMake build tool : /usr/bin/make -- Build flags
-- Build Tests : Enabled -- Build examples with 'make all' : Enabled -- Build timing scripts with 'make all' : Disabled -- Build shared GTSAM libraries : Enabled -- Put build type in library name : Enabled -- Build libgtsam_unstable : Disabled -- Build GTSAM unstable Python : Enabled -- Build MATLAB Toolbox for unstable : Disabled -- Build for native architecture : Enabled -- Build type : Release -- C compilation flags : -O3 -DNDEBUG -- C++ compilation flags : -O3 -DNDEBUG -- GTSAM_COMPILE_FEATURES_PUBLIC : cxx_std_11 -- GTSAM_COMPILE_OPTIONS_PUBLIC : -march=native -- GTSAM_COMPILE_DEFINITIONS_PUBLIC : -- GTSAM_COMPILE_OPTIONS_PUBLIC_DEBUG : -- GTSAM_COMPILE_DEFINITIONS_PUBLIC_DEBUG : -- GTSAM_COMPILE_OPTIONS_PUBLIC_RELEASE : -- GTSAM_COMPILE_DEFINITIONS_PUBLIC_RELEASE : -- GTSAM_COMPILE_OPTIONS_PUBLIC_TIMING : -- GTSAM_COMPILE_DEFINITIONS_PUBLIC_TIMING : -- GTSAM_COMPILE_OPTIONS_PUBLIC_PROFILING : -- GTSAM_COMPILE_DEFINITIONS_PUBLIC_PROFILING : -- GTSAM_COMPILE_OPTIONS_PUBLIC_RELWITHDEBINFO : -- GTSAM_COMPILE_DEFINITIONS_PUBLIC_RELWITHDEBINFO : -- GTSAM_COMPILE_OPTIONS_PUBLIC_MINSIZEREL : -- GTSAM_COMPILE_DEFINITIONS_PUBLIC_MINSIZEREL : -- Use System Eigen : OFF (Using version: 3.3.7) -- Use System Metis : OFF -- Use Intel TBB : Yes (Version: 2017.0) -- Eigen will use MKL : MKL not found -- Eigen will use MKL and OpenMP : OpenMP found but GTSAM_WITH_EIGEN_MKL is disabled -- Default allocator : TBB -- Cheirality exceptions enabled : YES -- Build with ccache : No -- Packaging flags -- CPack Source Generator : TGZ -- CPack Generator : TGZ -- GTSAM flags
-- Quaternions as default Rot3 : Disabled -- Runtime consistency checking : Disabled -- Rot3 retract is full ExpMap : Enabled -- Pose3 retract is full ExpMap : Enabled -- Allow features deprecated in GTSAM 4.1 : Enabled -- Metis-based Nested Dissection : Enabled -- Use tangent-space preintegration : Enabled -- MATLAB toolbox flags -- Install MATLAB toolbox : Enabled -- MATLAB root : /home/godu/Documents/MATLAB/R2021b -- MEX binary : /home/godu/Documents/MATLAB/R2021b/bin/glnxa64/mex -- Python toolbox flags
-- Build Python module with pybind : Disabled -- =============================================================== -- Configuring done -- Generating done -- Build files have been written to: /home/godu/gtsam/build

varunagrawal commented 2 years ago

And what is your OS version?

shaoxh commented 2 years ago

And what is your OS version?

oh, it's ubuntu 18.04.

shaoxh commented 2 years ago

After tried python 3.6.9, this error no long occurred! It's annoying that minor python version affects project. I think something does not work fine with a function of python3.6/site-packages/pyparsing.py there in gtsam code. So what's your python minor version @varunagrawal ?

varunagrawal commented 2 years ago

I tried with python 3.6.5 and it worked for me. I wonder if your pyparsing version was an older one perhaps.

shaoxh commented 2 years ago

I wonder if your pyparsing version was an older one perhaps.

Thank you

shaoxh commented 2 years ago

Or users if have this problems in your compiling, may refer to a compiled matlab tool box here: https://github.com/kanster/gtsam_toolbox

Gary2077 commented 2 years ago

I have the same problem and fix it with: pip install pyparsing.