39 #ifndef INCLUDE_OKVIS_CERES_MAP_HPP_
40 #define INCLUDE_OKVIS_CERES_MAP_HPP_
44 #include <ceres/ceres.h>
51 #include <unordered_map>
86 : residualBlockId(residualBlockId),
87 lossFunctionPtr(lossFunctionPtr),
88 errorInterfacePtr(errorInterfacePtr) {
134 void getLhs(uint64_t parameterBlockId, Eigen::MatrixXd& H);
147 std::shared_ptr<okvis::ceres::ParameterBlock> parameterBlock,
148 int parameterization = Parameterization::Trivial,
const int group = -1);
163 std::shared_ptr<okvis::ceres::ParameterBlock> parameterBlock);
173 std::shared_ptr< ::ceres::CostFunction> cost_function,
174 ::ceres::LossFunction* loss_function,
175 std::vector<std::shared_ptr<okvis::ceres::ParameterBlock> >& parameterBlockPtrs);
183 ::ceres::ResidualBlockId residualBlockId,
184 std::vector<std::shared_ptr<okvis::ceres::ParameterBlock> >& parameterBlockPtrs);
203 std::shared_ptr< ::ceres::CostFunction> cost_function,
204 ::ceres::LossFunction* loss_function,
205 std::shared_ptr<okvis::ceres::ParameterBlock> x0,
206 std::shared_ptr<okvis::ceres::ParameterBlock> x1 = std::shared_ptr<
208 std::shared_ptr<okvis::ceres::ParameterBlock> x2 = std::shared_ptr<
210 std::shared_ptr<okvis::ceres::ParameterBlock> x3 = std::shared_ptr<
212 std::shared_ptr<okvis::ceres::ParameterBlock> x4 = std::shared_ptr<
214 std::shared_ptr<okvis::ceres::ParameterBlock> x5 = std::shared_ptr<
216 std::shared_ptr<okvis::ceres::ParameterBlock> x6 = std::shared_ptr<
218 std::shared_ptr<okvis::ceres::ParameterBlock> x7 = std::shared_ptr<
220 std::shared_ptr<okvis::ceres::ParameterBlock> x8 = std::shared_ptr<
222 std::shared_ptr<okvis::ceres::ParameterBlock> x9 = std::shared_ptr<
257 std::shared_ptr<okvis::ceres::ParameterBlock> parameterBlock) {
267 std::shared_ptr<okvis::ceres::ParameterBlock> parameterBlock) {
286 uint64_t parameterBlockId,
287 ::ceres::LocalParameterization* local_parameterization);
296 std::shared_ptr<okvis::ceres::ParameterBlock> parameterBlock,
297 ::ceres::LocalParameterization* local_parameterization) {
308 uint64_t parameterBlockId);
312 uint64_t parameterBlockId)
const;
316 ::ceres::ResidualBlockId residualBlockId);
320 ::ceres::ResidualBlockId residualBlockId)
const;
331 ::ceres::ResidualBlockId residualBlockId)
const;
344 double relTol = 1e-6)
const;
348 typedef std::unordered_map<uint64_t,
389 typedef std::unordered_map< ::ceres::ResidualBlockId,
std::pair< uint64_t, std::shared_ptr< okvis::ceres::ParameterBlock > > ParameterBlockSpec
Definition: Map.hpp:95
Header file for the HomogeneousPointLocalParameterization class.
void printParameterBlockInfo(uint64_t parameterBlockId) const
Log information on a parameter block.
Definition: Map.cpp:75
Header file for the ErrorInterface class. A simple interface class that other error classes should in...
const Id2ParameterBlock_Map & id2parameterBlockMap() const
Get map connecting parameter block IDs to parameter blocks.
Definition: Map.hpp:355
ResidualBlockSpec()
Definition: Map.hpp:73
::ceres::ResidualBlockId residualBlockId
ID of residual block.
Definition: Map.hpp:91
std::vector< ResidualBlockSpec > ResidualBlockCollection
Definition: Map.hpp:97
void getLhs(uint64_t parameterBlockId, Eigen::MatrixXd &H)
Obtain the Hessian block for a specific parameter block.
Definition: Map.cpp:101
std::shared_ptr< ErrorInterface > errorInterfacePtr
The pointer to the error interface of the respective residual block.
Definition: Map.hpp:93
ParameterBlockCollection parameters(::ceres::ResidualBlockId residualBlockId) const
Get the parameters of a residual block.
Definition: Map.cpp:706
bool parameterBlockExists(uint64_t parameterBlockId) const
Check whether a certain parameter block is part of the map.
Definition: Map.cpp:67
bool removeParameterBlock(uint64_t parameterBlockId)
Remove a parameter block from the map.
Definition: Map.cpp:366
ResidualBlockId2ParameterBlockCollection_Map residualBlockId2ParameterBlockCollection_Map_
Go from residual block id to its parameter blocks.
Definition: Map.hpp:402
ResidualBlockSpec(::ceres::ResidualBlockId residualBlockId,::ceres::LossFunction *lossFunctionPtr, std::shared_ptr< ErrorInterface > errorInterfacePtr)
Constructor.
Definition: Map.hpp:83
bool isJacobianCorrect(::ceres::ResidualBlockId residualBlockId, double relTol=1e-6) const
Check a Jacobian with numeric differences.
Definition: Map.cpp:159
uint64_t residualCounter_
count the inserted residual blocks.
Definition: Map.hpp:378
std::shared_ptr< ::ceres::Problem > problem_
The ceres problem.
Definition: Map.hpp:382
Header file for the PoseLocalParemerization class.
std::shared_ptr< okvis::ceres::ErrorInterface > errorInterfacePtr(::ceres::ResidualBlockId residualBlockId)
Get a shared pointer to an error term.
Definition: Map.cpp:684
Use okvis::ceres::PoseLocalParameterization.
Definition: Map.hpp:103
okvis::ceres::PoseLocalParameterization poseLocalParameterization_
Store parameterisation locally.
Definition: Map.hpp:408
Use okvis::ceres::PoseLocalParameterization3d (orientation varying).
Definition: Map.hpp:104
bool setParameterBlockConstant(std::shared_ptr< okvis::ceres::ParameterBlock > parameterBlock)
Do not optimise a certain parameter block.
Definition: Map.hpp:256
bool setParameterization(uint64_t parameterBlockId,::ceres::LocalParameterization *local_parameterization)
Set the (local) parameterisation of a parameter block.
Definition: Map.cpp:628
ResidualBlockId2ResidualBlockSpec_Map residualBlockId2ResidualBlockSpec_Map_
Go from residual ID to specs.
Definition: Map.hpp:396
bool setParameterBlockVariable(uint64_t parameterBlockId)
Optimise a certain parameter block (this is the default).
Definition: Map.cpp:579
::ceres::Solver::Summary summary
Ceres optimization summary.
Definition: Map.hpp:368
std::vector< ParameterBlockSpec > ParameterBlockCollection
Definition: Map.hpp:98
::ceres::Solver::Options options
Ceres options.
Definition: Map.hpp:365
bool addParameterBlock(std::shared_ptr< okvis::ceres::ParameterBlock > parameterBlock, int parameterization=Parameterization::Trivial, const int group=-1)
Add a parameter block to the map.
Definition: Map.cpp:292
Header file for the TimeBase, Time and WallTime class.
Pose local parameterisation, i.e. for orientation dq(dalpha) x q_bar. Here, we only perturb roll and ...
Definition: PoseLocalParameterization.hpp:255
Simple interface class the errors implemented here should inherit from.
Definition: ErrorInterface.hpp:53
okvis::ceres::HomogeneousPointLocalParameterization homogeneousPointLocalParameterization_
Store parameterisation locally.
Definition: Map.hpp:405
void solve()
Solve the optimization problem.
Definition: Map.hpp:371
::ceres::ResidualBlockId addResidualBlock(std::shared_ptr< ::ceres::CostFunction > cost_function,::ceres::LossFunction *loss_function, std::vector< std::shared_ptr< okvis::ceres::ParameterBlock > > ¶meterBlockPtrs)
Adds a residual block.
Definition: Map.cpp:388
bool setParameterBlockVariable(std::shared_ptr< okvis::ceres::ParameterBlock > parameterBlock)
Optimise a certain parameter block (this is the default).
Definition: Map.hpp:266
ResidualBlockCollection residuals(uint64_t parameterBlockId) const
Get the residual blocks of a parameter block.
Definition: Map.cpp:666
Local parameterisation of a homogeneous point [x,y,z,w]^T. We use a Euclidean-type perturbation...
Definition: HomogeneousPointLocalParameterization.hpp:53
Pose local parameterisation, i.e. for orientation dq(dalpha) x q_bar. Here, we only perturb the trans...
Definition: PoseLocalParameterization.hpp:194
#define OKVIS_DEFINE_EXCEPTION(exceptionName, exceptionParent)
Macro for defining an exception with a given parent.
Definition: assert_macros.hpp:52
bool resetParameterization(uint64_t parameterBlockId, int parameterization)
Reset the (local) parameterisation of a parameter block.
Definition: Map.cpp:590
void resetResidualBlock(::ceres::ResidualBlockId residualBlockId, std::vector< std::shared_ptr< okvis::ceres::ParameterBlock > > ¶meterBlockPtrs)
Replace the parameters connected to a residual block ID.
Definition: Map.cpp:488
okvis::ceres::PoseLocalParameterization4d poseLocalParameterization4d_
Store parameterisation locally.
Definition: Map.hpp:417
This file contains some useful assert macros.
okvis::ceres::PoseLocalParameterization3d poseLocalParameterization3d_
Store parameterisation locally.
Definition: Map.hpp:414
Parameterization
The Parameterisation enum.
Definition: Map.hpp:101
Id2ResidualBlock_Multimap id2ResidualBlock_Multimap_
Go from Id to residual block pointer.
Definition: Map.hpp:399
Header file for the ParameterBlock class.
Use okvis::ceres::PoseLocalParameterization2d (roll/pitch varying).
Definition: Map.hpp:106
Use okvis::ceres::PoseLocalParameterization4d (position and yaw varying).
Definition: Map.hpp:105
const ResidualBlockId2ResidualBlockSpec_Map & residualBlockId2ResidualBlockSpecMap() const
Get the actual map from Id to residual block specs.
Definition: Map.hpp:359
Id2ParameterBlock_Map id2ParameterBlock_Map_
The map connecting parameter block ID's and parameter blocks.
Definition: Map.hpp:393
Pose local parameterisation, i.e. for orientation dq(dalpha) x q_bar.
Definition: PoseLocalParameterization.hpp:52
std::unordered_map< ::ceres::ResidualBlockId, ParameterBlockCollection > ResidualBlockId2ParameterBlockCollection_Map
Go from residual block id to its parameter blocks.
Definition: Map.hpp:390
std::unordered_map< ::ceres::ResidualBlockId, ResidualBlockSpec > ResidualBlockId2ResidualBlockSpec_Map
The actual map from Id to residual block specs.
Definition: Map.hpp:352
bool setParameterization(std::shared_ptr< okvis::ceres::ParameterBlock > parameterBlock,::ceres::LocalParameterization *local_parameterization)
Set the (local) parameterisation of a parameter block.
Definition: Map.hpp:295
bool setParameterBlockConstant(uint64_t parameterBlockId)
Do not optimise a certain parameter block.
Definition: Map.cpp:568
::ceres::LossFunction * lossFunctionPtr
The m-estimator.
Definition: Map.hpp:92
void printResidualBlockInfo(::ceres::ResidualBlockId residualBlockId) const
Log information on a residual block.
Definition: Map.cpp:94
Use okvis::ceres::HomogeneousPointLocalParameterization.
Definition: Map.hpp:102
Struct to store some infos about a residual.
Definition: Map.hpp:72
std::unordered_map< uint64_t, std::shared_ptr< okvis::ceres::ParameterBlock > > Id2ParameterBlock_Map
The actual map from Id to parameter block pointer.
Definition: Map.hpp:349
The Map class. This keeps track of how parameter blocks are connected to residual blocks...
Definition: Map.hpp:63
No local parameterisation.
Definition: Map.hpp:107
Map()
Constructor.
Definition: Map.cpp:52
bool removeResidualBlock(::ceres::ResidualBlockId id)
Remove a residual block.
Definition: Map.cpp:537
okvis::ceres::PoseLocalParameterization2d poseLocalParameterization2d_
Store parameterisation locally.
Definition: Map.hpp:411
std::shared_ptr< okvis::ceres::ParameterBlock > parameterBlockPtr(uint64_t parameterBlockId)
Get a shared pointer to a parameter block.
Definition: Map.cpp:643
Pose local parameterisation, i.e. for orientation dq(dalpha) x q_bar. Here, we only perturb the trans...
Definition: PoseLocalParameterization.hpp:133
std::unordered_multimap< uint64_t, ResidualBlockSpec > Id2ResidualBlock_Multimap
Go from Id to residual block pointer.
Definition: Map.hpp:386
Base class providing the interface for parameter blocks.
Definition: ParameterBlock.hpp:53
This file contains useful typedefs and structs related to frames.