Commit Graph

1069 Commits

Author SHA1 Message Date
Sameer Agarwal 2fd39fcecb FindWithDefault returns by value rather than reference.
Returning by reference leads to lifetime issues with the default
value which may go out of scope by the time it is used.

Thanks to @Ardavel for reporting this, as this causes graph_test
to fail on VS2015x64.

https://github.com/ceres-solver/ceres-solver/issues/216

Change-Id: I596481219cfbf7622d49a6511ea29193b82c8ba3
2016-09-01 16:05:06 -07:00
Mike Vitus 716f049a7b Convert pose graph 2D example to glog and gflags.
Change-Id: I0ed75a60718ef95199bb36f33d9eb99157d11d40
2016-08-31 13:55:58 -07:00
David Gossow 46c5ce89dd Fix compiler errors on some systems
This fixes some signed-unsigned comparisons and a missing header
include.

Change-Id: Ieb2bf6e905faa74851bc4ac4658d2f1da24b6ecc
2016-08-31 20:26:53 +00:00
David Gossow b102d53e1d Gradient checker multithreading bugfix.
This is a follow-up on c/7470. GradientCheckingCostFunction calls
callback_->SetGradientErrorDetected() in its Evaluate method,
which will run in multiple threads simultaneously when enabling
this option in the solver. Thus, the string append operation
inside that method has to be protected by a mutex.

Change-Id: I314ef1df2be52595370d9af05851bf6da39bb45e
2016-08-31 20:25:44 +00:00
Sameer Agarwal 79a28d1e49 Rename a confusingly named member of Solver::Options
Solver::Options::numeric_derivative_relative_step_size to
Solver::Options::gradient_check_numeric_derivative_relative_step_size

Change-Id: Ib89ae3f87e588d4aba2a75361770d2cec26f07aa
2016-08-31 07:47:29 -07:00
Sameer Agarwal 358ae741c8 Note that Problem::Evaluate cannot be called from an IterationCallback
Change-Id: Ieabdc2d40715e6b547ab22156ba32e9c8444b7ed
2016-08-31 07:42:00 -07:00
Sameer Agarwal 44044e25b1 Update the NumTraits for Jets
1. Use AVX if EIGEN_VECTORIZE_AVX is defined.
2. Make the cost of division same as the cost of multiplication.

These are updates to the original numtraits update needed for eigen 3.3
that Shaheen Gandhi sent out.

Change-Id: Ic1e3ed7d05a659c7badc79a894679b2dd61c51b9
2016-08-31 06:19:08 -07:00
Sameer Agarwal 4b6ad5d88e Use ProductParameterization in bundle_adjuster.cc
Previously, when using a quaternion to parameterize the camera
orientation, the camera parameter block was split into two
parameter blocks. One for the rotation and another for the
translation and intrinsics. This was to enable the use of the
Quaternion parameterization.

Now that we have a ProductParameterization which allows us
to compose multiple parameterizations, this is no longer needed
and we use a size 10 parameter block instead.

This leads to a more than 2x improvements in the linear solver time.

Change-Id: I78b8f06696f81fee54cfe1a4ae193ee8a5f8e920
2016-08-31 05:46:44 -07:00
Shaheen Gandhi bfc916cf1c Allow ceres to be used with the latest version of Eigen
Change-Id: Ief3b0f6b405484ec04ecd9ab6a1e1e5409a594c2
2016-08-31 12:45:47 +00:00
Alex Stewart edbd48ab50 Enable support for OpenMP in Clang if detected.
- Previously we disabled OpenMP if Clang was detected, as it did not
  support it.  However as of Clang 3.8 (and potentially Xcode 8) OpenMP
  is supported.

Change-Id: Ia39dac9fe746f1fc6310e08553f85f3c37349707
2016-08-31 08:25:11 +00:00
Mike Vitus f6df6c05dd Add an example for modeling and solving a 3D pose graph SLAM problem.
Change-Id: I750ca5f20c495edfee5f60ffedccc5bd8ba2bb37
2016-08-22 15:26:02 -07:00
David Gossow ac3b8e8217 Gradient checking cleanup and local parameterization bugfix
Change the Ceres gradient checking API to make is useful for
unit testing, clean up code duplication and fix interaction between
gradient checking and local parameterizations.

There were two gradient checking implementations, one being used
when using the check_gradients flag in the Solver, the other
being a standalone class. The standalone version was restricted
to cost functions with fixed parameter sizes at compile time, which
is being lifted here. This enables it to be used inside the
GradientCheckingCostFunction as well.

In addition, this installs new hooks in the Solver to ensure
that Solve will fail if any incorrect gradients are detected. This
way, you can set the check_gradient flags to true and detect
errors in an automated way, instead of just printing error information
to the log. The error log is now also returned in the Solver summary
instead of being printed directly. The user can then decide what to
do with it. The existing hooks for user callbacks are used for
this purpose to keep the internal API changes minimal and non-invasive.

The last and biggest change is the way the the interaction between
local parameterizations and the gradient checker works. Before,
local parameterizations would be ignored by the checker. However,
if a cost function does not compute its Jacobian along the null
space of the local parameterization, this wil not have any effect
on the solver, but would result in a gradient checker error.
With this change, the Jacobians are multiplied by the Jacobians
of the respective local parameterization and thus being compared
in the tangent space only.

The typical use case for this are quaternion parameters, where
a cost function will typically assume that the quaternion is
always normalized, skipping the correct computation of the Jacobian
along the normal to save computation cost.

Change-Id: I5e1bb97b8a899436cea25101efe5011b0bb13282
2016-08-18 06:18:43 +00:00
Mike Vitus d4264ec10d Add a quaternion local parameterization for Eigen's quaternion element convention.
Change-Id: I7046e8b24805313c5fb6a767de581d0054fcdb83
2016-08-17 18:28:54 -07:00
Mike Vitus fd7cab65ef Fix typos in the pose graph 2D example.
Change-Id: Ie024ff6b6cab9f2e8011d21121a91931bd987bd1
2016-08-10 09:37:47 -07:00
Mike Vitus 375dc34874 Remove duplicate entry for the NIST example in the docs.
Change-Id: Ic4e8f9b68b77b5235b5c96fe588cc56866dab759
2016-08-05 21:50:48 +00:00
Mike Vitus f554681bf2 Add an example for modeling and solving a 2D pose graph SLAM problem.
Change-Id: Ia89b12af7afa33e7b1b9a68d69cf2a0b53416737
2016-08-05 14:22:27 -07:00
Sameer Agarwal e1bcc6e0f5 Add additional logging for analyzing orderings
Change-Id: Ic68d2959db35254e2895f11294fb25de4d4b8a81
2016-08-02 10:12:04 -07:00
Mike Vitus 16980b4fec Delete the remove_definitons command from sampled_functions
CMakeLists.txt because it will be inherited from the top level examples
CMakeLists.txt.

Change-Id: I25593587df0ae84fd8ddddc589bc2a13f3777427
2016-07-15 13:44:56 -07:00
Mike Vitus a04490be97 Add readme for the sampled_function example.
Change-Id: I9468b6a7b9f2ffdd2bf9f0dd1f4e1d5f894e540c
2016-07-14 17:06:38 -07:00
Alex Stewart ff11d0e63d Use _j[0,1,n]() Bessel functions on MSVC to avoid deprecation errors.
- Microsoft deprecated the POSIX Bessel functions: j[0,1,n]() in favour
  of _j[0,1,n](), it appears since at least MSVC 2005:
  https://msdn.microsoft.com/en-us/library/ms235384(v=vs.100).aspx.
- As this occurs in jet.h (templated public header), although Ceres
  suppresses the warning when it itself is built (to suppress a warning
  about the insecurity of using std::copy), it will crop up again in
  client code (without this fix) unless it is explicitly suppressed
  there also.
- Raised as Issue #190:
  https://github.com/ceres-solver/ceres-solver/issues/190.

Change-Id: If7ac5dbb856748f9900be93ec0452a40c0b00524
2016-06-29 09:33:45 +01:00
Nicolai Wojke 8ea86e1614 Fix: Copy minimizer option 'is_silent' to LinSearchDirection::Options
Change-Id: I23b4c3383cad30033c539ac93883d77c8dd4ba1a
2016-04-25 14:24:41 +02:00
Sameer Agarwal 080ca4c5f2 Fix typos in users.rst
Change-Id: Ifdc67638a39403354bc9589f42a1b42cb9984dd2
2016-04-24 22:46:54 -07:00
Sameer Agarwal 21ab397dc5 Make some Jet comparisons exact.
Change-Id: Ia08c72f3b8779df96f5c0d5a954b2c0a1dd3a061
2016-04-24 21:13:00 -07:00
Sameer Agarwal ee40f954cf Add colmap to users.rst
Change-Id: I452a8c1dc6a3bc55734b2fc3a4002ff7939ba863
2016-04-24 07:56:12 -07:00
Sameer Agarwal 9665e09902 Fix step norm evaluation in LineSearchMinimizer
TrustRegionMinimizer evaluates the size of the step
taken in the ambient space, where as the LineSearchMinimizer
was using the norm in the tangent space. This change fixes
this discrepancy.

Change-Id: I9fef64cbb5622c9769c0413003cfb1dc6e89cfa3
2016-04-19 00:08:06 +00:00
Alex Stewart 620ca9d066 Remove use of -Werror when compiling Ceres.
- As noted in Issue #193 (in that case for GCC 6), Ceres' use of -Werror
  when compiling on *nix can prevent compilation on new compilers that
  add new warnings and there is an inevitable delay between new compiler
  versions and Ceres versions.
- Removing the explicit use of -Werror, and relying on indirect
  verification by maintainers should fix build issues for Ceres releases
  on newer compilers.

Change-Id: I38e9ade28d4a90e53dcd918a7d470f1a1debd7b4
2016-04-18 15:14:11 +01:00
Mike Vitus 0c63bd3efb Add floor and ceil functions to the Jet implementation.
Change-Id: I72ebfb0e9ade2964dbf3a014225ead345d5ae352
2016-04-15 10:47:22 -07:00
Alex Stewart 9843f32803 Report Ceres compile options as components in find_package().
- Users can now specify particular components from Ceres, such as
  SuiteSparse support) that must be present in a detected version of
  Ceres in order for it to be reported as found by find_package().
- This allows users to specify for example that they require a version
  of Ceres with SuiteSparse support at configure time, rather than
  finding out only at run time that Ceres was not compiled with the
  options they require.
- The list of available components are built directly from the Ceres
  compile options.
- The meta-module SparseLinearAlgebraLibrary is present if at least
  one sparse linear algebra backend is available.

Change-Id: I65f1ddfd7697e6dd25bb4ac7e54f5097d3ca6266
2016-04-10 17:27:26 +00:00
Timer e4d4d88bbe Fix a spelling error in nnls_modeling.rst
Change-Id: I341d901d3df993bc5397ed15e6cb330b0c38fd72
2016-04-08 15:50:52 +08:00
Keir Mierle 5512f58536 Only use collapse() directive with OpenMP 3.0 or higher
Change-Id: Icba544c0494763c57eb6dc61e98379312ca15972
2016-04-07 12:03:16 -07:00
Thomas Schneider d61e94da52 Add IsParameterBlockConstant to the ceres::Problem class.
Change-Id: I7d0e828e81324443209c17fa54dd1d37605e5bfe
2016-04-06 23:52:18 +02:00
Alex Stewart 77d94b3474 Fix install path for CeresConfig.cmake to be architecture-aware.
- Previously we were auto-detecting a "64" suffix for the install path
  for the Ceres library on non-Debian/Arch Linux distributions, but
  we were installing CeresConfig.cmake to an architecture independent
  location.
- We now install CeresConfig.cmake to lib${LIB_SUFFIX}/cmake/Ceres.
- Also make LIB_SUFFIX visible to the user in the CMake GUI s/t they can
  easily override the auto-detected value if desired.
- Reported by jpgr87@gmail.com as Issue #194.

Change-Id: If126260d7af685779487c01220ae178ac31f7aea
2016-03-16 21:20:31 +00:00
Keir Mierle f4ba28d09d Fix double conversion to degrees in rotation_test
Change-Id: I16b6d210cdab94340c001b322916c5b1a3b6a35f
2016-03-16 11:38:05 -07:00
Keir Mierle efe61b089b Make Jet string output more readable
Change-Id: Iebab111ab136c52f88180688ccb684584ab21dea
2016-03-16 11:27:25 -07:00
Keir Mierle 0149ce0e0e Fix rotation_test IsClose() and related tests
Change-Id: I0ff91e2931615babf1dcc9483fac7f4a2fb13726
2016-03-16 11:09:53 -07:00
Sameer Agarwal 0178c7a3e3 Update title in README.md
Change-Id: Iafd66125d9c54a35947a0b4a5eb49bd0e0df00be
2016-03-07 09:33:07 -08:00
Sameer Agarwal d431475437 Update README.md
The README.md was woefully out of date, as it was advertising
Ceres Solver as just a non-linear least squares library.

Change-Id: I9a58fb8b63c08ee3852ffbae955e2ca8c90cd6d9
2016-03-07 09:25:44 -08:00
Sameer Agarwal 2c178ec35f Add more documentation.
Add documentation to the TrustRegionMinimizer and
TrustRegionStepEvaluator.

Change-Id: I3651e41ff37955a0b7044910403630af1a855071
2016-03-06 21:13:42 -08:00
Sameer Agarwal 2ee3e06064 Loosen an exact equality in local_parameterization_test
The norm comparison in QuaternionParameterizationHelper is exact
but that leads to numerical precision problems and test failures
as reported by Nicu Stiurca.

https://github.com/ceres-solver/ceres-solver/issues/198

Change-Id: I45f42f0373770408ddeee0b4c9d162e619f8d445
2016-03-04 22:12:18 -08:00
Niels Ole Salscheider 2ad14b7a61 make_docs: Pass the file encoding to open()
Otherwise, it will fail on Python 3 with:
"UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position
7690: ordinal not in range(128)"

We have to use io.open() instead of open(), because open() does not
accept the encoding on Python 2.

Change-Id: I77b6552491e8de01d79a26d2f146ddbd968cce49
2016-03-02 22:09:24 +01:00
Simon Rutishauser 7d670209a2 Fix error message returned when using SUITE_SPARSE_QR in covariance estimation
on a ceres built without SuiteSparse support.

This is only a minor issue, up until now this case would have been handled by
the "default" case of the switch

Change-Id: Ib4568eb827dbf0e8e8d618a5bc8cd379a3c42c42
2016-02-16 11:53:45 +01:00
Alex Stewart eaa58c5d6e Fix CXX11 option to be available on MinGW & CygWin, but not MSVC.
- Previously we were disabling the CXX11 option when WIN32 was defined,
  which it can be on both MinGW & CygWin, even though the compilers
  there can support the -std=c++11 option.
- Now we disable the CXX11 option only when the compiler used is MSVC.

Change-Id: I68ebcf0a4241afe93892a3c6f79cdd98887e785a
2016-02-07 13:50:48 +00:00
Alex Stewart 562a72ea2b Fix missing early return() in xxx_not_found() dependency macros.
- This could result in potentially confusing output if dependencies
  were found with the QUIET option: "XXX not found due to ...", followed
  by "found <part of> XXX".
- If find_package() was called with REQUIRED, then a FATAL_ERROR was
  triggered in the xxx_not_found() macros, resulting in early
  termination.

Change-Id: Ibf59afd10067b9debd1a5e15f735a41b61bed52e
2016-02-06 15:58:10 +00:00
Sameer Agarwal 982327062e Initialize inner_iterations_were_useful_ correctly.
This variable should be initialized before the decision to
perform inner iterations are performed.

Change-Id: Ic80e2d5284ecc67eaed1859be009b1a4d18bf76b
2016-02-04 11:50:20 -08:00
Sameer Agarwal 8861522fc5 Add trust_region_step_evaluator.cc to Application.mk
Change-Id: I841d889b96cc538ad9e87691a3be31ae71e3ff33
2016-02-04 18:13:23 +00:00
Sameer Agarwal 46ad4699f4 A complete refactoring of TrustRegionMinimizer.
1. Break up the monolithic loop in TrustRegionMinimizer::Minimize
   into a number of more easily described and analyzed subfunctions.
2. Break out the logic for evaluating the quality of a Trust Region
   step into its own object - TrustRegionStepEvaluator.

Change-Id: I08580ecac074cfd74c096cb8e4880cbda3d48296
2016-02-04 10:05:12 -08:00
Sameer Agarwal dec43ae5e0 Add an implementation for GradientProblemSolver::Options::IsValid
Thanks for Francesco Callari for reporting this.

Change-Id: I2b2f4e0e098fbdc914dc7770db1164884ac50e24
2016-02-03 07:24:05 -08:00
Alex Stewart 706a876541 Fix use of va_copy() if compiling with explicit C++ version < C++11.
- va_copy() was defined in the C99 standard, but did not appear in the
  C++ standard until C++11.  If the C++ standard is not specified,
  both GCC & Clang will define va_copy(), even though strictly speaking
  they should not.  However, if the C++ standard is explicitly specified
  to something < C++11 (e.g. -std=c++03) then va_copy() will NOT be
  defined.
- Now, if va_copy() is not defined, we either define our own version
  on non GCC/Clang compilers (as before for MSVC alone), and use the
  internal __va_copy() version on GCC & Clang, which does exist.

Change-Id: I0224f7fa6aae060dee2287782b1cad767c244d3c
2016-01-21 19:30:58 +00:00
Niels Ole Salscheider cb467d83fe Install CMake files to lib/cmake/Ceres
This is the right thing to do since the CMake files contain target
specific information - share is only for target-independent files.
Without this patch, the CMake files will collide on distributions
that allow to install for multiple targets in parallel (e. g. on
Exherbo).

Change-Id: Iac17af63b9f9b25d0ca400c77c2b2e0e8a51196f
2016-01-10 20:39:20 +01:00
Niels Ole Salscheider 1f20b72afd Allow users to override the documentation install directory.
This is needed for multiarch layouts where the prefix is /usr/${host}
but where arch-independent files are installed to /usr/share.

Change-Id: Icec01f8ea927594b4edb26997d6384e478415999
2016-01-10 20:39:12 +01:00