41 #ifndef INCLUDE_OKVIS_ESTIMATOR_HPP_
42 #define INCLUDE_OKVIS_ESTIMATOR_HPP_
48 #include <ceres/ceres.h>
81 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
92 Estimator(std::shared_ptr<okvis::ceres::Map> mapPtr);
141 void printStates(uint64_t poseId, std::ostream & buffer)
const;
150 const Eigen::Vector4d & landmark);
161 template<
class GEOMETRY_TYPE>
162 ::ceres::ResidualBlockId
addObservation(uint64_t landmarkId, uint64_t poseId,
163 size_t camIdx,
size_t keypointIdx);
202 void optimize(
size_t numIter,
size_t numThreads = 1,
bool verbose =
false);
221 "id="<<landmarkId<<
" inconsistent. isAdded = " << isAdded);
265 "Requested multi-frame does not exist in estimator.");
393 bool setLandmark(uint64_t landmarkId,
const Eigen::Vector4d & landmark);
409 void setMap(std::shared_ptr<okvis::ceres::Map> mapPtr) {
509 std::shared_ptr<ceres::ParameterBlock>& stateParameterBlockPtr)
const;
510 template<
class PARAMETER_BLOCK_T>
512 PARAMETER_BLOCK_T & stateParameterBlock)
const;
513 template<
class PARAMETER_BLOCK_T>
515 typename PARAMETER_BLOCK_T::estimate_t & state)
const;
518 int sensorType,
int stateType,
519 std::shared_ptr<ceres::ParameterBlock>& stateParameterBlockPtr)
const;
520 template<
class PARAMETER_BLOCK_T>
522 int sensorType,
int stateType,
523 PARAMETER_BLOCK_T & stateParameterBlock)
const;
524 template<
class PARAMETER_BLOCK_T>
526 int stateType,
typename PARAMETER_BLOCK_T::estimate_t & state)
const;
529 template<
class PARAMETER_BLOCK_T>
531 const typename PARAMETER_BLOCK_T::estimate_t & state);
532 template<
class PARAMETER_BLOCK_T>
534 int stateType,
const typename PARAMETER_BLOCK_T::estimate_t & state);
546 : isKeyframe(isKeyframe), id(id), timestamp(timestamp) {}
569 std::vector<okvis::ImuParameters, Eigen::aligned_allocator<okvis::ImuParameters> >
imuParametersVec_;
Pose.
Definition: Estimator.hpp:444
void clearCameras()
Remove all cameras from the configuration.
Definition: Estimator.cpp:100
The estimator class.
Definition: Estimator.hpp:77
StateInfo(uint64_t id=0, bool isRequired=true, bool exists=false)
Constructor.
Definition: Estimator.hpp:430
bool setCameraSensorStates(uint64_t poseId, size_t cameraIdx, const okvis::kinematics::Transformation &T_SCi)
Set the transformation from sensor to camera frame for a given pose ID.
Definition: Estimator.cpp:1067
bool setLandmark(uint64_t landmarkId, const Eigen::Vector4d &landmark)
Set the homogeneous coordinates for a landmark.
Definition: Estimator.cpp:1076
uint64_t frameIdByAge(size_t age) const
Get the ID of an older frame.
Definition: Estimator.cpp:1022
std::map< uint64_t, States > statesMap_
Buffer for currently considered states.
Definition: Estimator.hpp:555
std::shared_ptr< ::ceres::LossFunction > huberLossFunctionPtr_
Huber loss.
Definition: Estimator.hpp:573
std::shared_ptr< okvis::ceres::Map > mapPtr_
The underlying okvis::Map.
Definition: Estimator.hpp:557
Struct to define the behavior of the camera extrinsics.
Definition: Parameters.hpp:60
Eigen::Matrix< double, 1, 1 > Qff
Definition: Variables.hpp:59
std::mutex statesMutex_
Regulate access of landmarksMap_.
Definition: Estimator.hpp:564
States()
Definition: Estimator.hpp:544
A type to store information about a point in the world map.
Definition: FrameTypedefs.hpp:139
Camera.
Definition: Estimator.hpp:453
bool getGlobalStateParameterBlockPtr(uint64_t poseId, int stateType, std::shared_ptr< ceres::ParameterBlock > &stateParameterBlockPtr) const
Definition: Estimator.cpp:1110
bool getSensorStateParameterBlockAs(uint64_t poseId, int sensorIdx, int sensorType, int stateType, PARAMETER_BLOCK_T &stateParameterBlock) const
Definition: Estimator.cpp:1192
std::vector< okvis::ExtrinsicsEstimationParameters, Eigen::aligned_allocator< okvis::ExtrinsicsEstimationParameters > > extrinsicsEstimationParametersVec_
Extrinsics parameters.
Definition: Estimator.hpp:568
std::vector< StateInfo > SpecificSensorStatesContainer
Container for sensor states. The dimension can vary from sensor to sensor...
Definition: Estimator.hpp:538
std::array< std::vector< SpecificSensorStatesContainer >, 7 > AllSensorStatesContainer
Union of all sensor states.
Definition: Estimator.hpp:539
AllSensorStatesContainer sensors
Definition: Estimator.hpp:548
StaticPressureSensorStates
GpsSensorStates, currently unused.
Definition: Estimator.hpp:496
Magnetometer z-bias, currently unused.
Definition: Estimator.hpp:445
void setLandmarkInitialized(uint64_t landmarkId, bool initialized)
Set the landmark initialization state.
Definition: Estimator.cpp:1100
std::deque< ImuMeasurement, Eigen::aligned_allocator< ImuMeasurement > > ImuMeasurementDeque
Definition: Measurements.hpp:163
GpsSensorStates
GpsSensorStates, currently unused.
Definition: Estimator.hpp:484
uint64_t id
Definition: Estimator.hpp:550
Static pressure, currently unused.
Definition: Estimator.hpp:458
Header file for the CeresIterationCallback class. Used to enforce a time limit on the ceres optimizat...
Header file for the PoseParameterBlock class.
Header file for the MultiFrame class.
Header file for the Map class. This essentially encapsulates the ceres::Problem.
bool isLandmarkInitialized(uint64_t landmarkId) const
Checks whether the landmark is initialized.
Definition: Estimator.cpp:946
bool getSensorStateParameterBlockPtr(uint64_t poseId, int sensorIdx, int sensorType, int stateType, std::shared_ptr< ceres::ParameterBlock > &stateParameterBlockPtr) const
Definition: Estimator.cpp:1171
DynamicPressureSensorStates
GpsSensorStates, currently unused.
Definition: Estimator.hpp:502
Dynamic pressure, currently unused.
Definition: Estimator.hpp:459
position sensor frame to world, currently unused
Definition: Estimator.hpp:479
bool setSensorStateEstimateAs(uint64_t poseId, int sensorIdx, int sensorType, int stateType, const typename PARAMETER_BLOCK_T::estimate_t &state)
Definition: Estimator.cpp:1269
okvis::PointMap landmarksMap_
Contains all the current landmarks (synched after optimisation).
Definition: Estimator.hpp:563
Eigen::Matrix< double, 9, 1 > SpeedAndBias
Definition: FrameTypedefs.hpp:234
PositionSensorStates
PositionSensorStates, currently unused.
Definition: Estimator.hpp:477
uint64_t currentKeyframeId() const
Get the ID of the current keyframe.
Definition: Estimator.cpp:1010
bool setOptimizationTimeLimit(double timeLimit, int minIterations)
Set a time limit for the optimization process.
Definition: Estimator.cpp:909
std::shared_ptr< MultiFrame > MultiFramePtr
For convenience.
Definition: MultiFrame.hpp:272
This file contains the templated measurement structs, structs encapsulating Sensor data and related t...
void setMap(std::shared_ptr< okvis::ceres::Map > mapPtr)
set ceres map
Definition: Estimator.hpp:409
Position, currently unused.
Definition: Estimator.hpp:455
Header implementation file for the Estimator class.
okvis::Time timestamp
Definition: Estimator.hpp:551
int addImu(const okvis::ImuParameters &imuParameters)
Add an IMU to the configuration.
Definition: Estimator.cpp:89
void setKeyframe(uint64_t frameId, bool isKeyframe)
Set whether a frame is a keyframe or not.
Definition: Estimator.hpp:403
std::map< uint64_t, okvis::MultiFramePtr > multiFramePtrMap_
remember all needed okvis::MultiFrame.
Definition: Estimator.hpp:556
bool setSpeedAndBias(uint64_t poseId, size_t imuIdx, const okvis::SpeedAndBias &speedAndBias)
Set the speeds and IMU biases for a given pose ID.
Definition: Estimator.cpp:1060
Header file for the ReprojectionError class.
States This summarizes all the possible states – i.e. their ids:
Definition: Estimator.hpp:542
bool removeObservation(uint64_t landmarkId, uint64_t poseId, size_t camIdx, size_t keypointIdx)
Remove an observation from a landmark, if available.
Definition: Estimator.cpp:388
std::vector< MapPoint, Eigen::aligned_allocator< MapPoint > > MapPointVector
Definition: FrameTypedefs.hpp:172
Header file for the HomogeneousPointParameterBlock class.
bool getSpeedAndBias(uint64_t poseId, uint64_t imuIdx, okvis::SpeedAndBias &speedAndBias) const
Get speeds and IMU biases for a given pose ID.
Definition: Estimator.cpp:989
bool isInImuWindow(uint64_t frameId) const
Checks if a particular frame is still in the IMU window.
Definition: Estimator.cpp:1039
antenna offset, currently unused
Definition: Estimator.hpp:480
#define OKVIS_DEFINE_EXCEPTION(exceptionName, exceptionParent)
Macro for defining an exception with a given parent.
Definition: assert_macros.hpp:52
Magnetometer, currently unused.
Definition: Estimator.hpp:457
::ceres::ResidualBlockId marginalizationResidualId_
Remembers the marginalisation object's Id.
Definition: Estimator.hpp:577
bool setGlobalStateEstimateAs(uint64_t poseId, int stateType, const typename PARAMETER_BLOCK_T::estimate_t &state)
Definition: Estimator.cpp:1234
Extrinsics as T_SC.
Definition: Estimator.hpp:465
okvis::MultiFramePtr multiFrame(uint64_t frameId) const
Get a multiframe.
Definition: Estimator.hpp:263
bool addLandmark(uint64_t landmarkId, const Eigen::Vector4d &landmark)
Add a landmark.
Definition: Estimator.cpp:346
void optimize(size_t numIter, size_t numThreads=1, bool verbose=false)
Start ceres optimization.
Definition: Estimator.cpp:847
This file contains some useful assert macros.
bool isLandmarkAdded(uint64_t landmarkId) const
Checks whether the landmark is added to the estimator.
Definition: Estimator.hpp:218
bool isRequired
Whether or not we require the state.
Definition: Estimator.hpp:437
GPS, currently unused.
Definition: Estimator.hpp:456
IMU.
Definition: Estimator.hpp:454
bool applyMarginalizationStrategy(size_t numKeyframes, size_t numImuFrames, okvis::MapPointVector &removedLandmarks)
Applies the dropping/marginalization strategy according to the RSS'13/IJRR'14 paper. The new number of frames in the window will be numKeyframes+numImuFrames.
Definition: Estimator.cpp:434
Header file for the SpeedAndBiasParameterBlock class.
SensorStates
SensorStates The sensor-internal states enumerated.
Definition: Estimator.hpp:451
static bool initPoseFromImu(const okvis::ImuMeasurementDeque &imuMeasurements, okvis::kinematics::Transformation &T_WS)
Initialise pose from IMU measurements. For convenience as static.
Definition: Estimator.cpp:811
size_t getLandmarks(okvis::PointMap &landmarks) const
Get a copy of all the landmarks as a PointMap.
Definition: Estimator.cpp:954
MagnetometerSensorStates
MagnetometerSensorStates, currently unused.
Definition: Estimator.hpp:490
bool getSensorStateEstimateAs(uint64_t poseId, int sensorIdx, int sensorType, int stateType, typename PARAMETER_BLOCK_T::estimate_t &state) const
Definition: Estimator.cpp:1220
std::vector< okvis::ImuParameters, Eigen::aligned_allocator< okvis::ImuParameters > > imuParametersVec_
IMU parameters.
Definition: Estimator.hpp:569
ImuSensorStates
ImuSensorStates The IMU-internal states enumerated.
Definition: Estimator.hpp:471
void clearImus()
Remove all IMUs from the configuration.
Definition: Estimator.cpp:105
Alignment of global frame, currently unused.
Definition: Estimator.hpp:447
virtual ~Estimator()
Definition: Estimator.cpp:76
This file contains some typedefs related to state variables.
uint64_t currentFrameId() const
Get the ID of the newest frame added to the state.
Definition: Estimator.cpp:1033
bool getLandmark(uint64_t landmarkId, okvis::MapPoint &mapPoint) const
Get a specific landmark.
Definition: Estimator.cpp:933
bool addStates(okvis::MultiFramePtr multiFrame, const okvis::ImuMeasurementDeque &imuMeasurements, bool asKeyframe)
Add a pose to the state.
Definition: Estimator.cpp:110
bool exists
Whether or not this exists in the ceres problem.
Definition: Estimator.hpp:438
bool getGlobalStateParameterBlockAs(uint64_t poseId, int stateType, PARAMETER_BLOCK_T &stateParameterBlock) const
Definition: Estimator.cpp:1131
void printStates(uint64_t poseId, std::ostream &buffer) const
Prints state information to buffer.
Definition: Estimator.cpp:776
currently unused
Definition: Estimator.hpp:498
currently unused
Definition: Estimator.hpp:504
GlobalStates
GlobalStates The global states enumerated.
Definition: Estimator.hpp:442
Intrinsics.
Definition: Estimator.hpp:466
IMU parameters.
Definition: Parameters.hpp:105
size_t numFrames() const
Get the number of states/frames in the estimator.
Definition: Estimator.hpp:302
std::map< uint64_t, MapPoint, std::less< uint64_t >, Eigen::aligned_allocator< MapPoint > > PointMap
Definition: FrameTypedefs.hpp:174
CameraSensorStates
CameraSensorStates The camera-internal states enumerated.
Definition: Estimator.hpp:463
uint64_t referencePoseId_
The pose ID of the reference (currently not changing)
Definition: Estimator.hpp:560
GlobalStatesContainer global
Definition: Estimator.hpp:547
bool set_T_WS(uint64_t poseId, const okvis::kinematics::Transformation &T_WS)
Set pose for a given pose ID.
Definition: Estimator.cpp:1047
Time representation. May either represent wall clock time or ROS clock time.
Definition: Time.hpp:187
::ceres::ResidualBlockId addObservation(uint64_t landmarkId, uint64_t poseId, size_t camIdx, size_t keypointIdx)
Add an observation to a landmark.
int addCamera(const okvis::ExtrinsicsEstimationParameters &extrinsicsEstimationParameters)
Add a camera to the configuration. Sensors can only be added and never removed.
Definition: Estimator.cpp:81
std::array< StateInfo, 6 > GlobalStatesContainer
Container for global states.
Definition: Estimator.hpp:537
bool getCameraSensorStates(uint64_t poseId, size_t cameraIdx, okvis::kinematics::Transformation &T_SCi) const
Get camera states for a given pose ID.
Definition: Estimator.cpp:1001
uint64_t id
The ID.
Definition: Estimator.hpp:436
bool isKeyframe(uint64_t frameId) const
Checks if a particular frame is a keyframe.
Definition: Estimator.hpp:334
bool get_T_WS(uint64_t poseId, okvis::kinematics::Transformation &T_WS) const
Get pose for a given pose ID.
Definition: Estimator.cpp:975
Header file for the VioBackendInterface class.
StateInfo This configures the state vector ordering.
Definition: Estimator.hpp:424
States(bool isKeyframe, uint64_t id, okvis::Time timestamp)
Definition: Estimator.hpp:545
std::shared_ptr< ::ceres::LossFunction > cauchyLossFunctionPtr_
Cauchy loss.
Definition: Estimator.hpp:572
#define OKVIS_ASSERT_TRUE_DBG(exceptionType, condition, message)
Definition: assert_macros.hpp:211
std::shared_ptr< ceres::MarginalizationError > marginalizationErrorPtr_
The marginalisation class.
Definition: Estimator.hpp:576
antenna offset, currently unused
Definition: Estimator.hpp:486
bool isKeyframe
Definition: Estimator.hpp:549
size_t numLandmarks() const
Get the number of landmarks in the estimator.
Definition: Estimator.hpp:308
Header file for the MarginalizationError class.
bool getGlobalStateEstimateAs(uint64_t poseId, int stateType, typename PARAMETER_BLOCK_T::estimate_t &state) const
Definition: Estimator.cpp:1159
An abstract interface for backends.
Definition: VioBackendInterface.hpp:67
okvis::Time timestamp(uint64_t frameId) const
Get the timestamp for a particular frame.
Definition: Estimator.hpp:352
Eigen::Matrix< double, 3, 1 > MagnetometerBias
Definition: Variables.hpp:55
This file contains useful typedefs and structs related to frames.
std::unique_ptr< okvis::ceres::CeresIterationCallback > ceresCallback_
Maybe there was a callback registered, store it here.
Definition: Estimator.hpp:580
EIGEN_MAKE_ALIGNED_OPERATOR_NEW Estimator()
The default constructor.
Definition: Estimator.cpp:67