Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for GTSAM 4.1+, and make installable through pip #6

Merged
merged 46 commits into from
Dec 10, 2021

Conversation

btalb
Copy link
Collaborator

@btalb btalb commented Sep 17, 2021

Pull request for the following @lachlan-nicholson :

  • Adds gtsam as a submodule in the root directory, tracking the latest commit on develop (newer than 4.1rc)
  • Changing of namespaces of all code in gtsam_quadrics/ from gtsam to gtsam_quadrics
  • Conversion of gtsam_quadrics.h to gtsam_quadrics/qtsam_quadrics.i and gtsam_quadrics/gtsam_quadrics.tpl for PyBind11
  • Re-writing of Python binding code in CMakeLists.txt to use new pybind_wrap() functionality
  • CMakeLists.txt was changed to have a rigid link to the gtsam submodule, and its bundled version of gtwrap
  • Leave decision of shared vs static library to the user via the BUILD_SHARED_LIBS setting (Python packages require static libraries)
  • Removal of links to the old MATLAB wrapper in CMakeLists.txt
  • Removal of old cmake_uninstall.cmake.in target (was getting in the way of default uninstall target)
  • Python package building files added (pyproject.toml, setup.py, MANIFEST.in)
  • Custom Python extension for building the CMake project and packaging it's outputs
  • GitHub Action for building and uploading the latest version to PyPI when a new release is created
  • Gave the project a starting version number of v0.1.0

Known issues:

  • The virtual PriorFactor class didn't seem to work in the bindings (see comments in gtsam_quadrics/gtsam_quadrics.i
  • Currently you have to import gtsam before import gtsam_quadrics works (haven't yet dug into whether that's a symptom of a dependency not being declared, or an issue of how I'm linking to gtsam)
  • Examples have been disabled in CMakeLists.txt for now, I'm going to move onto them next
  • I've rejigged the README with the new install process, but there's still a few places that need to be touched up for accuracy
  • I don't use any of the CMake install targets in my build processes (a static Python wrapper can be installed without C++ headers needing to be installed on your system), so I haven't tested what state the install targets are in
  • No version is on PyPI yet, as I can't run the GitHub Action until this is merged into master
  • No Conda Feedstock exists yet, as I need it on PyPI before doing this.

Can you give this a look over, and let me know of any regressions I haven't picked up on? Probably easiest to merge this in, then I'll address any of your feedback in future commits.

@dishank-b
Copy link

When is this going to be merged? I want to install gtsam_quadrics and I have gtsam 4.1.x already installed. If this merge is gonna be soon, I can wait for installing gtsam_quadrics.

@btalb
Copy link
Collaborator Author

btalb commented Sep 22, 2021

Intention is for this merge to be in within the next week or so @dishank-b.

When it is done you will be able to simply pip install gtsam_quadrics.

Note though, that this will link against an included version of GTSAM 4.1 (see the submodule in this branch). At this stage we don't have direct plans to support using an already installed version instead.

We're always curious about user use-cases. Will you be able to achieve what you need using the bundled GTSAM 4.1 instead of your manually installed copy? Or is there a reason you need the already installed version?

If you're itching to get up and running, this should theoretically let you use a system version of GTSAM:

  1. Clone this repo, and check out the feature/gtsam-4.1 branch (don't initialise the submodule)
  2. Attempt the manual process. The CMake step will probably require fiddling with things to make it link against your already installed GTSAM (things like -DGTSAM_DIR= and -Dgtwrap_DIR=, plus commenting out add_subdirectory() calls)
  3. At the end of the build process you should have CPython.so files you can import in Python

@btalb btalb mentioned this pull request Sep 22, 2021
@dishank-b
Copy link

@btalb Thanks for replying.

I do not necessarily want to use system gtsam, it's just that gtsam is already installed and I don't want to have two duplicates of gtsam if gtsam_quadrics install one manually to avoid dependency issues if there will be any.

I have to get going on my project so I guess I will just start with what you suggested to install manually. Thanks again.

@dishank-b
Copy link

@btalb Also, I don't know if you will be able to help but I have one more query.

Is there a way to get the full the code for the paper "QuadricSLAM: Dual Quadrics from Object Detections as Landmarks in Object-oriented SLAM"?

I understand that this repository is for this paper, but it is missing many components from the paper such as object detector for TUM dataset and the front-end of the SLAM system. I would be really grateful if I can get the code of the paper to reproduce the slam system.

Thanks!

@btalb
Copy link
Collaborator Author

btalb commented Sep 22, 2021

In that case, these instructions should get you into a working state with Python bindings:
https://github.com/best-of-acrv/gtsam-quadrics/tree/feature/gtsam-4.1#from-source

Essentially you'll just need to:

  1. Clone recursively
  2. Run pip install . in the cloned directory

Looking through the README in this branch should help you out: https://github.com/best-of-acrv/gtsam-quadrics/tree/feature/gtsam-4.1

In terms of full code for what was done in the paper, that's one @lachlan-nicholson will be able to answer best.

@dishank-b
Copy link

dishank-b commented Sep 23, 2021

pip install . is not working. Giving error: ERROR: Could not build wheels for gtsam-quadrics which use PEP 517 and cannot be installed directly.

Also I am on MacOS Catalina.

@dishank-b
Copy link

dishank-b commented Sep 23, 2021

I tried to use CMake to install, but I get the following error during build:

make[2]: *** [CMakeFiles/gtsam_quadrics.dir/gtsam_quadrics/geometry/BoundingBoxFactor.cpp.o] Error 1
make[1]: *** [CMakeFiles/gtsam_quadrics.dir/all] Error 2
make: *** [all] Error 2

Error are these:

/Users/dishank/projects/prob_slam/gtsam-quadrics/gtsam_quadrics/geometry/BoundingBoxFactor.cpp:81:71: error: use of undeclared
      identifier '_1'
          funPtr(boost::bind(&BoundingBoxFactor::evaluateError, this, _1, _2,
                                                                      ^
/Users/dishank/projects/prob_slam/gtsam-quadrics/gtsam_quadrics/geometry/BoundingBoxFactor.cpp:81:75: error: use of undeclared
      identifier '_2'
          funPtr(boost::bind(&BoundingBoxFactor::evaluateError, this, _1, _2,

@btalb
Copy link
Collaborator Author

btalb commented Sep 23, 2021

This has only been tested on Ubuntu 20.04 so far @dishank-b , though in theory it shouldn't be restricted to that.

The pip install . will be failing due to the CMake error as it runs those CMake commands underneath. If you run pip install -vv . I suspect you'll see a similar error to the CMake error you've reported.

The CMake error appears to be due to Boost. I'll need some more details before I can try to help:

  1. Details of what is currently checked out: git status && git rev-parse HEAD
  2. Full log of CMake errors (in particular, the output at the configure step where it shows what versions of libraries were found)

@dishank-b
Copy link

dishank-b commented Sep 24, 2021

thanks for replying again.

Yeah, I figured it was due to boost version mismatch.

I just made changes in two lines which were giving error in the source code, as mentioned here https://stackoverflow.com/questions/15359553/stdbind-compiling-unexpected-undeclared-identifier-error-in-visual-studio

Basically in the boost function call, replaced _1 with placeholder::_1.

It solved my issue, I was able to build successfully and able to use gtsam_quadrics.

The only problem is that now when I import gtsam it's importing the original gtsam which I had installed separately before instead of importing the one which was packaged with gtsam_quadrics. But since the original gtsam is also 4.1.0, I hope that there will be no problem.

right now I am able to import gtsam-4.1.0 (installed separately) and gtsam_quadrics. So i guess all good.

Thanks for all the help. :)

@btalb btalb merged commit 854fe8e into master Dec 10, 2021
@1184919257
Copy link

@dishank-b Hi. I am recreating this project recently, but all three installations for Python are failed.
And pip install . also Giving error: ERROR: Could not build wheels for gtsam-quadrics which use PEP 517 and cannot be installed directly.
So did you configure it successfully for python, or can you give me some advice?

@lachlan-nicholson
Copy link
Collaborator

@1184919257 The error you mentioned only explains that the build has failed. The build will fail if cmake and boost are not installed. You can install these packages with the following: sudo apt-get install cmake libboost-all-dev. If this is not the issue you are having then please send the entire error message and I can have a look.

@1184919257
Copy link

@lachlan-nicholson Thanks for reply. My environment configurations are python 3.9, build-essential 12.8ubuntu1.1,cmake 3.16.3-1ubuntu1, libboost-all-dev 1.71.0.0ubuntu2,libmetis-dev 5.1.0.dfsg-5.
The error is as follow:

  • Processing /home/yjhl/project/gtsam-quadrics-master
    Installing build dependencies ... done
    Getting requirements to build wheel ... done
    Preparing metadata (pyproject.toml) ... done
    Building wheels for collected packages: gtsam-quadrics
    Building wheel for gtsam-quadrics (pyproject.toml) ... error
    error: subprocess-exited-with-error

    × Building wheel for gtsam-quadrics (pyproject.toml) did not run successfully.
    │ exit code: 1
    ╰─> [18 lines of output]
    Warning: 'classifiers' should be a list, got type 'tuple'
    running bdist_wheel
    running build
    running build_ext
    CMake Error at CMakeLists.txt:1 (project):
    Running

       '/tmp/pip-build-env-rghc2_wz/overlay/bin/ninja' '--version'
    
      failed with:
    
       No such file or directory
    
    
    -- Configuring incomplete, errors occurred!
    See also "/home/yjhl/project/gtsam-quadrics-master/build/temp.linux-x86_64-3.9/CMakeFiles/CMakeOutput.log".
    See also "/home/yjhl/project/gtsam-quadrics-master/build/temp.linux-x86_64-3.9/CMakeFiles/CMakeError.log".
    error: command '/usr/bin/cmake' failed with exit code 1
    [end of output]
    

    note: This error originates from a subprocess, and is likely not a problem with pip.
    ERROR: Failed building wheel for gtsam-quadrics
    Failed to build gtsam-quadrics
    ERROR: Could not build wheels for gtsam-quadrics, which is required to install pyproject.toml-based projects

I'm not sure if this is an environment version issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants