Code Monkey home page Code Monkey logo

minisam's People

Contributors

dongjing3309 avatar edwinem avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

minisam's Issues

A use case of minisam for 3D lidar slam

Hi, I am a Ph.D. student, from KAIST, South Korea.

This issue is not intended to report any difficulties,
but to share a use-case of miniSAM.

For me, miniSAM was easy to use, especially for Python.
So I have created a simple, practical, and educational purpose 3D lidar SLAM example implemented using miniSAM.
https://github.com/kissb2/PyICP-SLAM

Thank you!

fatal error: fmt/core.h: No such file or directory

I followed the install instruction, and can compiler Sophus, but face the following error:
XXXXX/Sophus/sophus/common.hpp:42:10: fatal error: fmt/core.h: No such file or directory
#include <fmt/core.h>
^~~~~~~~~~~~

I checked the CMakelist of Sophus, and found the following settings:
if(USE_BASIC_LOGGING)
set (CMAKE_DISABLE_FIND_PACKAGE_fmt ON)
endif()

Should I set OFF and re-make the Sophus?

I modified the Sophus cmake file, and installed sucessfully, but facing make error in minisam, and occured many times during compile the examples (optimize_custom_type, robust_curve_fitting, pose_graph_example, etc.):
../../minisam/libminisam.so: undefined reference to fmt::v8::vprint(fmt::v8::basic_string_view<char>, fmt::v8::basic_format_args<fmt::v8::basic_format_context<fmt::v8::appender, char> >)' ../../minisam/libminisam.so: undefined reference to fmt::v8::detail::throw_format_error(char const*)'
../../minisam/libminisam.so: undefined reference to `std::locale fmt::v8::detail::locale_ref::getstd::locale() const'
collect2: error: ld returned 1 exit status
examples/cpp/CMakeFiles/optimize_custom_type.dir/build.make:111: recipe for target 'examples/cpp/optimize_custom_type' failed
make[2]: *** [examples/cpp/optimize_custom_type] Error 1
CMakeFiles/Makefile2:1171: recipe for target 'examples/cpp/CMakeFiles/optimize_custom_type.dir/all' failed
make[1]: *** [examples/cpp/CMakeFiles/optimize_custom_type.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

Python wrapper fails upon import

I compiled and installed the C++ and then Python according to instructions and when I finally do import minisam I get this error:


ImportError Traceback (most recent call last)
in
----> 1 import minisam

~/anaconda3/lib/python3.7/site-packages/minisam/init.py in
1
2 # wrapped c++ module
----> 3 from . _minisam_py_wrapper import *
4
5

ImportError: /home/maintenance/anaconda3/lib/python3.7/site-packages/minisam/_minisam_py_wrapper.cpython-37m-x86_64-linux-gnu.so: undefined symbol: _Z13wrap_geometryRN8pybind116moduleE

What am I missing?

install with pip from pypi

Thanks for publishing this library, it is very useful. Can it be added to pypi, to facilitate easy installation via pip install minisam? This also would allow easy install without sudo (pip install --user minisam).

You might then have to package sophus with it, since that is often not available as a system dependency, at least not on mac and ubuntu AFAIK.

For the record, I use the following steps to install minisam (just python package, and without sudo). Tested on macos and ubuntu 18.04.

# 1. install sophus

# a) check for registered setups of sophus; possibly remove old files
ls ~/.cmake/packages/Sophus/

# b) setup / register with cmake:
git clone https://github.com/strasdat/Sophus.git
cd Sophus
mkdir build && cd build
cmake ..
make -j8

# 2. install minisam (pip package)

git clone https://github.com/dongjing3309/minisam.git
cd minisam
mkdir build && cd build
cmake .. -DMINISAM_BUILD_PYTHON_PACKAGE=ON
# Note: using the following flags seems to make the solver hang in python:
# -DMINISAM_WITH_MULTI_THREADS=On -DMINISAM_WITH_MULTI_THREADS_NUM=8
make -j8
pip install --user .

Make Error 20.04

Hi all,

cmake info:

-- The CXX compiler identification is GNU 9.4.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
-- Search Dependency: Eigen3
-- Found Eigen3: /usr/include/eigen3 (Required is at least version "2.91.0") 
-- Search Dependency: Sophus
-- Search Dependency: Cholmod
-- Found CHOLMOD: /usr/include/suitesparse  
-- Search Dependency: SPQR
-- Found SPQR: /usr/include/suitesparse  
-- Build module: core
-- Build module: linear
-- Build module: nonlinear
-- Build module: utils
-- Build module: geometry
-- Build module: slam
-- Build module: linear/cholmod
-- Build module: linear/spqr
-- Library: build shared library
-- Install 3rd-party module: eigen3
-- Add all unit tests, exclude:  ;testCUDASolver
-- Add all C++ examples, exclude:  
-- git submodule update: pybind11
-- Found PythonInterp: /usr/bin/python3.8 (found version "3.8.10") 
-- Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython3.8.so
-- Performing Test HAS_CPP14_FLAG
-- Performing Test HAS_CPP14_FLAG - Success
-- pybind11 v2.3.dev1
-- ===============================================================
--                 Configurations for miniSAM                     
--  
--   Library type                Shared
--   Install path                /usr/local
--  
--   Compiler type               GNU
--   Compiler version            9.4.0
--   Built type                  Release
--   C++ compilation flags        -std=c++11 -Wall -Werror -Wextra -O3 -DNDEBUG
--  
--   Multi-threading             No
--   Internal profiling          No
--  
--   Eigen                       3.3.7 (/usr/include/eigen3)
--   Sophus                      Yes (/usr/local/share/sophus/cmake)
--   Cholmod                     Yes (/usr/include/suitesparse)
--   SPQR                        Yes (/usr/include/suitesparse)
--   CUDA cuSOLVER               No
--  
--   Python package              Yes
--   Python version              3.8
--   Python executable           /usr/bin/python3.8
--  
-- Configuring done
-- Generating done

Attempting to build this on Ubuntu 20.04 I end up with this error:

[  1%] Building CXX object minisam/CMakeFiles/minisam.dir/nonlinear/DoglegOptimizer.cpp.o
/home/paul/libs/minisam/minisam/nonlinear/DoglegOptimizer.cpp: In member function ‘minisam::NonlinearOptimizationStatus minisam::DoglegOptimizer::tryRadius_(const minisam::FactorGraph&, minisam::Variables&, const VectorXd&, const VectorXd&, double, double)’:
/home/paul/libs/minisam/minisam/nonlinear/DoglegOptimizer.cpp:140:75: error: implicitly-declared ‘minisam::Variables& minisam::Variables::operator=(const minisam::Variables&)’ is deprecated [-Werror=deprecated-copy]
  140 |       values_update = values.retract(dx_dl, h_sparsity_cache_.var_ordering);
      |                                                                           ^
In file included from /home/paul/libs/minisam/minisam/nonlinear/DoglegOptimizer.cpp:11:
/home/paul/libs/minisam/minisam/core/Variables.h:33:3: note: because ‘minisam::Variables’ has user-provided ‘minisam::Variables::Variables(const minisam::Variables&)’
   33 |   Variables(const Variables& variables);
      |   ^~~~~~~~~
/home/paul/libs/minisam/minisam/nonlinear/DoglegOptimizer.cpp:142:75: error: implicitly-declared ‘minisam::Variables& minisam::Variables::operator=(const minisam::Variables&)’ is deprecated [-Werror=deprecated-copy]
  142 |       values_update = values.retract(dx_dl, j_sparsity_cache_.var_ordering);
      |                                                                           ^
In file included from /home/paul/libs/minisam/minisam/nonlinear/DoglegOptimizer.cpp:11:
/home/paul/libs/minisam/minisam/core/Variables.h:33:3: note: because ‘minisam::Variables’ has user-provided ‘minisam::Variables::Variables(const minisam::Variables&)’
   33 |   Variables(const Variables& variables);
      |   ^~~~~~~~~
/home/paul/libs/minisam/minisam/nonlinear/DoglegOptimizer.cpp:208:16: error: implicitly-declared ‘minisam::Variables& minisam::Variables::operator=(const minisam::Variables&)’ is deprecated [-Werror=deprecated-copy]
  208 |       values = values_update;
      |                ^~~~~~~~~~~~~
In file included from /home/paul/libs/minisam/minisam/nonlinear/DoglegOptimizer.cpp:11:
/home/paul/libs/minisam/minisam/core/Variables.h:33:3: note: because ‘minisam::Variables’ has user-provided ‘minisam::Variables::Variables(const minisam::Variables&)’
   33 |   Variables(const Variables& variables);
      |   ^~~~~~~~~
cc1plus: all warnings being treated as errors
make[2]: *** [minisam/CMakeFiles/minisam.dir/build.make:232: minisam/CMakeFiles/minisam.dir/nonlinear/DoglegOptimizer.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:234: minisam/CMakeFiles/minisam.dir/all] Error 2
make: *** [Makefile:141: all] Error 2

Any ideas for how to resolve this?

Application of algorithms

Hi,I have a question to consult you :Can this code be applied to backend graph optimization in cross domain collaborative SLAM? (For example, air and land coordination, surface and underwater coordination)
Looking forward to your reply!

Error importing minisam module in Python

When I execute the following command
from minisam import *
I got an error report
Traceback (most recent call last): File "/home/wyw/codeProjects/pyProj/PyICP-SLAM/main_icp_slam.py", line 15, in <module> from minisam import * File "/home/wyw/anaconda3/envs/python_robotics/lib/python3.10/site-packages/minisam-0.0.0-py3.10.egg/minisam/__init__.py", line 3, in <module> ModuleNotFoundError: No module named 'minisam._minisam_py_wrapper'

Joint optimization with differerent type of variables

First, thanks for publishing the minisam library, it is very helpful.

However, I come across some problem, and hope to get some advice from you.

I am designing system like under, I have variables: lij and Ti, which is different type, one is a number belong to [0,1], one is a transformation belong to SE(2)

image

I first put all SE(2) in the initials, but when I put lij to initials, I get error like under
image

So I am wondering if we can't joint optimize different type of variables? 
image

I have an idea to work around like defining lij as SE(2), but only use part of it in error function, but I am curious if there is a way to do this directly.

Hi, issue during 'make' command about minisam::Variables& minisam::Variables::operator=(const minisam::Variables&)

Hi,

During compiling the code, the following errors occurs,
_
[ 2%] Building CXX object minisam/CMakeFiles/minisam.dir/nonlinear/DoglegOptimizer.cpp.o
[ 4%] Building CXX object minisam/CMakeFiles/minisam.dir/nonlinear/GaussNewtonOptimizer.cpp.o
[ 6%] Building CXX object minisam/CMakeFiles/minisam.dir/nonlinear/LevenbergMarquardtOptimizer.cpp.o
[ 8%] Building CXX object minisam/CMakeFiles/minisam.dir/nonlinear/NonlinearOptimizer.cpp.o
[ 11%] Building CXX object minisam/CMakeFiles/minisam.dir/nonlinear/NumericalFactor.cpp.o
[ 13%] Building CXX object minisam/CMakeFiles/minisam.dir/nonlinear/SparsityPattern.cpp.o
[ 15%] Building CXX object minisam/CMakeFiles/minisam.dir/nonlinear/linearization.cpp.o
[ 17%] Building CXX object minisam/CMakeFiles/minisam.dir/utils/Timer.cpp.o
[ 20%] Building CXX object minisam/CMakeFiles/minisam.dir/utils/testAssertions.cpp.o
/home/win/work/minisam/minisam/nonlinear/DoglegOptimizer.cpp: In member function ‘minisam::NonlinearOptimizationStatus minisam::DoglegOptimizer::tryRadius_(const minisam::FactorGraph&, minisam::Variables&, const VectorXd&, const VectorXd&, double, double)’:
/home/win/work/minisam/minisam/nonlinear/DoglegOptimizer.cpp:140:75: error: implicitly-declared ‘minisam::Variables& minisam::Variables::operator=(const minisam::Variables&)’ is deprecated [-Werror=deprecated-copy]
140 | values_update = values.retract(dx_dl, h_sparsity_cache_.var_ordering);
| ^
In file included from /home/win/work/minisam/minisam/nonlinear/DoglegOptimizer.cpp:11:
/home/win/work/minisam/minisam/core/Variables.h:33:3: note: because ‘minisam::Variables’ has user-provided ‘minisam::Variables::Variables(const minisam::Variables&)’
33 | Variables(const Variables& variables);
| ^~~~~~~~~
/home/win/work/minisam/minisam/nonlinear/DoglegOptimizer.cpp:142:75: error: implicitly-declared ‘minisam::Variables& minisam::Variables::operator=(const minisam::Variables&)’ is deprecated [-Werror=deprecated-copy]
142 | values_update = values.retract(dx_dl, j_sparsity_cache_.var_ordering);
| ^

_

My system is Ubuntu 20.04 with cuda installed as version 11.5.

make check failed in case testFactorGraph and AttributeError: module 'minisam' has no attribute 'SE3'

Hi, I try to install PyICP-SLAM which depends on minisam. then make check, runs in this error,

  Start  1: testCalibration

1/22 Test #1: testCalibration .................. Passed 0.01 sec
Start 2: testCholmod
2/22 Test #2: testCholmod ...................... Passed 0.01 sec
Start 3: testConjugateGradient
3/22 Test #3: testConjugateGradient ............ Passed 0.01 sec
Start 4: testCovariance
4/22 Test #4: testCovariance ................... Passed 0.01 sec
Start 5: testDenseCholesky
5/22 Test #5: testDenseCholesky ................ Passed 0.01 sec
Start 6: testDogleg
6/22 Test #6: testDogleg ....................... Passed 0.01 sec
Start 7: testEigen
7/22 Test #7: testEigen ........................ Passed 0.01 sec
Start 8: testFactorGraph
8/22 Test #8: testFactorGraph ..................***Failed 0.01 sec
Not equal:
expected: 10,
actual: 0,
Not equal:
expected: 10,
actual: 0,
Not equal:
expected: 11,
actual: 1,
Not equal:
expected: 11,
actual: 1,
Not equal:
expected size: 0
actual size: 6

testFactorGraph is a Catch v2.9.1 host application.
Run with -? for options

and I run PyICP-SLAM, this error occers,

File "/home/win/work/PyICP-SLAM/utils/PoseGraphManager.py", line 32, in addPriorFactor
self.graph_initials.add(minisam.key('x', self.curr_node_idx), minisam.SE3(self.curr_se3))
AttributeError: module 'minisam' has no attribute 'SE3'.

My system is ubuntu 20.04, Python 3.8.10..
Thank you.

Iterator over Variables and FactorGraph in Python

Hi Jing/Zhaoyang,

Great work with the library especially the Python wrapper. I was playing with it and I was not able to iterate over Variables. I could iterate over FactorGraph but I was not able to extract anything out of each factor.

I tried iterating like this:

 for key in initials:
     print(key)

And I get an error:

Traceback (most recent call last):
  File "gps_factor_example.py", line 109, in <module>
    for key in initials:
KeyError: '[python::Variables] key does not exist'

Wondering if I am doing something wrong or this is not supported yet.

make check failing on MacOS 12.6.2 (x86_64 architecture)

Hi, sorry for opening this request but I encountered this problem when performing the make check command during installation.
I'm using MacOS 12.6.2 on an Intel x86_64 architecture.
Here follows the output from the make check command,
Thank you for your availability,
Greetings

% make check               
[  1%] Built target catch_test_main
[ 40%] Built target minisam
[ 41%] Linking CXX executable testprojection
Undefined symbols for architecture x86_64:
  "fmt::v9::detail::is_printable(unsigned int)", referenced from:
      void fmt::v9::detail::for_each_codepoint<fmt::v9::detail::find_escape(char const*, char const*)::'lambda'(unsigned int, fmt::v9::basic_string_view<char>)>(fmt::v9::basic_string_view<char>, fmt::v9::detail::find_escape(char const*, char const*)::'lambda'(unsigned int, fmt::v9::basic_string_view<char>))::'lambda'(char const*, char const*)::operator()(char const*, char const*) const in testprojection.cpp.o
  "fmt::v9::detail::throw_format_error(char const*)", referenced from:
      decltype(fp.begin()) fmt::v9::formatter<fmt::v9::basic_string_view<char>, char, void>::parse<fmt::v9::basic_format_parse_context<char, fmt::v9::detail::error_handler> >(fmt::v9::basic_format_parse_context<char, fmt::v9::detail::error_handler>&) in testprojection.cpp.o
      char const* fmt::v9::detail::parse_width<char, fmt::v9::detail::specs_checker<fmt::v9::detail::dynamic_specs_handler<fmt::v9::basic_format_parse_context<char, fmt::v9::detail::error_handler> > >&>(char const*, char const*, fmt::v9::detail::specs_checker<fmt::v9::detail::dynamic_specs_handler<fmt::v9::basic_format_parse_context<char, fmt::v9::detail::error_handler> > >&) in testprojection.cpp.o
      char const* fmt::v9::detail::parse_precision<char, fmt::v9::detail::specs_checker<fmt::v9::detail::dynamic_specs_handler<fmt::v9::basic_format_parse_context<char, fmt::v9::detail::error_handler> > >&>(char const*, char const*, fmt::v9::detail::specs_checker<fmt::v9::detail::dynamic_specs_handler<fmt::v9::basic_format_parse_context<char, fmt::v9::detail::error_handler> > >&) in testprojection.cpp.o
      char const* fmt::v9::detail::do_parse_arg_id<char, char const* fmt::v9::detail::parse_width<char, fmt::v9::detail::specs_checker<fmt::v9::detail::dynamic_specs_handler<fmt::v9::basic_format_parse_context<char, fmt::v9::detail::error_handler> > >&>(char const*, char const*, fmt::v9::detail::specs_checker<fmt::v9::detail::dynamic_specs_handler<fmt::v9::basic_format_parse_context<char, fmt::v9::detail::error_handler> > >&)::width_adapter&>(char const*, char const*, fmt::v9::detail::specs_checker<fmt::v9::detail::dynamic_specs_handler<fmt::v9::basic_format_parse_context<char, fmt::v9::detail::error_handler> > >&) in testprojection.cpp.o
      char const* fmt::v9::detail::do_parse_arg_id<char, char const* fmt::v9::detail::parse_precision<char, fmt::v9::detail::specs_checker<fmt::v9::detail::dynamic_specs_handler<fmt::v9::basic_format_parse_context<char, fmt::v9::detail::error_handler> > >&>(char const*, char const*, fmt::v9::detail::specs_checker<fmt::v9::detail::dynamic_specs_handler<fmt::v9::basic_format_parse_context<char, fmt::v9::detail::error_handler> > >&)::precision_adapter&>(char const*, char const*, fmt::v9::detail::specs_checker<fmt::v9::detail::dynamic_specs_handler<fmt::v9::basic_format_parse_context<char, fmt::v9::detail::error_handler> > >&) in testprojection.cpp.o
      fmt::v9::appender fmt::v9::basic_ostream_formatter<char>::format<Eigen::Transpose<Eigen::Matrix<double, 4, 1, 0, 4, 1> >, fmt::v9::appender>(Eigen::Transpose<Eigen::Matrix<double, 4, 1, 0, 4, 1> > const&, fmt::v9::basic_format_context<fmt::v9::appender, char>&) const in testprojection.cpp.o
      int fmt::v9::detail::get_dynamic_spec<fmt::v9::detail::width_checker, fmt::v9::basic_format_arg<fmt::v9::basic_format_context<fmt::v9::appender, char> >, fmt::v9::detail::error_handler>(fmt::v9::basic_format_arg<fmt::v9::basic_format_context<fmt::v9::appender, char> >, fmt::v9::detail::error_handler) in testprojection.cpp.o
      ...
  "fmt::v9::vprint(fmt::v9::basic_string_view<char>, fmt::v9::basic_format_args<fmt::v9::basic_format_context<fmt::v9::appender, char> >)", referenced from:
      ____C_A_T_C_H____T_E_S_T____0() in testprojection.cpp.o
      ____C_A_T_C_H____T_E_S_T____4() in testprojection.cpp.o
      minisam::transform2sensor(Sophus::SE3<double, 0> const&, Eigen::Matrix<double, 3, 1, 0, 3, 1> const&) in testprojection.cpp.o
      minisam::internal::SophusTraitsImpl<Sophus::SE3<double, 0> >::Retract(Sophus::SE3<double, 0> const&, Eigen::Matrix<double, 6, 1, 0, 6, 1> const&) in testprojection.cpp.o
      Sophus::SO3<double, 0>::expAndTheta(Eigen::Matrix<double, 3, 1, 0, 3, 1> const&, double*) in testprojection.cpp.o
      minisam::transform2image(Sophus::SE3<double, 0> const&, Eigen::Matrix<double, 3, 1, 0, 3, 1> const&) in testprojection.cpp.o
      Eigen::Matrix<double, 2, 1, 0, 2, 1> minisam::project<minisam::CalibK>(Sophus::SE3<double, 0> const&, minisam::CalibK const&, Eigen::Matrix<double, 3, 1, 0, 3, 1> const&) in testprojection.cpp.o
      ...
  "minisam::projectBundler(Sophus::SE3<double, 0> const&, minisam::CalibBundler const&, Eigen::Matrix<double, 3, 1, 0, 3, 1> const&)", referenced from:
      ____C_A_T_C_H____T_E_S_T____10() in testprojection.cpp.o
  "minisam::projectBundlerJacobians(Sophus::SE3<double, 0> const&, minisam::CalibBundler const&, Eigen::Matrix<double, 3, 1, 0, 3, 1> const&, Eigen::Matrix<double, 2, 6, 0, 2, 6>&, Eigen::Matrix<double, 2, 3, 0, 2, 3>&, Eigen::Matrix<double, 2, 3, 0, 2, 3>&)", referenced from:
      ____C_A_T_C_H____T_E_S_T____10() in testprojection.cpp.o
  "minisam::transform2imageJacobians(Sophus::SE3<double, 0> const&, Eigen::Matrix<double, 3, 1, 0, 3, 1> const&, Eigen::Matrix<double, 2, 6, 0, 2, 6>&, Eigen::Matrix<double, 2, 3, 0, 2, 3>&)", referenced from:
      ____C_A_T_C_H____T_E_S_T____4() in testprojection.cpp.o
      void minisam::projectJacobians<minisam::CalibK>(Sophus::SE3<double, 0> const&, minisam::CalibK const&, Eigen::Matrix<double, 3, 1, 0, 3, 1> const&, Eigen::Matrix<double, 2, 6, 0, 2, 6>&, Eigen::Matrix<double, 2, minisam::CalibK::dim(), ((Eigen::StorageOptions)0) | ((((2) == (1)) && ((minisam::CalibK::dim()) != (1))) ? ((Eigen::StorageOptions)1) : ((((minisam::CalibK::dim()) == (1)) && ((2) != (1))) ? ((Eigen::StorageOptions)0) : ((Eigen::StorageOptions)0))), 2, minisam::CalibK::dim()>&, Eigen::Matrix<double, 2, 3, 0, 2, 3>&) in testprojection.cpp.o
      void minisam::projectJacobians<minisam::CalibKD>(Sophus::SE3<double, 0> const&, minisam::CalibKD const&, Eigen::Matrix<double, 3, 1, 0, 3, 1> const&, Eigen::Matrix<double, 2, 6, 0, 2, 6>&, Eigen::Matrix<double, 2, minisam::CalibKD::dim(), ((Eigen::StorageOptions)0) | ((((2) == (1)) && ((minisam::CalibKD::dim()) != (1))) ? ((Eigen::StorageOptions)1) : ((((minisam::CalibKD::dim()) == (1)) && ((2) != (1))) ? ((Eigen::StorageOptions)0) : ((Eigen::StorageOptions)0))), 2, minisam::CalibKD::dim()>&, Eigen::Matrix<double, 2, 3, 0, 2, 3>&) in testprojection.cpp.o
  "minisam::transform2worldJacobians(Sophus::SE3<double, 0> const&, Eigen::Matrix<double, 3, 1, 0, 3, 1> const&, Eigen::Matrix<double, 3, 6, 0, 3, 6>&, Eigen::Matrix<double, 3, 3, 0, 3, 3>&)", referenced from:
      ____C_A_T_C_H____T_E_S_T____2() in testprojection.cpp.o
  "minisam::transform2sensorJacobians(Sophus::SE3<double, 0> const&, Eigen::Matrix<double, 3, 1, 0, 3, 1> const&, Eigen::Matrix<double, 3, 6, 0, 3, 6>&, Eigen::Matrix<double, 3, 3, 0, 3, 3>&)", referenced from:
      ____C_A_T_C_H____T_E_S_T____0() in testprojection.cpp.o
  "std::__1::locale fmt::v9::detail::locale_ref::get<std::__1::locale>() const", referenced from:
      void fmt::v9::detail::format_value<char, Eigen::Transpose<Eigen::Matrix<double, 4, 1, 0, 4, 1> > >(fmt::v9::detail::buffer<char>&, Eigen::Transpose<Eigen::Matrix<double, 4, 1, 0, 4, 1> > const&, fmt::v9::detail::locale_ref) in testprojection.cpp.o
      void fmt::v9::detail::format_value<char, Eigen::Transpose<Eigen::Matrix<double, 3, 1, 0, 3, 1> const> >(fmt::v9::detail::buffer<char>&, Eigen::Transpose<Eigen::Matrix<double, 3, 1, 0, 3, 1> const> const&, fmt::v9::detail::locale_ref) in testprojection.cpp.o
      void fmt::v9::detail::format_value<char, double>(fmt::v9::detail::buffer<char>&, double const&, fmt::v9::detail::locale_ref) in testprojection.cpp.o
  "minisam::CalibK::projectJacobians(Eigen::Matrix<double, 2, 1, 0, 2, 1> const&, Eigen::Matrix<double, 2, 4, 0, 2, 4>&, Eigen::Matrix<double, 2, 2, 0, 2, 2>&) const", referenced from:
      void minisam::projectJacobians<minisam::CalibK>(Sophus::SE3<double, 0> const&, minisam::CalibK const&, Eigen::Matrix<double, 3, 1, 0, 3, 1> const&, Eigen::Matrix<double, 2, 6, 0, 2, 6>&, Eigen::Matrix<double, 2, minisam::CalibK::dim(), ((Eigen::StorageOptions)0) | ((((2) == (1)) && ((minisam::CalibK::dim()) != (1))) ? ((Eigen::StorageOptions)1) : ((((minisam::CalibK::dim()) == (1)) && ((2) != (1))) ? ((Eigen::StorageOptions)0) : ((Eigen::StorageOptions)0))), 2, minisam::CalibK::dim()>&, Eigen::Matrix<double, 2, 3, 0, 2, 3>&) in testprojection.cpp.o
  "minisam::CalibKD::projectJacobians(Eigen::Matrix<double, 2, 1, 0, 2, 1> const&, Eigen::Matrix<double, 2, 8, 0, 2, 8>&, Eigen::Matrix<double, 2, 2, 0, 2, 2>&) const", referenced from:
      void minisam::projectJacobians<minisam::CalibKD>(Sophus::SE3<double, 0> const&, minisam::CalibKD const&, Eigen::Matrix<double, 3, 1, 0, 3, 1> const&, Eigen::Matrix<double, 2, 6, 0, 2, 6>&, Eigen::Matrix<double, 2, minisam::CalibKD::dim(), ((Eigen::StorageOptions)0) | ((((2) == (1)) && ((minisam::CalibKD::dim()) != (1))) ? ((Eigen::StorageOptions)1) : ((((minisam::CalibKD::dim()) == (1)) && ((2) != (1))) ? ((Eigen::StorageOptions)0) : ((Eigen::StorageOptions)0))), 2, minisam::CalibKD::dim()>&, Eigen::Matrix<double, 2, 3, 0, 2, 3>&) in testprojection.cpp.o
  "minisam::CalibKD::project(Eigen::Matrix<double, 2, 1, 0, 2, 1> const&) const", referenced from:
      Eigen::Matrix<double, 2, 1, 0, 2, 1> minisam::project<minisam::CalibKD>(Sophus::SE3<double, 0> const&, minisam::CalibKD const&, Eigen::Matrix<double, 3, 1, 0, 3, 1> const&) in testprojection.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [tests/testprojection] Error 1
make[2]: *** [tests/CMakeFiles/testprojection.dir/all] Error 2
make[1]: *** [tests/CMakeFiles/check.dir/rule] Error 2
make: *** [check] Error 2

Exception while adding Key Val to Variable

Hi,

I am trying with the Bundle Adjustment example using bundle_adjustment_bal.cpp but I am facing issue when adding Key Value to variable on line number 60. The error is

image

Can you please help me out to get rid of the issue?

Empty python package after compilation

Hello,
I am compiling minisam with python3.7 and fullfill all the relevant dependencies. All tests are passed after compilation and I can import the package in Python.

However, when importing the python package, it is empty.

Therefore I can't run the python examples because all relevant functions are missing. What am I doing wrong?

testFactorGraph is Failed

Hi,
After installation, I run make check, everything is okey, but testFactorGraph is failed.

`

test cases: 9 | 8 passed | 1 failed
assertions: 29 | 23 passed | 6 failed

  Start  9: testLevenbergMarquardt

9/22 Test #9: testLevenbergMarquardt ........... Passed 0.01 sec
Start 10: testMarginalCovariance
10/22 Test #10: testMarginalCovariance ........... Passed 0.01 sec
Start 11: testNumericalJacobian
11/22 Test #11: testNumericalJacobian ............ Passed 0.01 sec
Start 12: testOrdering
12/22 Test #12: testOrdering ..................... Passed 0.01 sec
Start 13: testSPQR
13/22 Test #13: testSPQR ......................... Passed 0.01 sec
Start 14: testScalar
14/22 Test #14: testScalar ....................... Passed 0.00 sec
Start 15: testSchurComplement
15/22 Test #15: testSchurComplement .............. Passed 0.00 sec
Start 16: testSchurComplementDenseSolver
16/22 Test #16: testSchurComplementDenseSolver ... Passed 0.00 sec
Start 17: testSophus
17/22 Test #17: testSophus ....................... Passed 0.00 sec
Start 18: testSparseCholesky
18/22 Test #18: testSparseCholesky ............... Passed 0.00 sec
Start 19: testSquareRootCholesky
19/22 Test #19: testSquareRootCholesky ........... Passed 0.00 sec
Start 20: testVariables
20/22 Test #20: testVariables .................... Passed 0.00 sec
Start 21: testlinearization
21/22 Test #21: testlinearization ................ Passed 0.00 sec
Start 22: testprojection
22/22 Test #22: testprojection ................... Passed 0.00 sec

95% tests passed, 1 tests failed out of 22

Total Test time (real) = 0.15 sec

The following tests FAILED:
8 - testFactorGraph (Failed)
Errors while running CTest
make[3]: *** [tests/CMakeFiles/check.dir/build.make:78: tests/CMakeFiles/check] Error 8
make[2]: *** [CMakeFiles/Makefile2:478: tests/CMakeFiles/check.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:485: tests/CMakeFiles/check.dir/rule] Error 2
make: *** [Makefile:279: check] Error 2

`
Ubuntu 20.04, python3.8.10

Error building python wrapper

Hi. Trying to build miniSAM on Ubuntu 18.04 with python 3.6, gcc 7.4. Sophus was installed from apt
Unfortunately I've got an error during compilation:

/home/mika/Coding/minisam/python/sophus_wrapper/sophus.cpp: In function ‘void pybind11_init__minisam_sophus_py_wrapper(pybind11::module&)’: /home/mika/Coding/minisam/python/sophus_wrapper/sophus.cpp:86:61: error: address of overloaded function with no contextual type information .def_static("trans", (SE2d (*)(const Eigen::Vector2d&)) &SE2d::trans) \ ^~~~~ /home/mika/Coding/minisam/python/sophus_wrapper/sophus.cpp:124:61: error: address of overloaded function with no contextual type information .def_static("trans", (SE3d (*)(const Eigen::Vector3d&)) &SE3d::trans) \

cmake output:

-- Search Dependency: Eigen3
-- Search Dependency: Sophus
-- Search Dependency: Cholmod
-- Search Dependency: SPQR
-- Search Dependency: CUDA
-- Search Dependency: OpenMP
-- Found OpenMP_CXX: -fopenmp
-- Found OpenMP: TRUE
-- CUDA and OpenMP found (with GCC): use cuSOLVER
-- Build module: core
-- Build module: linear
-- Build module: nonlinear
-- Build module: utils
-- Build module: geometry
-- Build module: slam
-- Build module: linear/cuda
-- Build module: linear/cholmod
-- Build module: linear/spqr
-- Library: build shared library
-- Install 3rd-party module: eigen3
-- Add all unit tests, exclude:
-- Add all C++ examples, exclude:
-- git submodule update: pybind11
-- Found PythonInterp: /home/mika/.virtualenvs/p3/bin/python (found version "3.6.8")
-- Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython3.6m.so
-- Performing Test HAS_CPP14_FLAG
-- Performing Test HAS_CPP14_FLAG - Success
-- pybind11 v2.3.dev1
-- ===============================================================
-- Configurations for miniSAM

-- Library type Shared
-- Install path /usr/local

-- Compiler type GNU
-- Compiler version 7.4.0
-- Built type Release
-- C++ compilation flags -std=c++11 -Wall -Werror -Wextra -fopenmp -O3 -DNDEBUG

-- Multi-threading No
-- Internal profiling No

-- Eigen 3.3.4 (/usr/include/eigen3)
-- Sophus Yes (/opt/ros/melodic/share/sophus/cmake)
-- Cholmod Yes (/usr/include/suitesparse)
-- SPQR Yes (/usr/include/suitesparse)
-- CUDA cuSOLVER 10.1 (/usr/local/cuda-10.1/include)

-- Python package Yes
-- Python version 3.6
-- Python executable /home/mika/.virtualenvs/p3/bin/python

-- Configuring done
-- Generating done
-- Build files have been written to: /home/mika/Coding/minisam/build

Sophus version

Hello, first, a great package!
Actually, I have some doubts about the version of Sophus. It seems that the current implementation the template version of Sophus is used. However, from the user side, I believe some may install the older version without template. Would it be better for including it as a sub-module or name the specific version in the doc? : )

SE3 Example

Hi,

Thank you for your work.

I'm trying to use this package for 3D pose graph optimization in Python. However it is unclear to me how to add nodes and variables of type SE3.

There is no official SE3 example, but I tried using a 4x4 numpy array for this,graph.add(sam.PriorFactor(sam.key('x',0), sam.SE3(np.eye(4)))), the same way it's been used in the PyICP-SLAM example.

But I get the following incompatibility error,

TypeError: PriorFactor(): incompatible function arguments. The following argument types are supported:
    1. (arg0: int, arg1: Sophus::SE2<double, 0>, arg2: minisam._minisam_py_wrapper.LossFunction) -> minisam._minisam_py_wrapper.PriorFac
tor_SE2_
    2. (arg0: int, arg1: Sophus::SE3<double, 0>, arg2: minisam._minisam_py_wrapper.LossFunction) -> minisam._minisam_py_wrapper.PriorFac
tor_SE3_
    3. (arg0: int, arg1: Sophus::SO2<double, 0>, arg2: minisam._minisam_py_wrapper.LossFunction) -> minisam._minisam_py_wrapper.PriorFac
tor_SO2_
    4. (arg0: int, arg1: Sophus::SO3<double, 0>, arg2: minisam._minisam_py_wrapper.LossFunction) -> minisam._minisam_py_wrapper.PriorFac
tor_SO3_
    5. (arg0: int, arg1: minisam._minisam_py_wrapper.CalibK, arg2: minisam._minisam_py_wrapper.LossFunction) -> minisam._minisam_py_wrap
per.PriorFactor_CalibK_
    6. (arg0: int, arg1: minisam._minisam_py_wrapper.CalibKD, arg2: minisam._minisam_py_wrapper.LossFunction) -> minisam._minisam_py_wra
pper.PriorFactor_CalibKD_
    7. (arg0: int, arg1: minisam._minisam_py_wrapper.CalibBundler, arg2: minisam._minisam_py_wrapper.LossFunction) -> minisam._minisam_p
y_wrapper.PriorFactor_CalibBundler_
    8. (arg0: int, arg1: float, arg2: minisam._minisam_py_wrapper.LossFunction) -> minisam._minisam_py_wrapper.PriorFactor_double_
    9. (arg0: int, arg1: numpy.ndarray[float64[2, 1]], arg2: minisam._minisam_py_wrapper.LossFunction) -> minisam._minisam_py_wrapper.Pr
iorFactor_Vector2_
    10. (arg0: int, arg1: numpy.ndarray[float64[3, 1]], arg2: minisam._minisam_py_wrapper.LossFunction) -> minisam._minisam_py_wrapper.P
riorFactor_Vector3_
    11. (arg0: int, arg1: numpy.ndarray[float64[4, 1]], arg2: minisam._minisam_py_wrapper.LossFunction) -> minisam._minisam_py_wrapper.P
riorFactor_Vector4_
    12. (arg0: int, arg1: numpy.ndarray[float64[m, 1]], arg2: minisam._minisam_py_wrapper.LossFunction) -> minisam._minisam_py_wrapper.P
riorFactor_Vector_
    13. (arg0: int, arg1: object, arg2: minisam._minisam_py_wrapper.LossFunction) -> minisam._minisam_py_wrapper.PriorFactor_pyobject_

Invoked with: 8646911284551352320, array([[1., 0., 0., 0.],

I'm also unable to make out the right convention from the Sophus wrapper code.

Custom binary factors

Hi, first of all many thanks for the great job. I did follow qour tutorial and made a simple test with a custom unary factor and everything was fine. So I would like to define a dual factor (like a custom bearing / range factor).
Is it possible directly from python? If yes could you give me some hints?

Kindest regards,
Thomas

Optimization Failed when simultaneously use NumericFactor and Multi Thread

Hi,

First thanks for your great work, it is clean and well designed.

I think NumericFactor is really very useful for prototyping and I use it for my prototype and save a lot of time.

Surely, Accerating a prototyping feature is not that important, and prototyping is always not expected for too high performance.

I derive the analytical jacobians later when I finish prototyping. I just came across this issue just by curiousity.

I find optimization failed when simultaneously use NumericFactor and Multi Thread.

My sample code is like under: It is the sample code in the project and I just change the Factor to Numeric Factor and comment jacobians.

#/usr/lib/env python
"""
Robust curve fitting example
In this example we fit a curve defined by
    y = exp(m * x + c)
The error function is
    \sum_i f(|y_i - exp(m * x_i + c)|^2)
The loss function f can be either identity or robust Cauchy loss function
"""

from __future__ import print_function
from minisam import *
import numpy as np
import math

import time

import matplotlib.pyplot as plt

# ################################## factor ####################################
# exp curve fitting factor
class ExpCurveFittingFactor(NumericalFactor):
    # constructor
    def __init__(self, key, point, loss):
        NumericalFactor.__init__(self, 1, [key], loss)
        self.p_ = point

    # make a deep copy
    def copy(self):
        return ExpCurveFittingFactor(self.keys()[0], self.p_, self.lossFunction())

    # error = y - exp(m * x + c);
    def error(self, variables):
        # p = [m c]
        p = self.keys()[0]
        params = variables.at(p)
        return np.array([self.p_[1] - math.exp(params[0] * self.p_[0] + params[1])])

    # jacobians
    # def jacobians(self, variables):
    #     # p = [m c]
    #     p = self.keys()[0]
    #     params = variables.at(p)
    #     J_e_mc = np.array([[-self.p_[0] * math.exp(params[0] * self.p_[0] + params[1]),
    #                         -math.exp(params[0] * self.p_[0] + params[1])]])
    #     return [J_e_mc]


# ########################## plot and loading utils ############################
# load x-y value pairs
def loadFromFile(filename):
    data = []
    f = open(filename, "r")
    for line in f:
        arr = [float(num) for num in line.split(' ')]
        data.append(np.array(arr))
    return data

# plot raw x-y points
def plotPoints(data, color, r=10):
    xs, ys = [], []
    for d in data:
        xs.append(d[0])
        ys.append(d[1])
    plt.scatter(xs, ys, s=r, facecolors='none', edgecolors=color, marker='o')

# plot fitted exp curve
# y = exp(m * x + c);
def plotExpCurve(m, c, x_start, x_end, color, linewidth=1):
    x_step = 0.05
    xs, ys = [], []
    for x in np.arange(x_start, x_end, x_step):
        xs.append(x)
        ys.append(math.exp(m * x + c))
    plt.plot(xs, ys, color, linewidth)

def main():
    # Note
    # Refer to: [minisam document](https://minisam.readthedocs.io/install.html)
    # build graph
    # ################################# example ####################################
    # load data
    data = loadFromFile("../data/sync_data/exp_curve_fitting_data.txt")

    # use robust (Cauchy) loss function or not
    useRobustLoss = True
    if useRobustLoss:
        loss = CauchyLoss.Cauchy(1.0)
    else:
        loss = None

    # build graph
    graph = FactorGraph()
    for d in data:
        graph.add(ExpCurveFittingFactor(key('p', 0), d, loss))

    # init estimation of curve parameters
    init_values = Variables()
    init_values.add(key('p', 0), np.array([0, 0]))

    print("initial curve parameters :", init_values.at(key('p', 0)))

    # Use LM method optimizes the initial values
    opt_param = LevenbergMarquardtOptimizerParams()
    opt_param.verbosity_level = NonlinearOptimizerVerbosityLevel.ITERATION
    opt = LevenbergMarquardtOptimizer(opt_param)

    values = Variables()
    st = time.time()
    status = opt.optimize(graph, init_values, values)
    ed = time.time()
    print("[ Info] Time cost" , ed-st, " [s]")

    if status != NonlinearOptimizationStatus.SUCCESS:
        print("optimization error: ", status)

    print("opitmized curve parameters :", values.at(key('p', 0)))

    # plot
    fig, ax = plt.subplots()

    plotPoints(data, 'b')
    plotExpCurve(0.3, 0.1, data[0][0], data[-1][0], 'k')
    params_opt = values.at(key('p', 0))
    plotExpCurve(params_opt[0], params_opt[1], data[0][0], data[-1][0], 'r')

    ax.set_title('red is optimized and black is ground truth')
    plt.axis('equal')
    plt.show()

if __name__ == "__main__":
    main()

Optimized result:
image

get_target_property() called with non-existent target "Sophus::Sophus"

CMake Error at CMakeLists.txt:101 (get_target_property):
get_target_property() called with non-existent target "Sophus::Sophus".
#1

I have the same question, which version of sophus is necessary ? my sophus is a621ff2e56c56c839a6c40418d42c .

  1. when i do with readme, cmake with:

-- Search Dependency: Sophus
CMake Error at CMakeLists.txt:101 (get_target_property):
get_target_property() called with non-existent target "Sophus::Sophus".

  1. when i ignore the line of 101 in CMakeLists.txt.. camke with error

[ 43%] Building CXX object minisam/CMakeFiles/minisam.dir/geometry/projection.cpp.o
In file included from /home/yhzhao/test_git/minisam/minisam/geometry/projection.cpp:9:0:
/home/yhzhao/test_git/minisam/minisam/geometry/projection.h:13:26: fatal error: sophus/se3.hpp: No such file or directory
compilation terminated.

auto diff?

Does the library support auto-diff functions?

static assertion failed: error while running make check

Compiled all the dependent libraries successfully(Eigen3, Sophist, and fmt). SInce fmt library is optional, I included the line #define FMT_HEADER_ONLY in Sophus/common.hpp .
But, I'm still facing the following error while running make check
Screenshot from 2022-05-27 22-31-22

module 'minisam' has no attribute 'DiagonalLoss'

I am using PyICP github repo. I built the Sophus from this commit (commit a0fe89a323e20c42d3cecb590937eb7a06b8343a) Reference.
I am using Ubuntu 22 and used virtual environment (venv with python version 3.7.14) to build the PyICP repo, minisam and Sophus repo.

Finally when I run the command python3 main_icp_slam.py it runs in this error.

DiagonalLoss_no_attribute

I am not sure is it caused by Sophus, Eigen, Venv or minisam.

Let me know if anymore information is needed.

Thanks, for any and all the help.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.