Commit Graph

1107 Commits

Author SHA1 Message Date
Alex Stewart 8a2da98ac2 Clear XXX_FOUND in Find<XXX>.cmake prior to searching.
- This protects against a client project which invokes
  find_package(Ceres) after having called find_package(Foo) with their
  own version of FindFoo.cmake which conflicts with Ceres’ exported
  version and defines FOO_FOUND, but not the other variables Ceres’
  FindFoo.cmake is expecting which can break the detection logic.

Change-Id: I9fe7bfa8a34bb58b09ffe34446da973912cf5587
2016-12-01 18:20:11 +00:00
Sameer Agarwal d1e954d246 Minor changes to the documentation.
1. Section title changes.
2. Moving the glog discussion into installation.rst
3. Re-working the faqs into two separate chapters.

Change-Id: I95dd25bace50f0f9077ef114504999190686963e
2016-11-27 15:12:11 -08:00
Sameer Agarwal 0aa945cf48 Fix versioning in the documentation
Change-Id: I0b8b599972cc32839b6aefe6b9e96861cfd522f8
2016-11-24 21:21:36 -08:00
Sameer Agarwal 7cb5d9cca3 Update changelog
Change-Id: Ib284990fd819c71411617c3d995178181af9fc4d
1.12.0rc4
2016-11-21 06:24:28 -08:00
Alex Stewart 523e397be2 Fix missing gflags imported target definition in CeresConfig.cmake
- If gflags was built & exported with CMake but glog was not, but both
  were found then as we now make gflags a public dependency of Ceres if
  both it and glog are found, the *name* of the exported gflags CMake
  target (gflags-shared or similar) will appear in CERES_LIBRARIES.
- However, as imported targets are not re-exported, this results in a
  linker error when compiling client code, as the name of the exported
  gflags target is not known to CMake, it assumes it is a library name,
  which it is not.
- Confusingly, if glog was built with CMake, this problem would not
  occur, as in that case glog’s CMake target would bring in gflags’.
- Now we explicitly call find_package(Gflags) in CeresConfig.cmake if
  Ceres was built with gflags as a public dependency (via glog).

Change-Id: I5cc9483a1fae50f4e9e3a8fbba491b645fd45db6
2016-11-21 11:56:19 +00:00
Sameer Agarwal 0f80f018ff Update changelog
Change-Id: I36db7e705ad520321335ff2f438cba54d914bb5c
1.12.0rc3
2016-11-20 12:13:56 -08:00
Alex Stewart 29888185a1 Make gflags a public dependency of Ceres if it and glog are found.
- Previously we were not listing gflags as a public dependency of Ceres
  if it and glog were found (and MINIGLOG was not being used). This
  does not reflect that if glog was compiled with gflags then it will
  #include gflags/gflags.h in glog/logging.h, thus making gflags a
  public dependency of anything linking against glog.
- On *nix OSs if glog/gflags are shared libraries this did not result
  in a link error when compiling Ceres as the gflags symbols were
  indirectly resolved.  However, on MSVC this is not the case, and this
  could result in unresolved gflags symbol link errors when compiling
  Ceres.
- Now we add gflags to the list of public Ceres dependencies if both
  glog and gflags are found (and MINIGLOG is not enabled).

Change-Id: I5ce6038fa816781cc81b378522068dc563d29c51
2016-11-20 19:44:46 +00:00
Alex Stewart d38e49a6cc Add support for glog exported CMake target.
- The latest version of glog supports building with CMake, in which case
  it exports itself via CMake as a target that contains important meta
  information such as Windows-specific compilation definitions.
- This patch updates FindGlog.cmake such that it can optionally use
  an exported glog target if one exists, if not it will fall back to
  the current approach whereby the glog components are found manually.
  This behaviour (and the implementation) is very similar to that of
  FindGflags.cmake.

Change-Id: Idfb5f49c1b457707029bff52068f58237c0e285d
2016-11-20 19:29:16 +00:00
Alex Stewart 73341234cb Use google::GLOG_WARNING instead of WARNING in tests to support MSVC.
- GLOG_NO_ABBREVIATED_SEVERITIES is the default on Windows, in which
  case google::WARNING is not defined.
- Remove Ceres-specific redefinition of WARNING in mock-log.h fork
  in place of using non-abbreviated severity in the one place in
  levenberg_marquardt_strategy_test where ScopedMockLog is actually
  used.
- Remove unnecessary dependency of gradient_checking_cost_function_test
  on ScopedMockLog.

Change-Id: I9fb540f638037b6015fd264cfc618c9d60f5686c
2016-11-20 19:11:48 +00:00
Sameer Agarwal 185aacc71f Update gtest and gmock to a2b8a8e07628e5fd60644b6dd99c1b5e7d7f1f47
Change-Id: I1d7cfda65de173ceba156cf1f684f56f6c62840b
2016-11-20 10:57:24 -08:00
Alex Stewart 6879bbbf77 Add MSVC-specific #define to expose math constants in <cmath>.
- MSVC does not expose standard math constants, such as M_PI in <cmath>
  or <math.h> unless _USE_MATH_DEFINES is defined prior to their
  inclusion: https://msdn.microsoft.com/en-us/library/4hwaceh6.aspx.
- Use CMake to ensure that this is #defined when both Ceres and the
  examples are compiled, even though it should only be an issue for the
  examples where M_PI is used.

Change-Id: I67af75b100b8138a65514273d23bfe445d92652c
2016-11-13 18:09:39 +00:00
Hung Lun 1b1209824d Fix typo. indepdendent -> independent
Change-Id: I7f04f5e82a6e47e8d22c902744729f3f6d93dee8
2016-11-13 21:10:45 +08:00
Alex Stewart c5c6f559ab Fix potential invalid reset of CMAKE_FIND_LIBRARY_PREFIXES on MSVC.
- gflags_report_not_found() calls gflags_reset_find_library_prefix()
  and we only reset CMAKE_FIND_LIBRARY_PREFIXES when performing a manual
  search for gflags, but gflags_report_not_found() is also used
  before the manual search when searching for an exported gflags target.
- As such, it was possible that we could have cleared
  CMAKE_FIND_LIBRARY_PREFIXES rather than reset it if
  gflags_report_not_found() was invoked during the exported target
  search.
- This patch prevents this possibility by verifying that the cached
  version of CMAKE_FIND_LIBRARY_PREFIXES exists before updating it.

Change-Id: I07528ae5f197a366c7da342196b3e977f9a1fc93
2016-11-13 11:42:44 +00:00
Alex Stewart 6519e78920 Fix use of alignas(0) which is not ignored on GCC.
- alignas(0) should be ignored, however it results in a build error on
  GCC, so instead default to the alignment of double in Jets if
  we cannot align to 16-byte boundaries on the platform, but are
  compiling with C++11.

Change-Id: I2e54c69516ea2e1447a8bdc138b2dd70050c6dad
2016-11-12 21:45:57 +00:00
Alex Stewart b4e27240b2 Use default alignment if alignof(std::max_align_t) < 16 with C++11.
- As per Andrew Hunter’s comments in the commit which added Jet
  alignment when using C++11 here:
  https://ceres-solver-review.googlesource.com/#/c/7100, there is wide
  lattitude in the standard about what the maximum supported alignment
  can be.
- Previously, we were forcing the alignment to 1, if the value of
  alignof(std::max_align_t), which we use as a proxy for the maximum
  supported alignment on the platform, was < 16.
- An alignment of 1 is not valid for Jets, as it would weaken the
  natural alignment of the types within a Jet, which would typically be
  4 (32-bit systems) or 8 (64-bit systems), thus resulting in a compiler
  error.
- This was reported as issue 235 for Clang 3.8 on i386:
  https://github.com/ceres-solver/ceres-solver/issues/235.

Change-Id: Ie39e5499c64f9231f29ebf4392992b5c9ce2e385
2016-11-12 17:18:25 +00:00
Sameer Agarwal 717417512b Update changelog
Change-Id: I1c8bef059adc57476b5e75310fd7d983b8229bf7
1.12.0rc2
2016-11-11 10:48:51 -08:00
Sameer Agarwal 78abf0cdfe Introduce a common base class for DynamicAutoDiffCostFunction and DynamicNumericDiffCostFunction.
In the process also move some documentation from the file header to
just above the class declaration.

This change is in response to https://github.com/ceres-solver/ceres-solver/issues/233

Change-Id: I08cff1a94c57b67dd2bd8be4dba8c3fce46b68ab
2016-11-11 07:35:22 -08:00
Sameer Agarwal 88b827a0e7 Fix an exact equality test causing breakage in gradient_checker_test.
Also clang-format the file to fix some accumulated cruft.

Change-Id: Icf41e3f864a4fe925426477893602b50ff2131f4
2016-11-01 07:42:56 -07:00
Sameer Agarwal f21c17064b Add GradientProblemSolver::Options::parameter_tolerance.
Support for parameter tolerance was added to the line search
minimizer was added a while ago, and calling Solve on a
non-linear least squares problem supported it but for some reason
the GradientProblemSolver::Options struct was missing this
option even though the documentation suggested that it was present!

Thanks to Noah Snavely for reporting this bug.

Change-Id: I57cf4ab396bc822c19fa298529e113b89664a349
2016-11-01 12:56:19 +00:00
Rob Carroll e69bd2a206 Add missing T() wrappers for constants.
Needed for instantiation with Jet<float,N>.

Change-Id: I8ec07a844cc911a3c7f24c25797bd21c0bee07b5
2016-10-31 12:51:44 -07:00
Sameer Agarwal 8590e6e8e0 Remove two checks from rotation.h
This allows rotation.h to remove its dependency on glog.

Change-Id: Ia6aede93ee51a4bd4039570dc8edd100a7045329
2016-10-27 12:36:13 -07:00
Je Hyeong Hong e892499e8d Relax the tolerance in QuaternionParameterizationTestHelper.
This commit relaxes the tolerance value for comparing between the actual
local matrix and the expected local matrix. Without this fix,
EigenQuaternionParameterization.ZeroTest could fail as the difference
exactly matches the value of std::numeric_limits<double>::epsilon().

Change-Id: Ic4d3f26c0acdf5f16fead80dfdc53df9e7dabbf9
2016-10-20 00:16:18 +01:00
Sameer Agarwal 7ed9e2fb7f Occured -> Occurred.
Thanks to Phillip Huebner for reporting this.

Change-Id: I9cddfbb373aeb496961d08e434fe661bff4abd29
2016-10-19 04:45:23 -07:00
Je Hyeong Hong b82f972796 Fix a test error in autodiff_test.cc.
Previously, the test for the projective camera model would fail as no
tolerance is set in line 144. To resolve this, this commit changes
assert_equal to assert_near.

Change-Id: I6cd3379083b1a10c7cd0a9cc83fd6962bb993cc9
2016-10-18 21:49:26 +01:00
Sameer Agarwal 5690b447de Fix documentation source for templated functions in rotation.h
Change-Id: Ic1b2e6f0e6eb9914f419fd0bb5af77b66252e57c
1.12.0rc1
2016-10-13 09:52:02 -07:00
Sameer Agarwal 2f8f98f7e8 Prepare for 1.12.0RC1
Change-Id: I23eaf0b46117a01440143001b74dacfa5e57cbf0
2016-10-13 09:35:18 -07:00
Damon Kohler 55c12d2e95 Adds package.xml to support Catkin.
Change-Id: I8ad4d36a8b036417604a54644e0bb70dd1615feb
2016-10-11 06:32:26 +00:00
Sameer Agarwal 0bcce65652 Fix tabs in Android.mk
Change-Id: Ie5ab9a8ba2b727721565e1ded242609b6df5f8f5
2016-10-10 23:30:42 -07:00
Sameer Agarwal e6ffe26671 Update the version history.
Change-Id: I9a57b0541d6cebcb695ecb364a1d4ca04ea4e06c
2016-10-10 22:47:08 -07:00
David Gossow 0a4ccb7ee9 Relaxing Jacobian matching in Gradient Checker test.
Any result of an arithmetic operation on floating-point matrices
should never be checked for strict equality with some expected
value, due to limited floating point precision on different machines.
This fixes some occurences of exact checks in the gradient checker
unit test that were causing problems on some platforms.

Change-Id: I48e804c9c705dc485ce74ddfe51037d4957c8fcb
2016-10-10 14:40:14 +00:00
Je Hyeong Hong ee44fc91b5 Fix an Intel compiler error in covariance_impl.cc.
Intel C compiler strictly asks for parallel loops with collapse to be
perfectly nested. Otherwise, compiling Ceres with ICC will throw an
error at line 348 of covariance_impl.cc.

Change-Id: I1ecb68e89b7faf79e4153dfe6675c390d1780db4
2016-10-03 14:13:19 +01:00
Sameer Agarwal 9026d69d1c Allow SubsetParameterization to hold all parameters constant
1. SubsetParameterization can now be constructed such that all
parameters are constant. This is required for it be used as part
of a ProductParameterization to hold a part of parameter block
constant. For example, a parameter block consisting of a rotation
as a quaternion and a translation vector can now have a local
parameterization where the translation part is constant and the
quaternion part has a QuaternionParameterization associated with it.

2. The check for the tangent space of a parameterization being
positive dimensional. We were not doing this check up till now
and the user could accidentally create parameterizations like this
and create a problem for themselves. This will ensure that even
though one can construct a SubsetParameterization where all
parameters are constant, you cannot actually use it as a local
parameterization for an entire parameter block. Which is how
it was before, but the check was inside the SubsetParameterization
constructor.

3. Added more tests and refactored existing tests to be more
granular.

Change-Id: Ic0184a1f30e3bd8a416b02341781a9d98e855ff7
2016-09-22 20:33:53 -07:00
Sameer Agarwal a36693f83d Update version history
Change-Id: Ib2f0138ed7a1879ca3b2173e54092f7ae8dd5c9d
2016-09-17 16:31:41 -07:00
David Gossow 01e23e3d33 Removing duplicate include directive.
Change-Id: I729ae6501497746d1bb615cb893ad592e16ddf3f
2016-09-08 13:35:19 +00:00
Sameer Agarwal 99b8210cee Update Android.mk to include new files.
Change-Id: Id543ee7d2a65b65c868554a17f593c0a4958e873
2016-09-07 15:31:30 -07:00
Sameer Agarwal 195d8d13a6 Remove two DCHECKs from CubicHermiteSpline.
They were present as debugging checks but were causing problems
with the build on 32bit i386 due to numerical cancellation issues,
where x ~ -epsilon.

Removing these checks only changes the behaviour in Debug mode.
We are already handling such small negative numbers in production
if they occur. All that this change does is to remove the crash.

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

Thanks to @NeroBurner and @debalance for reporting this.

Change-Id: I66480e86d4fa0a4b621204f2ff44cc3ff8d01c04
2016-09-06 07:15:20 -07:00
Sameer Agarwal 83041ac84f Fix some compiler warnings.
Reported by Richard Trieu.

Change-Id: I202b7a7df09cc19c92582d276ccf171edf88a9fb
2016-09-02 19:10:35 -07:00
Sameer Agarwal 8c4623c63a Update ExpectArraysClose to use ExpectClose instead of EXPECT_NEAR
The documentation for ExpectArraysClose and its implementation
did not match.

This change makes the polynomial_test not fail on 64bit AMD builds.

Thanks to Phillip Huebner for reporting this.

Change-Id: I503f2d3317a28d5885a34f8bdbccd49d20ae9ba2
2016-09-03 02:01:10 +00:00
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