mjd3 / tracikpy

Python Bindings for TracIK
MIT License
38 stars 4 forks source link

Installation issue with C++11 standard + potential fix #4

Closed DanielTakeshi closed 3 years ago

DanielTakeshi commented 3 years ago

Hi @mjd3 thanks for the great repo! On an Ubuntu 16.04 system I have all the requirements:

(py3-yumi) seita@triton1:~/yumi_env/tracikpy (main) $ (dpkg-query -W -f='${Status}' libeigen3-dev 2>/dev/null | grep -c "ok installed")
1
(py3-yumi) seita@triton1:~/yumi_env/tracikpy (main) $ (dpkg-query -W -f='${Status}' liborocos-kdl-dev 2>/dev/null | grep -c "ok installed")
1
(py3-yumi) seita@triton1:~/yumi_env/tracikpy (main) $ (dpkg-query -W -f='${Status}' libkdl-parser-dev 2>/dev/null | grep -c "ok installed")
1
(py3-yumi) seita@triton1:~/yumi_env/tracikpy (main) $ (dpkg-query -W -f='${Status}' liburdfdom-dev 2>/dev/null | grep -c "ok installed")
1
(py3-yumi) seita@triton1:~/yumi_env/tracikpy (main) $ (dpkg-query -W -f='${Status}' libnlopt-dev 2>/dev/null | grep -c "ok installed")
1

I then clone the repo and attempt to pip install:

(py3-yumi) seita@triton1:~/yumi_env/tracikpy (main) $ pip install -e .
Obtaining file:///home/seita/yumi_env/tracikpy
Requirement already satisfied: numpy in /home/seita/venvs/py3-yumi/lib/python3.7/site-packages (from tracikpy==0.1.0) (1.21.1)
Installing collected packages: tracikpy
  Running setup.py develop for tracikpy
    ERROR: Command errored out with exit status 1:
     command: /home/seita/venvs/py3-yumi/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/home/seita/yumi_env/tracikpy/setup.py'"'"'; __file__='"'"'/home/seita/yumi_env/tracikpy/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps
         cwd: /home/seita/yumi_env/tracikpy/
    Complete output (94 lines):
    running develop
    running egg_info
    creating tracikpy.egg-info
    writing tracikpy.egg-info/PKG-INFO
    writing dependency_links to tracikpy.egg-info/dependency_links.txt
    writing requirements to tracikpy.egg-info/requires.txt
    writing top-level names to tracikpy.egg-info/top_level.txt
    writing manifest file 'tracikpy.egg-info/SOURCES.txt'
    reading manifest file 'tracikpy.egg-info/SOURCES.txt'
    writing manifest file 'tracikpy.egg-info/SOURCES.txt'
    running build_ext
    building 'tracikpy.swig._trac_ik_wrap' extension
    swigging tracikpy/swig/trac_ik.i to tracikpy/swig/trac_ik_wrap.cpp
    swig -python -c++ -Itracikpy/include -o tracikpy/swig/trac_ik_wrap.cpp tracikpy/swig/trac_ik.i
    creating build
    creating build/temp.linux-x86_64-3.7
    creating build/temp.linux-x86_64-3.7/tracikpy
    creating build/temp.linux-x86_64-3.7/tracikpy/swig
    creating build/temp.linux-x86_64-3.7/tracikpy/src
    x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Itracikpy/include -I/usr/include/eigen3 -I/home/seita/venvs/py3-yumi/include -I/usr/include/python3.7m -c tracikpy/swig/trac_ik_wrap.cpp -o build/temp.linux-x86_64-3.7/tracikpy/swig/trac_ik_wrap.o
    In file included from /usr/include/c++/5/thread:35:0,
                     from tracikpy/include/trac_ik.hpp:37,
                     from tracikpy/swig/trac_ik_wrap.cpp:3146:
    /usr/include/c++/5/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
     #error This file requires compiler and library support \
      ^
    In file included from tracikpy/swig/trac_ik_wrap.cpp:3146:0:
    tracikpy/include/trac_ik.hpp:113:8: error: ‘unique_ptr’ in namespace ‘std’ does not name a template type
       std::unique_ptr<KDL::ChainJntToJacSolver> jacsolver;
            ^
    tracikpy/include/trac_ik.hpp:118:8: error: ‘unique_ptr’ in namespace ‘std’ does not name a template type
       std::unique_ptr<NLOPT_IK::NLOPT_IK> nl_solver;
            ^
    tracikpy/include/trac_ik.hpp:119:8: error: ‘unique_ptr’ in namespace ‘std’ does not name a template type
       std::unique_ptr<KDL::ChainIkSolverPos_TL> iksolver;
            ^
    tracikpy/include/trac_ik.hpp:121:8: error: ‘chrono’ in namespace ‘std’ does not name a type
       std::chrono::time_point<std::chrono::steady_clock> start_time;
            ^
    tracikpy/include/trac_ik.hpp:135:8: error: ‘mutex’ in namespace ‘std’ does not name a type
       std::mutex mtx_;
            ^
    tracikpy/include/trac_ik.hpp:139:8: error: ‘thread’ in namespace ‘std’ does not name a type
       std::thread task1, task2;
            ^
    tracikpy/include/trac_ik.hpp: In member function ‘bool TRAC_IK::TRAC_IK::setKDLLimits(KDL::JntArray&, KDL::JntArray&)’:
    tracikpy/include/trac_ik.hpp:86:5: error: ‘nl_solver’ was not declared in this scope
         nl_solver.reset(new NLOPT_IK::NLOPT_IK(chain, lb, ub, maxtime, eps, NLOPT_IK::SumSq));
         ^
    tracikpy/include/trac_ik.hpp:87:5: error: ‘iksolver’ was not declared in this scope
         iksolver.reset(new KDL::ChainIkSolverPos_TL(chain, lb, ub, maxtime, eps, true, true));
         ^
    tracikpy/include/trac_ik.hpp: In member function ‘bool TRAC_IK::TRAC_IK::runKDL(const KDL::JntArray&, const KDL::Frame&)’:
    tracikpy/include/trac_ik.hpp:170:21: error: ‘iksolver’ was not declared in this scope
       return runSolver(*iksolver.get(), *nl_solver.get(), q_init, p_in);
                         ^
    tracikpy/include/trac_ik.hpp:170:38: error: ‘nl_solver’ was not declared in this scope
       return runSolver(*iksolver.get(), *nl_solver.get(), q_init, p_in);
                                          ^
    tracikpy/include/trac_ik.hpp: In member function ‘bool TRAC_IK::TRAC_IK::runNLOPT(const KDL::JntArray&, const KDL::Frame&)’:
    tracikpy/include/trac_ik.hpp:175:21: error: ‘nl_solver’ was not declared in this scope
       return runSolver(*nl_solver.get(), *iksolver.get(), q_init, p_in);
                         ^
    tracikpy/include/trac_ik.hpp:175:39: error: ‘iksolver’ was not declared in this scope
       return runSolver(*nl_solver.get(), *iksolver.get(), q_init, p_in);
                                           ^
    tracikpy/swig/trac_ik_wrap.cpp: In function ‘TRAC_IK::TRAC_IK* new_TRAC_IK_TRAC_IK(const string&, const string&, const string&, double, double, const string&)’:
    tracikpy/swig/trac_ik_wrap.cpp:5587:36: error: ‘lowest’ is not a member of ‘std::numeric_limits<float>’
                 joint_min(joint_num-1)=std::numeric_limits<float>::lowest();
                                        ^
    tracikpy/swig/trac_ik_wrap.cpp: In function ‘std::vector<std::vector<double>, std::allocator<std::vector<double> > > TRAC_IK_TRAC_IK_JntToCart(TRAC_IK::TRAC_IK*, std::vector<double>)’:
    tracikpy/swig/trac_ik_wrap.cpp:5665:7: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
           };
           ^
    tracikpy/swig/trac_ik_wrap.cpp:5660:12: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
           vout = {
                ^
    tracikpy/swig/trac_ik_wrap.cpp: In substitution of ‘template<class _InputIterator> std::vector<_Tp, _Alloc>::vector(_InputIterator, _InputIterator, const allocator_type&) [with _InputIterator = <missing>]’:
    tracikpy/swig/trac_ik_wrap.cpp:5660:12:   required from here
    tracikpy/swig/trac_ik_wrap.cpp:5660:12: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
    tracikpy/swig/trac_ik_wrap.cpp: In substitution of ‘template<class _InputIterator> std::vector<_Tp, _Alloc>::vector(_InputIterator, _InputIterator, const allocator_type&) [with _InputIterator = <missing>]’:
    tracikpy/swig/trac_ik_wrap.cpp:5660:12:   required from here
    tracikpy/swig/trac_ik_wrap.cpp:5660:12: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
    tracikpy/swig/trac_ik_wrap.cpp:5660:12: error: no match for ‘operator=’ (operand types are ‘std::vector<std::vector<double>, std::allocator<std::vector<double> > >’ and ‘<brace-enclosed initializer list>’)
    In file included from /usr/include/c++/5/vector:69:0,
                     from /usr/include/nlopt.hpp:31,
                     from tracikpy/include/nlopt_ik.hpp:34,
                     from tracikpy/include/trac_ik.hpp:35,
                     from tracikpy/swig/trac_ik_wrap.cpp:3146:
    /usr/include/c++/5/bits/vector.tcc:167:5: note: candidate: std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = std::vector<double>; _Alloc = std::allocator<std::vector<double> >]
         vector<_Tp, _Alloc>::
         ^
    /usr/include/c++/5/bits/vector.tcc:167:5: note:   no known conversion for argument 1 from ‘<brace-enclosed initializer list>’ to ‘const std::vector<std::vector<double>, std::allocator<std::vector<double> > >&’
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /home/seita/venvs/py3-yumi/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/home/seita/yumi_env/tracikpy/setup.py'"'"'; __file__='"'"'/home/seita/yumi_env/tracikpy/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps Check the logs for full command output.
WARNING: You are using pip version 20.1.1; however, version 21.2.1 is available.
You should consider upgrading via the '/home/seita/venvs/py3-yumi/bin/python3 -m pip install --upgrade pip' command.
(py3-yumi) seita@triton1:~/yumi_env/tracikpy (main) $ 

The error appears to be something with the C++11 standard. Doing this one-line fix in setup.py:

(py3-yumi) seita@triton1:~/yumi_env/tracikpy (main) $ git diff
diff --git a/setup.py b/setup.py
index e14259c..ae36972 100644
--- a/setup.py
+++ b/setup.py
@@ -33,6 +33,7 @@ _trac_ik_wrap = Extension(
     ],
     libraries=["orocos-kdl", "nlopt", "urdf", "kdl_parser"],
     swig_opts=["-c++", "-Itracikpy/include"],
+    extra_compile_args=['-std=c++11']
 )

 setup(
(py3-yumi) seita@triton1:~/yumi_env/tracikpy (main) $ 

And then doing the pip install -e . again seems to work. (Source for the change)

mjd3 commented 3 years ago

Ah yeah it's a good point we do require the C++11 standard to build the library. I will update with the args you've mentioned here (or if you want to submit a PR that would also be welcome)!